RDAP: Display truncation notice for large domain result sets

The ICAAN Operational Profile dictates that a notice be added to the RDAP search results response when there are more objects than the server's chosen result set size. This CL handles the fixes for domain searches.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135407203
This commit is contained in:
mountford 2016-10-06 14:43:46 -07:00 committed by Ben McIlwain
parent 5a4926323e
commit 179bd22531
6 changed files with 729 additions and 83 deletions

View file

@ -552,6 +552,31 @@ public class RdapDomainSearchActionTest {
persistResources(domainsBuilder.build());
}
private Object readMultiDomainFile(
String fileName,
String domainName1,
String domainHandle1,
String domainName2,
String domainHandle2,
String domainName3,
String domainHandle3,
String domainName4,
String domainHandle4) {
return JSONValue.parse(loadFileWithSubstitutions(
this.getClass(),
fileName,
new ImmutableMap.Builder<String, String>()
.put("DOMAINNAME1", domainName1)
.put("DOMAINHANDLE1", domainHandle1)
.put("DOMAINNAME2", domainName2)
.put("DOMAINHANDLE2", domainHandle2)
.put("DOMAINNAME3", domainName3)
.put("DOMAINHANDLE3", domainHandle3)
.put("DOMAINNAME4", domainName4)
.put("DOMAINHANDLE4", domainHandle4)
.build()));
}
private void checkNumberOfDomainsInResult(Object obj, int expected) {
assertThat(obj).isInstanceOf(Map.class);
@ -577,7 +602,7 @@ public class RdapDomainSearchActionTest {
public void testDomainMatch_manyDeletedDomains_partialResultSetDueToInsufficientDomains()
throws Exception {
// There are not enough domains to fill a full result set.
createManyDomainsAndHosts(3, 100, 2);
createManyDomainsAndHosts(3, 20, 2);
Object obj = generateActualJson(RequestType.NAME, "domain*.lol");
assertThat(response.getStatus()).isEqualTo(200);
checkNumberOfDomainsInResult(obj, 3);
@ -589,12 +614,82 @@ public class RdapDomainSearchActionTest {
// This is not exactly desired behavior, but expected: There are enough domains to fill a full
// result set, but there are so many deleted domains that we run out of patience before we work
// our way through all of them.
createManyDomainsAndHosts(4, 150, 2);
createManyDomainsAndHosts(4, 50, 2);
Object obj = generateActualJson(RequestType.NAME, "domain*.lol");
assertThat(response.getStatus()).isEqualTo(200);
checkNumberOfDomainsInResult(obj, 3);
}
@Test
public void testDomainMatch_nontruncatedResultsSet() throws Exception {
createManyDomainsAndHosts(4, 1, 2);
assertThat(generateActualJson(RequestType.NAME, "domain*.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_nontruncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testDomainMatch_truncatedResultsSet() throws Exception {
createManyDomainsAndHosts(5, 1, 2);
assertThat(generateActualJson(RequestType.NAME, "domain*.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testDomainMatch_reallyTruncatedResultsSet() throws Exception {
// Don't use 10 or more domains for this test, because domain10.lol will come before
// domain2.lol, and you'll get the wrong domains in the result set.
createManyDomainsAndHosts(9, 1, 2);
assertThat(generateActualJson(RequestType.NAME, "domain*.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testDomainMatch_truncatedResultsAfterMultipleChunks() throws Exception {
createManyDomainsAndHosts(5, 6, 2);
assertThat(generateActualJson(RequestType.NAME, "domain*.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain12.lol",
"4C-LOL",
"domain18.lol",
"52-LOL",
"domain24.lol",
"58-LOL",
"domain30.lol",
"5E-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testNameserverMatch_foundMultiple() throws Exception {
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1.cat.lol"))
@ -766,6 +861,77 @@ public class RdapDomainSearchActionTest {
checkNumberOfDomainsInResult(obj, 3);
}
@Test
public void testNameserverMatch_nontruncatedResultsSet() throws Exception {
createManyDomainsAndHosts(4, 1, 2);
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1.domain1.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_nontruncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testNameserverMatch_truncatedResultsSet() throws Exception {
createManyDomainsAndHosts(5, 1, 2);
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1.domain1.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testNameserverMatch_reallyTruncatedResultsSet() throws Exception {
createManyDomainsAndHosts(9, 1, 2);
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns1.domain1.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testNameserverMatch_duplicatesNotTruncated() throws Exception {
// 60 nameservers for each of 4 domains; these should translate into 2 30-nameserver domain
// fetches, which should _not_ trigger the truncation warning because all the domains will be
// duplicates.
createManyDomainsAndHosts(4, 1, 60);
assertThat(generateActualJson(RequestType.NS_LDH_NAME, "ns*.domain1.lol"))
.isEqualTo(readMultiDomainFile(
"rdap_nontruncated_domains.json",
"domain1.lol",
"B5-LOL",
"domain2.lol",
"B6-LOL",
"domain3.lol",
"B7-LOL",
"domain4.lol",
"B8-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testAddressMatchV4Address_foundMultiple() throws Exception {
assertThat(generateActualJson(RequestType.NS_IP, "1.2.3.4"))
@ -821,4 +987,55 @@ public class RdapDomainSearchActionTest {
.isEqualTo(generateExpectedJson("No domains found", null, null, "rdap_error_404.json"));
assertThat(response.getStatus()).isEqualTo(404);
}
@Test
public void testAddressMatch_nontruncatedResultsSet() throws Exception {
createManyDomainsAndHosts(4, 1, 2);
assertThat(generateActualJson(RequestType.NS_IP, "5.5.5.1"))
.isEqualTo(readMultiDomainFile(
"rdap_nontruncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testAddressMatch_truncatedResultsSet() throws Exception {
createManyDomainsAndHosts(5, 1, 2);
assertThat(generateActualJson(RequestType.NS_IP, "5.5.5.1"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
@Test
public void testAddressMatch_reallyTruncatedResultsSet() throws Exception {
createManyDomainsAndHosts(9, 1, 2);
assertThat(generateActualJson(RequestType.NS_IP, "5.5.5.1"))
.isEqualTo(readMultiDomainFile(
"rdap_truncated_domains.json",
"domain1.lol",
"41-LOL",
"domain2.lol",
"42-LOL",
"domain3.lol",
"43-LOL",
"domain4.lol",
"44-LOL"));
assertThat(response.getStatus()).isEqualTo(200);
}
}

View file

@ -0,0 +1,187 @@
{
"domainSearchResults": [
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE1%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME1%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME1%"
}
],
"ldhName": "%DOMAINNAME1%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE2%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME2%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME2%"
}
],
"ldhName": "%DOMAINNAME2%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE3%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME3%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME3%"
}
],
"ldhName": "%DOMAINNAME3%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE4%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME4%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME4%"
}
],
"ldhName": "%DOMAINNAME4%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
}
],
"rdapConformance": [
"rdap_level_0"
],
"notices" :
[
{
"title" : "RDAP Terms of Service",
"description" :
[
"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.",
"Please do not misuse the Domain Database. It is intended solely for query-based access.",
"Don't use the Domain Database to allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations.",
"Don't access our Domain Database through the use of high volume, automated electronic processes that send queries or data to the systems of Charleston Road Registry or any ICANN-accredited registrar.",
"You may only use the information contained in the Domain Database for lawful purposes.",
"Do not compile, repackage, disseminate, or otherwise use the information contained in the Domain Database in its entirety, or in any substantial portion, without our prior written permission.",
"We may retain certain details about queries to our Domain Database for the purposes of detecting and preventing misuse.",
"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" :
[
{
"value" : "https://example.com/rdap/help/tos",
"rel" : "alternate",
"href" : "https://www.registry.google/about/rdap/tos.html",
"type" : "text/html"
}
]
}
],
"remarks" :
[
{
"description" :
[
"This response conforms to the RDAP Operational Profile for gTLD Registries and Registrars version 1.0"
]
},
{
"title" : "EPP Status Codes",
"description" :
[
"For more information on domain status codes, please visit https://icann.org/epp"
],
"links" :
[
{
"value" : "https://icann.org/epp",
"rel" : "alternate",
"href" : "https://icann.org/epp",
"type" : "text/html"
}
]
},
{
"description" :
[
"URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf"
],
"links" :
[
{
"value" : "https://www.icann.org/wicf",
"rel" : "alternate",
"href" : "https://www.icann.org/wicf",
"type" : "text/html"
}
]
}
]
}

View file

@ -0,0 +1,195 @@
{
"domainSearchResults": [
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE1%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME1%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME1%"
}
],
"ldhName": "%DOMAINNAME1%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE2%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME2%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME2%"
}
],
"ldhName": "%DOMAINNAME2%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE3%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME3%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME3%"
}
],
"ldhName": "%DOMAINNAME3%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
},
{
"status": [
"client delete prohibited",
"client renew prohibited",
"client transfer prohibited",
"server update prohibited"
],
"handle": "%DOMAINHANDLE4%",
"links": [
{
"href": "https://example.com/rdap/domain/%DOMAINNAME4%",
"type": "application/rdap+json",
"rel": "self",
"value": "https://example.com/rdap/domain/%DOMAINNAME4%"
}
],
"ldhName": "%DOMAINNAME4%",
"objectClassName": "domain",
"remarks": [
{
"title": "Incomplete Data",
"description": [
"Summary data only. For complete data, send a specific query for the object."
],
"type": "object truncated due to unexplainable reasons"
}
]
}
],
"rdapConformance": [
"rdap_level_0"
],
"notices" :
[
{
"title" : "Search Policy",
"type" : "result set truncated due to unexplainable reasons",
"description" :
[
"Search results per query are limited."
]
},
{
"title" : "RDAP Terms of Service",
"description" :
[
"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.",
"Please do not misuse the Domain Database. It is intended solely for query-based access.",
"Don't use the Domain Database to allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations.",
"Don't access our Domain Database through the use of high volume, automated electronic processes that send queries or data to the systems of Charleston Road Registry or any ICANN-accredited registrar.",
"You may only use the information contained in the Domain Database for lawful purposes.",
"Do not compile, repackage, disseminate, or otherwise use the information contained in the Domain Database in its entirety, or in any substantial portion, without our prior written permission.",
"We may retain certain details about queries to our Domain Database for the purposes of detecting and preventing misuse.",
"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" :
[
{
"value" : "https://example.com/rdap/help/tos",
"rel" : "alternate",
"href" : "https://www.registry.google/about/rdap/tos.html",
"type" : "text/html"
}
]
}
],
"remarks" :
[
{
"description" :
[
"This response conforms to the RDAP Operational Profile for gTLD Registries and Registrars version 1.0"
]
},
{
"title" : "EPP Status Codes",
"description" :
[
"For more information on domain status codes, please visit https://icann.org/epp"
],
"links" :
[
{
"value" : "https://icann.org/epp",
"rel" : "alternate",
"href" : "https://icann.org/epp",
"type" : "text/html"
}
]
},
{
"description" :
[
"URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf"
],
"links" :
[
{
"value" : "https://www.icann.org/wicf",
"rel" : "alternate",
"href" : "https://www.icann.org/wicf",
"type" : "text/html"
}
]
}
]
}