mirror of
https://github.com/google/nomulus.git
synced 2025-08-02 07:52:11 +02:00
Don't validate RDAP nameserver names using validateDomainName
The nameserver may be external, in which case its TLD will not appear in our list of valid TLDs, and the search will be rejected erroneously. Tests for letter case canonicalizations also added at reviewer's suggestion. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171985702
This commit is contained in:
parent
9d1eb0d429
commit
326cf698e0
15 changed files with 113 additions and 91 deletions
|
@ -15,7 +15,6 @@
|
|||
package google.registry.rdap;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource;
|
||||
|
@ -94,6 +93,8 @@ public class RdapNameserverActionTest {
|
|||
// other registrar
|
||||
persistResource(
|
||||
makeRegistrar("otherregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 102L));
|
||||
// external
|
||||
makeAndPersistHostResource("ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1));
|
||||
}
|
||||
|
||||
private RdapNameserverAction newRdapNameserverAction(
|
||||
|
@ -180,9 +181,12 @@ public class RdapNameserverActionTest {
|
|||
|
||||
@Test
|
||||
public void testInvalidNameserver_returns400() throws Exception {
|
||||
assertThat(generateActualJson("invalid/host/name")).isEqualTo(
|
||||
generateExpectedJson(
|
||||
"invalid/host/name is not a valid nameserver", null, "rdap_error_400.json"));
|
||||
assertThat(generateActualJson("invalid/host/name"))
|
||||
.isEqualTo(
|
||||
generateExpectedJson(
|
||||
"invalid/host/name is not a valid nameserver: Invalid host name",
|
||||
null,
|
||||
"rdap_error_400.json"));
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
}
|
||||
|
||||
|
@ -221,6 +225,20 @@ public class RdapNameserverActionTest {
|
|||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpperCase_getsCanonicalized() throws Exception {
|
||||
assertThat(generateActualJson("Ns1.CaT.lOl."))
|
||||
.isEqualTo(generateExpectedJsonWithTopLevelEntries(
|
||||
"ns1.cat.lol",
|
||||
ImmutableMap.of(
|
||||
"HANDLE", "2-ROID",
|
||||
"ADDRESSTYPE", "v4",
|
||||
"ADDRESS", "1.2.3.4",
|
||||
"STATUS", "active"),
|
||||
"rdap_host.json"));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryParameter_getsIgnored() throws Exception {
|
||||
assertThat(generateActualJson("ns1.cat.lol?key=value"))
|
||||
|
@ -279,6 +297,20 @@ public class RdapNameserverActionTest {
|
|||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExternalNameserver_works() throws Exception {
|
||||
assertThat(generateActualJson("ns1.domain.external"))
|
||||
.isEqualTo(generateExpectedJsonWithTopLevelEntries(
|
||||
"ns1.domain.external",
|
||||
ImmutableMap.of(
|
||||
"HANDLE", "C-ROID",
|
||||
"ADDRESSTYPE", "v4",
|
||||
"ADDRESS", "9.10.11.12",
|
||||
"STATUS", "active"),
|
||||
"rdap_host.json"));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNameserver_found_sameRegistrarRequested() throws Exception {
|
||||
assertThat(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue