1
0
mirror of https://github.com/google/nomulus synced 2026-02-05 12:31:15 +00:00

Allow creation of hostnames on .zz-- style TLDs for RST (#2935)

This is a follow-on to PR #2909, which fixed the issue for domains, but
apparently not fully for hostnames.

BUG= http://b/476144993
This commit is contained in:
Ben McIlwain
2026-01-15 15:37:32 -05:00
committed by GitHub
parent 22ca4e3f2b
commit c187c92ae4
3 changed files with 49 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ package google.registry.flows.host;
import static google.registry.flows.domain.DomainFlowUtils.validateFirstLabel;
import static google.registry.model.EppResourceUtils.isActive;
import static google.registry.model.tld.Tlds.findTldForName;
import static google.registry.util.DomainNameUtils.canonicalizeHostname;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import static java.util.stream.Collectors.joining;
@@ -34,7 +35,6 @@ import google.registry.flows.EppException.StatusProhibitsOperationException;
import google.registry.model.ForeignKeyUtils;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.util.Idn;
import java.net.InetAddress;
import java.util.Optional;
import org.joda.time.DateTime;
@@ -57,7 +57,7 @@ public class HostFlowUtils {
throw new HostNameNotLowerCaseException(hostNameLowerCase);
}
try {
String hostNamePunyCoded = Idn.toASCII(name);
String hostNamePunyCoded = canonicalizeHostname(name);
if (!name.equals(hostNamePunyCoded)) {
throw new HostNameNotPunyCodedException(hostNamePunyCoded);
}

View File

@@ -45,6 +45,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
import google.registry.flows.host.HostFlowUtils.HostNameTooLongException;
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
import google.registry.flows.host.HostFlowUtils.LoopbackIpNotValidForHostException;
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException;
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException;
@@ -82,9 +83,14 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
}
private void doSuccessfulTest() throws Exception {
doSuccessfulTest("host_create_response.xml", ImmutableMap.of());
}
private void doSuccessfulTest(String responseFile, ImmutableMap<String, String> substitutions)
throws Exception {
clock.advanceOneMilli();
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("host_create_response.xml"));
runFlowAssertResponse(loadFile(responseFile, substitutions));
Host host = reloadResourceByForeignKey();
// Check that the host was created and persisted with a history entry.
assertAboutHosts()
@@ -134,6 +140,28 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
assertHostDnsRequests("ns1.example.tld");
}
@Test
void testSuccess_tldWithHyphenOn3And4() throws Exception {
setEppHostCreateInput("ns1.example.zz--main-2262", null);
doSuccessfulTest(
"host_create_response_wildcard.xml",
ImmutableMap.of("HOSTNAME", "ns1.example.zz--main-2262"));
}
@Test
void testFailure_domainWithHyphenOn3And4() throws Exception {
setEppHostCreateInput("ns1.zz--main-2262.tld", null);
EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
void testFailure_hostnameWithHyphenOn3And4() throws Exception {
setEppHostCreateInput("zz--ns1.domain.tld", null);
EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
void testFailure_multipartTLDsAndInvalidHost() {
createTlds("bar.tld", "tld");

View File

@@ -0,0 +1,18 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<host:creData
xmlns:host="urn:ietf:params:xml:ns:host-1.0">
<host:name>%HOSTNAME%</host:name>
<host:crDate>1999-04-03T22:00:00.0Z</host:crDate>
</host:creData>
</resData>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>