From 985d14b51fcfe7b97df9b32a34a0710954a1f004 Mon Sep 17 00:00:00 2001 From: mountford Date: Mon, 11 Sep 2017 08:37:15 -0700 Subject: [PATCH] Add more tests for RDAP contact data permissioning This CL adds extra tests to make sure that contact data is hidden for RDAP domain and contact requests when not logged in as the proper registrar. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168234733 --- .../registry/rdap/RdapDomainActionTest.java | 54 +++-- .../rdap/RdapDomainSearchActionTest.java | 33 +++- .../registry/rdap/RdapEntityActionTest.java | 51 +++-- .../rdap/RdapEntitySearchActionTest.java | 32 ++- .../rdap/RdapNameserverActionTest.java | 22 +-- .../rdap/RdapNameserverSearchActionTest.java | 2 +- .../google/registry/rdap/RdapTestHelper.java | 186 +++++++++++++----- ...p_associated_contact_no_personal_data.json | 25 +++ ..._contact_no_personal_data_with_remark.json | 34 ++++ .../testdata/rdap_domain_no_contacts.json | 106 ++++++++++ .../rdap_domain_no_contacts_with_remark.json | 115 +++++++++++ 11 files changed, 573 insertions(+), 87 deletions(-) create mode 100644 javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json create mode 100644 javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json create mode 100644 javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json create mode 100644 javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json diff --git a/javatests/google/registry/rdap/RdapDomainActionTest.java b/javatests/google/registry/rdap/RdapDomainActionTest.java index ff5b35c4c..d267b9540 100644 --- a/javatests/google/registry/rdap/RdapDomainActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainActionTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; @@ -77,6 +78,7 @@ public class RdapDomainActionTest { private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ")); private final SessionUtils sessionUtils = mock(SessionUtils.class); private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); + private final UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); private RdapDomainAction action; @@ -232,7 +234,6 @@ public class RdapDomainActionTest { action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; action.sessionUtils = sessionUtils; - UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); @@ -284,17 +285,18 @@ public class RdapDomainActionTest { if (obj instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) obj; - ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); - builder.putAll(map); - if (!map.containsKey("rdapConformance")) { - builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - } - if (!map.containsKey("notices")) { - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); - } - if (!map.containsKey("remarks")) { - RdapTestHelper.addDomainBoilerplateRemarks(builder); - } + ImmutableMap.Builder builder = + RdapTestHelper.getBuilderExcluding( + map, ImmutableSet.of("rdapConformance", "notices", "remarks")); + builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); + RdapTestHelper.addNotices( + builder, + "https://example.com/rdap/", + (contactRoids == null) + ? RdapTestHelper.ContactNoticeType.DOMAIN + : RdapTestHelper.ContactNoticeType.NONE, + map.get("notices")); + RdapTestHelper.addDomainBoilerplateRemarks(builder, false, map.get("remarks")); obj = builder.build(); } return obj; @@ -348,6 +350,34 @@ public class RdapDomainActionTest { assertThat(response.getStatus()).isEqualTo(200); } + @Test + public void testValidDomain_notLoggedIn_noContacts() throws Exception { + when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(false); + assertJsonEqual( + generateActualJson("cat.lol"), + generateExpectedJsonWithTopLevelEntries( + "cat.lol", + null, + "C-LOL", + null, + "rdap_domain_no_contacts.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + + @Test + public void testValidDomain_loggedInAsOtherRegistrar_noContacts() throws Exception { + when(sessionUtils.getRegistrarClientId(request)).thenReturn("otherregistrar"); + assertJsonEqual( + generateActualJson("cat.lol"), + generateExpectedJsonWithTopLevelEntries( + "cat.lol", + null, + "C-LOL", + null, + "rdap_domain_no_contacts.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + @Test public void testTrailingDot_ignored() throws Exception { assertJsonEqual( diff --git a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java index 4ce0166db..4149e4b3c 100644 --- a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java @@ -84,6 +84,7 @@ public class RdapDomainSearchActionTest { private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z")); private final SessionUtils sessionUtils = mock(SessionUtils.class); private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); + UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); private final RdapDomainSearchAction action = new RdapDomainSearchAction(); @@ -333,7 +334,6 @@ public class RdapDomainSearchActionTest { action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; action.sessionUtils = sessionUtils; - UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); @@ -381,7 +381,7 @@ public class RdapDomainSearchActionTest { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); builder.put("domainSearchResults", ImmutableList.of(obj)); builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); + RdapTestHelper.addNotices(builder, "https://example.com/rdap/"); RdapTestHelper.addDomainBoilerplateRemarks(builder); return builder.build(); } @@ -454,6 +454,35 @@ public class RdapDomainSearchActionTest { assertThat(response.getStatus()).isEqualTo(200); } + @Test + public void testDomainMatch_found_notLoggedIn() throws Exception { + when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(false); + when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); + assertThat(generateActualJson(RequestType.NAME, "cat.lol")) + .isEqualTo( + generateExpectedJsonForDomain( + "cat.lol", + null, + "C-LOL", + null, + "rdap_domain_no_contacts_with_remark.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + + @Test + public void testDomainMatch_found_loggedInAsOtherRegistrar() throws Exception { + when(sessionUtils.getRegistrarClientId(request)).thenReturn("otherregistrar"); + assertThat(generateActualJson(RequestType.NAME, "cat.lol")) + .isEqualTo( + generateExpectedJsonForDomain( + "cat.lol", + null, + "C-LOL", + null, + "rdap_domain_no_contacts_with_remark.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + /* * This test is flaky because IDN.toASCII may or may not remove the trailing dot of its own * accord. If it does, the test will pass. diff --git a/javatests/google/registry/rdap/RdapEntityActionTest.java b/javatests/google/registry/rdap/RdapEntityActionTest.java index 9862ca801..62212f1f3 100644 --- a/javatests/google/registry/rdap/RdapEntityActionTest.java +++ b/javatests/google/registry/rdap/RdapEntityActionTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import com.google.appengine.api.users.User; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import google.registry.model.contact.ContactResource; import google.registry.model.host.HostResource; import google.registry.model.ofy.Ofy; @@ -70,6 +71,7 @@ public class RdapEntityActionTest { private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ")); private final SessionUtils sessionUtils = mock(SessionUtils.class); private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); + UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); private RdapEntityAction action; @@ -153,7 +155,6 @@ public class RdapEntityActionTest { action.rdapLinkBase = "https://example.com/rdap/"; action.rdapWhoisServer = null; action.sessionUtils = sessionUtils; - UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); @@ -182,21 +183,29 @@ public class RdapEntityActionTest { private Object generateExpectedJsonWithTopLevelEntries( String handle, String expectedOutputFile) { + return generateExpectedJsonWithTopLevelEntries(handle, false, expectedOutputFile); + } + + private Object generateExpectedJsonWithTopLevelEntries( + String handle, + boolean addNoPersonalDataRemark, + String expectedOutputFile) { Object obj = generateExpectedJson(handle, expectedOutputFile); if (obj instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) obj; - ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); - builder.putAll(map); - if (!map.containsKey("rdapConformance")) { - builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - } - if (!map.containsKey("notices")) { - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); - } - if (!map.containsKey("remarks")) { - RdapTestHelper.addNonDomainBoilerplateRemarks(builder); - } + ImmutableMap.Builder builder = + RdapTestHelper.getBuilderExcluding( + map, ImmutableSet.of("rdapConformance", "notices", "remarks")); + builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); + RdapTestHelper.addNotices( + builder, + "https://example.com/rdap/", + addNoPersonalDataRemark + ? RdapTestHelper.ContactNoticeType.CONTACT + : RdapTestHelper.ContactNoticeType.NONE, + map.get("notices")); + RdapTestHelper.addNonDomainBoilerplateRemarks(builder, map.get("remarks")); obj = builder.build(); } return obj; @@ -226,6 +235,24 @@ public class RdapEntityActionTest { assertThat(response.getStatus()).isEqualTo(200); } + @Test + public void testValidRegistrantContact_works_notLoggedIn() throws Exception { + when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(false); + assertThat(generateActualJson(registrant.getRepoId())).isEqualTo( + generateExpectedJsonWithTopLevelEntries( + registrant.getRepoId(), true, "rdap_associated_contact_no_personal_data.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + + @Test + public void testValidRegistrantContact_works_loggedInAsOtherRegistrar() throws Exception { + when(sessionUtils.getRegistrarClientId(request)).thenReturn("otherregistrar"); + assertThat(generateActualJson(registrant.getRepoId())).isEqualTo( + generateExpectedJsonWithTopLevelEntries( + registrant.getRepoId(), true, "rdap_associated_contact_no_personal_data.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + @Test public void testValidAdminContact_works() throws Exception { assertThat(generateActualJson(adminContact.getRepoId())).isEqualTo( diff --git a/javatests/google/registry/rdap/RdapEntitySearchActionTest.java b/javatests/google/registry/rdap/RdapEntitySearchActionTest.java index f9b44c3cf..34c665255 100644 --- a/javatests/google/registry/rdap/RdapEntitySearchActionTest.java +++ b/javatests/google/registry/rdap/RdapEntitySearchActionTest.java @@ -67,6 +67,7 @@ public class RdapEntitySearchActionTest { private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z")); private final SessionUtils sessionUtils = mock(SessionUtils.class); private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); + UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); private final RdapEntitySearchAction action = new RdapEntitySearchAction(); @@ -145,7 +146,6 @@ public class RdapEntitySearchActionTest { action.fnParam = Optional.absent(); action.handleParam = Optional.absent(); action.sessionUtils = sessionUtils; - UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.getRegistrarClientId(request)).thenReturn("2-RegistrarTest"); @@ -196,7 +196,7 @@ public class RdapEntitySearchActionTest { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); builder.put("entitySearchResults", ImmutableList.of(obj)); builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); + RdapTestHelper.addNotices(builder, "https://example.com/rdap/"); RdapTestHelper.addNonDomainBoilerplateRemarks(builder); return builder.build(); } @@ -308,6 +308,34 @@ public class RdapEntitySearchActionTest { assertThat(response.getStatus()).isEqualTo(200); } + @Test + public void testNameMatch_contactFound_notLoggedIn() throws Exception { + when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(false); + assertThat(generateActualJsonWithFullName("Blinky (赤ベイ)")) + .isEqualTo( + generateExpectedJsonForEntity( + "2-ROID", + "Blinky (赤ベイ)", + "blinky@b.tld", + "\"123 Blinky St\", \"Blinkyland\"", + "rdap_contact_no_personal_data_with_remark.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + + @Test + public void testNameMatch_contactFound_loggedInAsOtherRegistrar() throws Exception { + when(sessionUtils.getRegistrarClientId(request)).thenReturn("otherregistrar"); + assertThat(generateActualJsonWithFullName("Blinky (赤ベイ)")) + .isEqualTo( + generateExpectedJsonForEntity( + "2-ROID", + "Blinky (赤ベイ)", + "blinky@b.tld", + "\"123 Blinky St\", \"Blinkyland\"", + "rdap_contact_no_personal_data_with_remark.json")); + assertThat(response.getStatus()).isEqualTo(200); + } + @Test public void testNameMatch_contactWildcardFound() throws Exception { assertThat(generateActualJsonWithFullName("Blinky*")) diff --git a/javatests/google/registry/rdap/RdapNameserverActionTest.java b/javatests/google/registry/rdap/RdapNameserverActionTest.java index c34d56b6b..686053134 100644 --- a/javatests/google/registry/rdap/RdapNameserverActionTest.java +++ b/javatests/google/registry/rdap/RdapNameserverActionTest.java @@ -22,6 +22,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions; import com.google.appengine.api.NamespaceManager; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; @@ -117,17 +118,16 @@ public class RdapNameserverActionTest { if (obj instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) obj; - ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); - builder.putAll(map); - if (!map.containsKey("rdapConformance")) { - builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - } - if (!map.containsKey("notices")) { - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.tld/rdap/"); - } - if (!map.containsKey("remarks")) { - RdapTestHelper.addNonDomainBoilerplateRemarks(builder); - } + ImmutableMap.Builder builder = + RdapTestHelper.getBuilderExcluding( + map, ImmutableSet.of("rdapConformance", "notices", "remarks")); + builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); + RdapTestHelper.addNotices( + builder, + "https://example.tld/rdap/", + RdapTestHelper.ContactNoticeType.NONE, + map.get("notices")); + RdapTestHelper.addNonDomainBoilerplateRemarks(builder, map.get("remarks")); obj = builder.build(); } return obj; diff --git a/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java b/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java index f75cd482e..d94421c07 100644 --- a/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapNameserverSearchActionTest.java @@ -190,7 +190,7 @@ public class RdapNameserverSearchActionTest { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); builder.put("nameserverSearchResults", ImmutableList.of(obj)); builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); - RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.tld/rdap/"); + RdapTestHelper.addNotices(builder, "https://example.tld/rdap/"); RdapTestHelper.addNonDomainBoilerplateRemarks(builder); return builder.build(); } diff --git a/javatests/google/registry/rdap/RdapTestHelper.java b/javatests/google/registry/rdap/RdapTestHelper.java index fe9222b60..27f0852dd 100644 --- a/javatests/google/registry/rdap/RdapTestHelper.java +++ b/javatests/google/registry/rdap/RdapTestHelper.java @@ -17,16 +17,68 @@ package google.registry.rdap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import google.registry.config.RdapNoticeDescriptor; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import javax.annotation.Nullable; public class RdapTestHelper { - static void addTermsOfServiceNotice( + enum ContactNoticeType { + NONE, + DOMAIN, + CONTACT + } + + static ImmutableMap.Builder getBuilderExcluding( + Map map, Set keysToExclude) { + ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); + for (Entry entry : map.entrySet()) { + if (!keysToExclude.contains(entry.getKey())) { + builder.put(entry); + } + } + return builder; + } + + static void addNotices( ImmutableMap.Builder builder, String linkBase) { - builder.put("notices", - ImmutableList.of( - ImmutableMap.of( - "title", "RDAP Terms of Service", - "description", ImmutableList.of( + addNotices(builder, linkBase, ContactNoticeType.NONE, null); + } + + static void addNotices( + ImmutableMap.Builder builder, + String linkBase, + ContactNoticeType contactNoticeType, + @Nullable Object otherNotices) { + ImmutableList.Builder> noticesBuilder = + getBuilderWithOthersAdded(otherNotices); + switch (contactNoticeType) { + case DOMAIN: + noticesBuilder.add( + ImmutableMap.of( + "title", "Contacts Hidden", + "description", + ImmutableList.of("Domain contacts are visible only to the owning registrar."), + "type", "object truncated due to unexplainable reasons")); + break; + case CONTACT: + noticesBuilder.add( + ImmutableMap.of( + "title", "Contact Personal Data Hidden", + "description", + ImmutableList.of( + "Contact personal data is visible only to the owning registrar."), + "type", "object truncated due to unexplainable reasons")); + break; + default: + break; + } + noticesBuilder.add( + ImmutableMap.of( + "title", "RDAP Terms of Service", + "description", + ImmutableList.of( "By querying our Domain Database, you are agreeing to comply with these terms" + " so please read them carefully.", "Any information provided is 'as is' without any guarantee of accuracy.", @@ -48,57 +100,97 @@ public class RdapTestHelper { "We reserve the right to restrict or deny your access to the database if we" + " suspect that you have failed to comply with these terms.", "We reserve the right to modify this agreement at any time."), - "links", ImmutableList.of( + "links", + ImmutableList.of( ImmutableMap.of( "value", linkBase + "help/tos", "rel", "alternate", "href", "https://www.registry.tld/about/rdap/tos.html", - "type", "text/html"))))); + "type", "text/html")))); + builder.put("notices", noticesBuilder.build()); } static void addNonDomainBoilerplateRemarks(ImmutableMap.Builder builder) { - builder.put("remarks", - ImmutableList.of( - ImmutableMap.of( - "description", - ImmutableList.of( - "This response conforms to the RDAP Operational Profile for gTLD Registries and" - + " Registrars version 1.0")))); + addNonDomainBoilerplateRemarks(builder, null); + } + + static void addNonDomainBoilerplateRemarks( + ImmutableMap.Builder builder, @Nullable Object otherRemarks) { + ImmutableList.Builder> remarksBuilder = + getBuilderWithOthersAdded(otherRemarks); + remarksBuilder.add( + ImmutableMap.of( + "description", + ImmutableList.of( + "This response conforms to the RDAP Operational Profile for gTLD Registries and" + + " Registrars version 1.0"))); + builder.put("remarks", remarksBuilder.build()); } static void addDomainBoilerplateRemarks(ImmutableMap.Builder builder) { - builder.put("remarks", - ImmutableList.of( - ImmutableMap.of( - "description", - ImmutableList.of( - "This response conforms to the RDAP Operational Profile for gTLD Registries and" - + " Registrars version 1.0")), - ImmutableMap.of( - "title", - "EPP Status Codes", - "description", - ImmutableList.of( - "For more information on domain status codes, please visit" - + " https://icann.org/epp"), - "links", - ImmutableList.of( - ImmutableMap.of( - "value", "https://icann.org/epp", - "rel", "alternate", - "href", "https://icann.org/epp", - "type", "text/html"))), - ImmutableMap.of( - "description", - ImmutableList.of( - "URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf"), - "links", - ImmutableList.of( - ImmutableMap.of( - "value", "https://www.icann.org/wicf", - "rel", "alternate", - "href", "https://www.icann.org/wicf", - "type", "text/html"))))); + addDomainBoilerplateRemarks(builder, false, null); + } + + static void addDomainBoilerplateRemarks( + ImmutableMap.Builder builder, + boolean addNoContactRemark, + @Nullable Object otherRemarks) { + ImmutableList.Builder> remarksBuilder = + getBuilderWithOthersAdded(otherRemarks); + if (addNoContactRemark) { + remarksBuilder.add( + ImmutableMap.of( + "title", "Contacts Hidden", + "description", + ImmutableList.of("Domain contacts are visible only to the owning registrar."), + "type", "object truncated due to unexplainable reasons")); + } + remarksBuilder.add( + ImmutableMap.of( + "description", + ImmutableList.of( + "This response conforms to the RDAP Operational Profile for gTLD Registries and" + + " Registrars version 1.0"))); + remarksBuilder.add( + ImmutableMap.of( + "title", + "EPP Status Codes", + "description", + ImmutableList.of( + "For more information on domain status codes, please visit" + + " https://icann.org/epp"), + "links", + ImmutableList.of( + ImmutableMap.of( + "value", "https://icann.org/epp", + "rel", "alternate", + "href", "https://icann.org/epp", + "type", "text/html")))); + remarksBuilder.add( + ImmutableMap.of( + "description", + ImmutableList.of( + "URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf"), + "links", + ImmutableList.of( + ImmutableMap.of( + "value", "https://www.icann.org/wicf", + "rel", "alternate", + "href", "https://www.icann.org/wicf", + "type", "text/html")))); + builder.put("remarks", remarksBuilder.build()); + } + + private static ImmutableList.Builder> getBuilderWithOthersAdded( + @Nullable Object others) { + ImmutableList.Builder> builder = new ImmutableList.Builder<>(); + if ((others != null) && (others instanceof ImmutableList)) { + @SuppressWarnings("unchecked") + ImmutableList> othersList = + (ImmutableList>) others; + builder.addAll(othersList); + } + return builder; } static RdapJsonFormatter getTestRdapJsonFormatter() { diff --git a/javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json b/javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json new file mode 100644 index 000000000..91c817b1e --- /dev/null +++ b/javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json @@ -0,0 +1,25 @@ +{ + "objectClassName" : "entity", + "handle" : "%NAME%", + "status" : ["active", "associated"], + "links" : + [ + { + "value" : "https://example.com/rdap/entity/%NAME%", + "rel" : "self", + "href": "https://example.com/rdap/entity/%NAME%", + "type" : "application/rdap+json" + } + ], + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "2000-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ] +} diff --git a/javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json b/javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json new file mode 100644 index 000000000..1b597f5c5 --- /dev/null +++ b/javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json @@ -0,0 +1,34 @@ +{ + "objectClassName" : "entity", + "handle" : "%NAME%", + "status" : ["active"], + "links" : + [ + { + "value" : "https://example.com/rdap/entity/%NAME%", + "rel" : "self", + "href": "https://example.com/rdap/entity/%NAME%", + "type" : "application/rdap+json" + } + ], + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "2000-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "remarks": [ + { + "title": "Contact Personal Data Hidden", + "description": [ + "Contact personal data is visible only to the owning registrar." + ], + "type": "object truncated due to unexplainable reasons" + } + ] +} diff --git a/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json b/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json new file mode 100644 index 000000000..c912fb530 --- /dev/null +++ b/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json @@ -0,0 +1,106 @@ +{ + "status": [ + "client delete prohibited", + "client renew prohibited", + "client transfer prohibited", + "server update prohibited" + ], + "handle": "%HANDLE%", + "links": [ + { + "href": "https://example.com/rdap/domain/%NAME%", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/domain/%NAME%" + } + ], + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "2000-01-01T00:00:00.000Z" + }, + { + "eventAction": "expiration", + "eventDate": "2110-10-08T00:44:59.000Z" + }, + { + "eventAction": "last changed", + "eventDate": "2009-05-29T20:13:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "nameservers": [ + { + "status": [ + "active", + "associated" + ], + "handle": "8-ROID", + "links": [ + { + "href": "https://example.com/rdap/nameserver/ns1.cat.lol", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/nameserver/ns1.cat.lol" + } + ], + "ldhName": "ns1.cat.lol", + "ipAddresses": { + "v4": [ + "1.2.3.4" + ] + }, + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "1999-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "objectClassName": "nameserver" + }, + { + "status": [ + "active", + "associated" + ], + "handle": "A-ROID", + "links": [ + { + "href": "https://example.com/rdap/nameserver/ns2.cat.lol", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/nameserver/ns2.cat.lol" + } + ], + "ldhName": "ns2.cat.lol", + "ipAddresses": { + "v6": [ + "bad:f00d:cafe::15:beef" + ] + }, + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "1998-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "objectClassName": "nameserver" + } + ], + "ldhName": "%NAME%", + "objectClassName": "domain" +} diff --git a/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json b/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json new file mode 100644 index 000000000..ffd156470 --- /dev/null +++ b/javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json @@ -0,0 +1,115 @@ +{ + "status": [ + "client delete prohibited", + "client renew prohibited", + "client transfer prohibited", + "server update prohibited" + ], + "handle": "%HANDLE%", + "links": [ + { + "href": "https://example.com/rdap/domain/%NAME%", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/domain/%NAME%" + } + ], + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "2000-01-01T00:00:00.000Z" + }, + { + "eventAction": "expiration", + "eventDate": "2110-10-08T00:44:59.000Z" + }, + { + "eventAction": "last changed", + "eventDate": "2009-05-29T20:13:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "nameservers": [ + { + "status": [ + "active", + "associated" + ], + "handle": "8-ROID", + "links": [ + { + "href": "https://example.com/rdap/nameserver/ns1.cat.lol", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/nameserver/ns1.cat.lol" + } + ], + "ldhName": "ns1.cat.lol", + "ipAddresses": { + "v4": [ + "1.2.3.4" + ] + }, + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "1999-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "objectClassName": "nameserver" + }, + { + "status": [ + "active", + "associated" + ], + "handle": "A-ROID", + "links": [ + { + "href": "https://example.com/rdap/nameserver/ns2.cat.lol", + "type": "application/rdap+json", + "rel": "self", + "value": "https://example.com/rdap/nameserver/ns2.cat.lol" + } + ], + "ldhName": "ns2.cat.lol", + "ipAddresses": { + "v6": [ + "bad:f00d:cafe::15:beef" + ] + }, + "events": [ + { + "eventAction": "registration", + "eventActor": "foo", + "eventDate": "1998-01-01T00:00:00.000Z" + }, + { + "eventAction": "last update of RDAP database", + "eventDate": "2000-01-01T00:00:00.000Z" + } + ], + "objectClassName": "nameserver" + } + ], + "ldhName": "%NAME%", + "objectClassName": "domain", + "remarks": [ + { + "title": "Contacts Hidden", + "description": [ + "Domain contacts are visible only to the owning registrar." + ], + "type": "object truncated due to unexplainable reasons" + } + ] +}