|
45 | 45 | import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException; |
46 | 46 | import google.registry.flows.host.HostFlowUtils.HostNameTooLongException; |
47 | 47 | import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException; |
| 48 | +import google.registry.flows.host.HostFlowUtils.InvalidHostNameException; |
48 | 49 | import google.registry.flows.host.HostFlowUtils.LoopbackIpNotValidForHostException; |
49 | 50 | import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException; |
50 | 51 | import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException; |
@@ -82,9 +83,14 @@ private void setEppHostCreateInputWithIps(String hostName) { |
82 | 83 | } |
83 | 84 |
|
84 | 85 | private void doSuccessfulTest() throws Exception { |
| 86 | + doSuccessfulTest("host_create_response.xml", ImmutableMap.of()); |
| 87 | + } |
| 88 | + |
| 89 | + private void doSuccessfulTest(String responseFile, ImmutableMap<String, String> substitutions) |
| 90 | + throws Exception { |
85 | 91 | clock.advanceOneMilli(); |
86 | 92 | assertMutatingFlow(true); |
87 | | - runFlowAssertResponse(loadFile("host_create_response.xml")); |
| 93 | + runFlowAssertResponse(loadFile(responseFile, substitutions)); |
88 | 94 | Host host = reloadResourceByForeignKey(); |
89 | 95 | // Check that the host was created and persisted with a history entry. |
90 | 96 | assertAboutHosts() |
@@ -134,6 +140,28 @@ void testSuccess_internalNeverExisted() throws Exception { |
134 | 140 | assertHostDnsRequests("ns1.example.tld"); |
135 | 141 | } |
136 | 142 |
|
| 143 | + @Test |
| 144 | + void testSuccess_tldWithHyphenOn3And4() throws Exception { |
| 145 | + setEppHostCreateInput("ns1.example.zz--main-2262", null); |
| 146 | + doSuccessfulTest( |
| 147 | + "host_create_response_wildcard.xml", |
| 148 | + ImmutableMap.of("HOSTNAME", "ns1.example.zz--main-2262")); |
| 149 | + } |
| 150 | + |
| 151 | + @Test |
| 152 | + void testFailure_domainWithHyphenOn3And4() throws Exception { |
| 153 | + setEppHostCreateInput("ns1.zz--main-2262.tld", null); |
| 154 | + EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow); |
| 155 | + assertAboutEppExceptions().that(thrown).marshalsToXml(); |
| 156 | + } |
| 157 | + |
| 158 | + @Test |
| 159 | + void testFailure_hostnameWithHyphenOn3And4() throws Exception { |
| 160 | + setEppHostCreateInput("zz--ns1.domain.tld", null); |
| 161 | + EppException thrown = assertThrows(InvalidHostNameException.class, this::runFlow); |
| 162 | + assertAboutEppExceptions().that(thrown).marshalsToXml(); |
| 163 | + } |
| 164 | + |
137 | 165 | @Test |
138 | 166 | void testFailure_multipartTLDsAndInvalidHost() { |
139 | 167 | createTlds("bar.tld", "tld"); |
|
0 commit comments