mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 20:17:51 +02:00
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:
parent
4b83615513
commit
985d14b51f
11 changed files with 573 additions and 87 deletions
|
@ -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<String, Object> map = (Map<String, Object>) obj;
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.putAll(map);
|
||||
if (!map.containsKey("rdapConformance")) {
|
||||
ImmutableMap.Builder<String, Object> builder =
|
||||
RdapTestHelper.getBuilderExcluding(
|
||||
map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
|
||||
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);
|
||||
}
|
||||
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(
|
||||
|
|
|
@ -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<String, Object> 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.
|
||||
|
|
|
@ -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<String, Object> map = (Map<String, Object>) obj;
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.putAll(map);
|
||||
if (!map.containsKey("rdapConformance")) {
|
||||
ImmutableMap.Builder<String, Object> builder =
|
||||
RdapTestHelper.getBuilderExcluding(
|
||||
map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
|
||||
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);
|
||||
}
|
||||
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(
|
||||
|
|
|
@ -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<String, Object> 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*"))
|
||||
|
|
|
@ -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<String, Object> map = (Map<String, Object>) obj;
|
||||
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
||||
builder.putAll(map);
|
||||
if (!map.containsKey("rdapConformance")) {
|
||||
ImmutableMap.Builder<String, Object> builder =
|
||||
RdapTestHelper.getBuilderExcluding(
|
||||
map, ImmutableSet.of("rdapConformance", "notices", "remarks"));
|
||||
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);
|
||||
}
|
||||
RdapTestHelper.addNotices(
|
||||
builder,
|
||||
"https://example.tld/rdap/",
|
||||
RdapTestHelper.ContactNoticeType.NONE,
|
||||
map.get("notices"));
|
||||
RdapTestHelper.addNonDomainBoilerplateRemarks(builder, map.get("remarks"));
|
||||
obj = builder.build();
|
||||
}
|
||||
return obj;
|
||||
|
|
|
@ -190,7 +190,7 @@ public class RdapNameserverSearchActionTest {
|
|||
ImmutableMap.Builder<String, Object> 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();
|
||||
}
|
||||
|
|
|
@ -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<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) {
|
||||
builder.put("notices",
|
||||
addNotices(builder, linkBase, ContactNoticeType.NONE, null);
|
||||
}
|
||||
|
||||
static void addNotices(
|
||||
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(
|
||||
ImmutableMap.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(
|
||||
"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,33 +100,59 @@ 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<String, Object> builder) {
|
||||
builder.put("remarks",
|
||||
ImmutableList.of(
|
||||
ImmutableMap.of(
|
||||
addNonDomainBoilerplateRemarks(builder, null);
|
||||
}
|
||||
|
||||
static void addNonDomainBoilerplateRemarks(
|
||||
ImmutableMap.Builder<String, Object> builder, @Nullable Object otherRemarks) {
|
||||
ImmutableList.Builder<ImmutableMap<String, Object>> remarksBuilder =
|
||||
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"))));
|
||||
+ " Registrars version 1.0")));
|
||||
builder.put("remarks", remarksBuilder.build());
|
||||
}
|
||||
|
||||
static void addDomainBoilerplateRemarks(ImmutableMap.Builder<String, Object> builder) {
|
||||
builder.put("remarks",
|
||||
ImmutableList.of(
|
||||
ImmutableMap.of(
|
||||
addDomainBoilerplateRemarks(builder, false, null);
|
||||
}
|
||||
|
||||
static void addDomainBoilerplateRemarks(
|
||||
ImmutableMap.Builder<String, Object> builder,
|
||||
boolean addNoContactRemark,
|
||||
@Nullable Object otherRemarks) {
|
||||
ImmutableList.Builder<ImmutableMap<String, Object>> remarksBuilder =
|
||||
getBuilderWithOthersAdded(otherRemarks);
|
||||
if (addNoContactRemark) {
|
||||
remarksBuilder.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"));
|
||||
}
|
||||
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")),
|
||||
ImmutableMap.of(
|
||||
+ " Registrars version 1.0")));
|
||||
remarksBuilder.add(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"title",
|
||||
"EPP Status Codes",
|
||||
"description",
|
||||
|
@ -87,8 +165,9 @@ public class RdapTestHelper {
|
|||
"value", "https://icann.org/epp",
|
||||
"rel", "alternate",
|
||||
"href", "https://icann.org/epp",
|
||||
"type", "text/html"))),
|
||||
ImmutableMap.of(
|
||||
"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"),
|
||||
|
@ -98,7 +177,20 @@ public class RdapTestHelper {
|
|||
"value", "https://www.icann.org/wicf",
|
||||
"rel", "alternate",
|
||||
"href", "https://www.icann.org/wicf",
|
||||
"type", "text/html")))));
|
||||
"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() {
|
||||
|
|
25
javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json
vendored
Normal file
25
javatests/google/registry/rdap/testdata/rdap_associated_contact_no_personal_data.json
vendored
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
34
javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json
vendored
Normal file
34
javatests/google/registry/rdap/testdata/rdap_contact_no_personal_data_with_remark.json
vendored
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
106
javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json
vendored
Normal file
106
javatests/google/registry/rdap/testdata/rdap_domain_no_contacts.json
vendored
Normal 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"
|
||||
}
|
115
javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json
vendored
Normal file
115
javatests/google/registry/rdap/testdata/rdap_domain_no_contacts_with_remark.json
vendored
Normal 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"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue