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
This commit is contained in:
mountford 2017-09-11 08:37:15 -07:00 committed by jianglai
parent 4b83615513
commit 985d14b51f
11 changed files with 573 additions and 87 deletions

View file

@ -31,6 +31,7 @@ import static org.mockito.Mockito.when;
import com.google.appengine.api.users.User; import com.google.appengine.api.users.User;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Period; 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 FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
private final SessionUtils sessionUtils = mock(SessionUtils.class); private final SessionUtils sessionUtils = mock(SessionUtils.class);
private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); private final User user = new User("rdap.user@example.com", "gmail.com", "12345");
private final UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
private RdapDomainAction action; private RdapDomainAction action;
@ -232,7 +234,6 @@ public class RdapDomainActionTest {
action.rdapLinkBase = "https://example.com/rdap/"; action.rdapLinkBase = "https://example.com/rdap/";
action.rdapWhoisServer = null; action.rdapWhoisServer = null;
action.sessionUtils = sessionUtils; action.sessionUtils = sessionUtils;
UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true);
when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar");
@ -284,17 +285,18 @@ public class RdapDomainActionTest {
if (obj instanceof Map) { if (obj instanceof Map) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) obj; Map<String, Object> map = (Map<String, Object>) obj;
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder =
builder.putAll(map); RdapTestHelper.getBuilderExcluding(
if (!map.containsKey("rdapConformance")) { map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); builder.put("rdapConformance", ImmutableList.of("rdap_level_0"));
} RdapTestHelper.addNotices(
if (!map.containsKey("notices")) { builder,
RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); "https://example.com/rdap/",
} (contactRoids == null)
if (!map.containsKey("remarks")) { ? RdapTestHelper.ContactNoticeType.DOMAIN
RdapTestHelper.addDomainBoilerplateRemarks(builder); : RdapTestHelper.ContactNoticeType.NONE,
} map.get("notices"));
RdapTestHelper.addDomainBoilerplateRemarks(builder, false, map.get("remarks"));
obj = builder.build(); obj = builder.build();
} }
return obj; return obj;
@ -348,6 +350,34 @@ public class RdapDomainActionTest {
assertThat(response.getStatus()).isEqualTo(200); 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 @Test
public void testTrailingDot_ignored() throws Exception { public void testTrailingDot_ignored() throws Exception {
assertJsonEqual( assertJsonEqual(

View file

@ -84,6 +84,7 @@ public class RdapDomainSearchActionTest {
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z")); private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
private final SessionUtils sessionUtils = mock(SessionUtils.class); private final SessionUtils sessionUtils = mock(SessionUtils.class);
private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); 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(); private final RdapDomainSearchAction action = new RdapDomainSearchAction();
@ -333,7 +334,6 @@ public class RdapDomainSearchActionTest {
action.rdapLinkBase = "https://example.com/rdap/"; action.rdapLinkBase = "https://example.com/rdap/";
action.rdapWhoisServer = null; action.rdapWhoisServer = null;
action.sessionUtils = sessionUtils; action.sessionUtils = sessionUtils;
UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true);
when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar");
@ -381,7 +381,7 @@ public class RdapDomainSearchActionTest {
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
builder.put("domainSearchResults", ImmutableList.of(obj)); builder.put("domainSearchResults", ImmutableList.of(obj));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); 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); RdapTestHelper.addDomainBoilerplateRemarks(builder);
return builder.build(); return builder.build();
} }
@ -454,6 +454,35 @@ public class RdapDomainSearchActionTest {
assertThat(response.getStatus()).isEqualTo(200); 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 * 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. * accord. If it does, the test will pass.

View file

@ -31,6 +31,7 @@ import static org.mockito.Mockito.when;
import com.google.appengine.api.users.User; import com.google.appengine.api.users.User;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.ContactResource;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.ofy.Ofy; 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 FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
private final SessionUtils sessionUtils = mock(SessionUtils.class); private final SessionUtils sessionUtils = mock(SessionUtils.class);
private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); private final User user = new User("rdap.user@example.com", "gmail.com", "12345");
UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
private RdapEntityAction action; private RdapEntityAction action;
@ -153,7 +155,6 @@ public class RdapEntityActionTest {
action.rdapLinkBase = "https://example.com/rdap/"; action.rdapLinkBase = "https://example.com/rdap/";
action.rdapWhoisServer = null; action.rdapWhoisServer = null;
action.sessionUtils = sessionUtils; action.sessionUtils = sessionUtils;
UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true);
when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar"); when(sessionUtils.getRegistrarClientId(request)).thenReturn("evilregistrar");
@ -182,21 +183,29 @@ public class RdapEntityActionTest {
private Object generateExpectedJsonWithTopLevelEntries( private Object generateExpectedJsonWithTopLevelEntries(
String handle, String handle,
String expectedOutputFile) { String expectedOutputFile) {
return generateExpectedJsonWithTopLevelEntries(handle, false, expectedOutputFile);
}
private Object generateExpectedJsonWithTopLevelEntries(
String handle,
boolean addNoPersonalDataRemark,
String expectedOutputFile) {
Object obj = generateExpectedJson(handle, expectedOutputFile); Object obj = generateExpectedJson(handle, expectedOutputFile);
if (obj instanceof Map) { if (obj instanceof Map) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) obj; Map<String, Object> map = (Map<String, Object>) obj;
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder =
builder.putAll(map); RdapTestHelper.getBuilderExcluding(
if (!map.containsKey("rdapConformance")) { map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); builder.put("rdapConformance", ImmutableList.of("rdap_level_0"));
} RdapTestHelper.addNotices(
if (!map.containsKey("notices")) { builder,
RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.com/rdap/"); "https://example.com/rdap/",
} addNoPersonalDataRemark
if (!map.containsKey("remarks")) { ? RdapTestHelper.ContactNoticeType.CONTACT
RdapTestHelper.addNonDomainBoilerplateRemarks(builder); : RdapTestHelper.ContactNoticeType.NONE,
} map.get("notices"));
RdapTestHelper.addNonDomainBoilerplateRemarks(builder, map.get("remarks"));
obj = builder.build(); obj = builder.build();
} }
return obj; return obj;
@ -226,6 +235,24 @@ public class RdapEntityActionTest {
assertThat(response.getStatus()).isEqualTo(200); 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 @Test
public void testValidAdminContact_works() throws Exception { public void testValidAdminContact_works() throws Exception {
assertThat(generateActualJson(adminContact.getRepoId())).isEqualTo( assertThat(generateActualJson(adminContact.getRepoId())).isEqualTo(

View file

@ -67,6 +67,7 @@ public class RdapEntitySearchActionTest {
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z")); private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
private final SessionUtils sessionUtils = mock(SessionUtils.class); private final SessionUtils sessionUtils = mock(SessionUtils.class);
private final User user = new User("rdap.user@example.com", "gmail.com", "12345"); 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(); private final RdapEntitySearchAction action = new RdapEntitySearchAction();
@ -145,7 +146,6 @@ public class RdapEntitySearchActionTest {
action.fnParam = Optional.absent(); action.fnParam = Optional.absent();
action.handleParam = Optional.absent(); action.handleParam = Optional.absent();
action.sessionUtils = sessionUtils; action.sessionUtils = sessionUtils;
UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo); action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true); when(sessionUtils.checkRegistrarConsoleLogin(request, userAuthInfo)).thenReturn(true);
when(sessionUtils.getRegistrarClientId(request)).thenReturn("2-RegistrarTest"); when(sessionUtils.getRegistrarClientId(request)).thenReturn("2-RegistrarTest");
@ -196,7 +196,7 @@ public class RdapEntitySearchActionTest {
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
builder.put("entitySearchResults", ImmutableList.of(obj)); builder.put("entitySearchResults", ImmutableList.of(obj));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); 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); RdapTestHelper.addNonDomainBoilerplateRemarks(builder);
return builder.build(); return builder.build();
} }
@ -308,6 +308,34 @@ public class RdapEntitySearchActionTest {
assertThat(response.getStatus()).isEqualTo(200); 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 @Test
public void testNameMatch_contactWildcardFound() throws Exception { public void testNameMatch_contactWildcardFound() throws Exception {
assertThat(generateActualJsonWithFullName("Blinky*")) assertThat(generateActualJsonWithFullName("Blinky*"))

View file

@ -22,6 +22,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import com.google.appengine.api.NamespaceManager; import com.google.appengine.api.NamespaceManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
@ -117,17 +118,16 @@ public class RdapNameserverActionTest {
if (obj instanceof Map) { if (obj instanceof Map) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) obj; Map<String, Object> map = (Map<String, Object>) obj;
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder =
builder.putAll(map); RdapTestHelper.getBuilderExcluding(
if (!map.containsKey("rdapConformance")) { map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); builder.put("rdapConformance", ImmutableList.of("rdap_level_0"));
} RdapTestHelper.addNotices(
if (!map.containsKey("notices")) { builder,
RdapTestHelper.addTermsOfServiceNotice(builder, "https://example.tld/rdap/"); "https://example.tld/rdap/",
} RdapTestHelper.ContactNoticeType.NONE,
if (!map.containsKey("remarks")) { map.get("notices"));
RdapTestHelper.addNonDomainBoilerplateRemarks(builder); RdapTestHelper.addNonDomainBoilerplateRemarks(builder, map.get("remarks"));
}
obj = builder.build(); obj = builder.build();
} }
return obj; return obj;

View file

@ -190,7 +190,7 @@ public class RdapNameserverSearchActionTest {
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>(); ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
builder.put("nameserverSearchResults", ImmutableList.of(obj)); builder.put("nameserverSearchResults", ImmutableList.of(obj));
builder.put("rdapConformance", ImmutableList.of("rdap_level_0")); 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); RdapTestHelper.addNonDomainBoilerplateRemarks(builder);
return builder.build(); return builder.build();
} }

View file

@ -17,16 +17,68 @@ package google.registry.rdap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.config.RdapNoticeDescriptor; 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 { public class RdapTestHelper {
static void addTermsOfServiceNotice( enum ContactNoticeType {
NONE,
DOMAIN,
CONTACT
}
static ImmutableMap.Builder<String, Object> getBuilderExcluding(
Map<String, Object> map, Set<String> keysToExclude) {
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
for (Entry<String, Object> entry : map.entrySet()) {
if (!keysToExclude.contains(entry.getKey())) {
builder.put(entry);
}
}
return builder;
}
static void addNotices(
ImmutableMap.Builder<String, Object> builder, String linkBase) { ImmutableMap.Builder<String, Object> builder, String linkBase) {
builder.put("notices", addNotices(builder, linkBase, ContactNoticeType.NONE, null);
ImmutableList.of( }
ImmutableMap.of(
"title", "RDAP Terms of Service", static void addNotices(
"description", ImmutableList.of( ImmutableMap.Builder<String, Object> builder,
String linkBase,
ContactNoticeType contactNoticeType,
@Nullable Object otherNotices) {
ImmutableList.Builder<ImmutableMap<String, Object>> noticesBuilder =
getBuilderWithOthersAdded(otherNotices);
switch (contactNoticeType) {
case DOMAIN:
noticesBuilder.add(
ImmutableMap.<String, Object>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.<String, Object>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.<String, Object>of(
"title", "RDAP Terms of Service",
"description",
ImmutableList.of(
"By querying our Domain Database, you are agreeing to comply with these terms" "By querying our Domain Database, you are agreeing to comply with these terms"
+ " so please read them carefully.", + " so please read them carefully.",
"Any information provided is 'as is' without any guarantee of accuracy.", "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" "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.", + " suspect that you have failed to comply with these terms.",
"We reserve the right to modify this agreement at any time."), "We reserve the right to modify this agreement at any time."),
"links", ImmutableList.of( "links",
ImmutableList.of(
ImmutableMap.of( ImmutableMap.of(
"value", linkBase + "help/tos", "value", linkBase + "help/tos",
"rel", "alternate", "rel", "alternate",
"href", "https://www.registry.tld/about/rdap/tos.html", "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<String, Object> builder) { static void addNonDomainBoilerplateRemarks(ImmutableMap.Builder<String, Object> builder) {
builder.put("remarks", addNonDomainBoilerplateRemarks(builder, null);
ImmutableList.of( }
ImmutableMap.of(
"description", static void addNonDomainBoilerplateRemarks(
ImmutableList.of( ImmutableMap.Builder<String, Object> builder, @Nullable Object otherRemarks) {
"This response conforms to the RDAP Operational Profile for gTLD Registries and" ImmutableList.Builder<ImmutableMap<String, Object>> remarksBuilder =
+ " Registrars version 1.0")))); getBuilderWithOthersAdded(otherRemarks);
remarksBuilder.add(
ImmutableMap.<String, Object>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<String, Object> builder) { static void addDomainBoilerplateRemarks(ImmutableMap.Builder<String, Object> builder) {
builder.put("remarks", addDomainBoilerplateRemarks(builder, false, null);
ImmutableList.of( }
ImmutableMap.of(
"description", static void addDomainBoilerplateRemarks(
ImmutableList.of( ImmutableMap.Builder<String, Object> builder,
"This response conforms to the RDAP Operational Profile for gTLD Registries and" boolean addNoContactRemark,
+ " Registrars version 1.0")), @Nullable Object otherRemarks) {
ImmutableMap.of( ImmutableList.Builder<ImmutableMap<String, Object>> remarksBuilder =
"title", getBuilderWithOthersAdded(otherRemarks);
"EPP Status Codes", if (addNoContactRemark) {
"description", remarksBuilder.add(
ImmutableList.of( ImmutableMap.<String, Object>of(
"For more information on domain status codes, please visit" "title", "Contacts Hidden",
+ " https://icann.org/epp"), "description",
"links", ImmutableList.of("Domain contacts are visible only to the owning registrar."),
ImmutableList.of( "type", "object truncated due to unexplainable reasons"));
ImmutableMap.of( }
"value", "https://icann.org/epp", remarksBuilder.add(
"rel", "alternate", ImmutableMap.<String, Object>of(
"href", "https://icann.org/epp", "description",
"type", "text/html"))), ImmutableList.of(
ImmutableMap.of( "This response conforms to the RDAP Operational Profile for gTLD Registries and"
"description", + " Registrars version 1.0")));
ImmutableList.of( remarksBuilder.add(
"URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf"), ImmutableMap.<String, Object>of(
"links", "title",
ImmutableList.of( "EPP Status Codes",
ImmutableMap.of( "description",
"value", "https://www.icann.org/wicf", ImmutableList.of(
"rel", "alternate", "For more information on domain status codes, please visit"
"href", "https://www.icann.org/wicf", + " https://icann.org/epp"),
"type", "text/html"))))); "links",
ImmutableList.of(
ImmutableMap.of(
"value", "https://icann.org/epp",
"rel", "alternate",
"href", "https://icann.org/epp",
"type", "text/html"))));
remarksBuilder.add(
ImmutableMap.<String, Object>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<ImmutableMap<String, Object>> getBuilderWithOthersAdded(
@Nullable Object others) {
ImmutableList.Builder<ImmutableMap<String, Object>> builder = new ImmutableList.Builder<>();
if ((others != null) && (others instanceof ImmutableList<?>)) {
@SuppressWarnings("unchecked")
ImmutableList<ImmutableMap<String, Object>> othersList =
(ImmutableList<ImmutableMap<String, Object>>) others;
builder.addAll(othersList);
}
return builder;
} }
static RdapJsonFormatter getTestRdapJsonFormatter() { static RdapJsonFormatter getTestRdapJsonFormatter() {

View file

@ -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"
}
]
}

View file

@ -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"
}
]
}

View file

@ -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"
}

View file

@ -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"
}
]
}