From 247339cfd525f3f1ab6fc39af33825e35bae6b53 Mon Sep 17 00:00:00 2001 From: mountford Date: Mon, 26 Feb 2018 11:08:59 -0800 Subject: [PATCH] RDAP: Show registrar entity even if contacts are redacted Even when the request is not permissioned to see contact information, we should show information about the owning registrar. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187049833 --- .../registry/rdap/RdapJsonFormatter.java | 29 ++--- .../rdap/RdapDomainSearchActionTest.java | 16 +-- .../testdata/rdap_domain_no_contacts.json | 96 +++++++++++++++- .../rdap_domain_no_contacts_with_remark.json | 96 +++++++++++++++- ...omain_unicode_no_contacts_with_remark.json | 98 +++++++++++++++- .../testdata/rdapjson_domain_logged_out.json | 108 ++++++++++++++++++ 6 files changed, 412 insertions(+), 31 deletions(-) diff --git a/java/google/registry/rdap/RdapJsonFormatter.java b/java/google/registry/rdap/RdapJsonFormatter.java index 7eec9ca60..fab91dc21 100644 --- a/java/google/registry/rdap/RdapJsonFormatter.java +++ b/java/google/registry/rdap/RdapJsonFormatter.java @@ -522,10 +522,13 @@ public class RdapJsonFormatter { Map, HostResource> loadedHosts = ofy().load().keys(domainResource.getNameservers()); // Load the registrant and other contacts and add them to the data. - if (displayContacts) { + ImmutableList> entities; + if (!displayContacts) { + entities = ImmutableList.of(); + } else { Map, ContactResource> loadedContacts = ofy().load().keys(domainResource.getReferencedContacts()); - ImmutableList> entities = + entities = Streams.concat( domainResource.getContacts().stream(), Stream.of( @@ -543,17 +546,17 @@ public class RdapJsonFormatter { outputDataType, authorization)) .collect(toImmutableList()); - entities = - addRegistrarEntity( - entities, - domainResource.getCurrentSponsorClientId(), - linkBase, - whoisServer, - now, - outputDataType); - if (!entities.isEmpty()) { - jsonBuilder.put("entities", entities); - } + } + entities = + addRegistrarEntity( + entities, + domainResource.getCurrentSponsorClientId(), + linkBase, + whoisServer, + now, + outputDataType); + if (!entities.isEmpty()) { + jsonBuilder.put("entities", entities); } // Add the nameservers to the data; the load was kicked off above for efficiency. ImmutableList.Builder nsBuilder = new ImmutableList.Builder<>(); diff --git a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java index 12a5c901b..f7290252d 100644 --- a/javatests/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/javatests/google/registry/rdap/RdapDomainSearchActionTest.java @@ -1022,7 +1022,7 @@ public class RdapDomainSearchActionTest extends RdapSearchActionTestCase { "21-EXAMPLE", null, ImmutableList.of("ns1.cat.lol", "ns2.external.tld"), - "Yes Virginia