From 4657b8ab514bca96c4aa0f71edf62b6b3ff78cb8 Mon Sep 17 00:00:00 2001 From: larryruili Date: Thu, 26 Apr 2018 08:09:15 -0700 Subject: [PATCH] Replace 'referralUrl' with 'url' in WHOIS responses The 'referralUrl' Datastore field is filled with mostly junk data, whereas 'url' contains real registrar web addresses. This makes the long needed fix to display the proper url in WHOIS. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=194398003 --- java/google/registry/whois/DomainWhoisResponse.java | 2 +- java/google/registry/whois/NameserverWhoisResponse.java | 2 +- java/google/registry/whois/RegistrarWhoisResponse.java | 2 +- .../google/registry/testing/FullFieldsTestEntityHelper.java | 1 + .../google/registry/whois/DomainWhoisResponseTest.java | 6 +++++- .../google/registry/whois/NameserverWhoisResponseTest.java | 3 +++ .../google/registry/whois/RegistrarWhoisResponseTest.java | 1 + javatests/google/registry/whois/WhoisActionTest.java | 3 +++ javatests/google/registry/whois/WhoisHttpActionTest.java | 2 ++ .../google/registry/whois/testdata/whois_action_domain.txt | 2 +- .../registry/whois/testdata/whois_action_idn_punycode.txt | 2 +- .../registry/whois/testdata/whois_action_idn_utf8.txt | 2 +- .../registry/whois/testdata/whois_action_nameserver.txt | 2 +- .../registry/whois/testdata/whois_action_registrar.txt | 2 +- javatests/google/registry/whois/testdata/whois_domain.txt | 2 +- .../registry/whois/testdata/whois_multiple_nameservers.txt | 4 ++-- .../google/registry/whois/testdata/whois_nameserver.txt | 2 +- .../google/registry/whois/testdata/whois_registrar.txt | 2 +- 18 files changed, 28 insertions(+), 14 deletions(-) diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index 5c5effdde..52bf284f6 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -82,7 +82,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl { maybeFormatHostname(domain.getFullyQualifiedDomainName(), preferUnicode)) .emitField("Registry Domain ID", domain.getRepoId()) .emitField("Registrar WHOIS Server", registrar.getWhoisServer()) - .emitField("Registrar URL", registrar.getReferralUrl()) + .emitField("Registrar URL", registrar.getUrl()) .emitFieldIfDefined("Updated Date", getFormattedString(domain.getLastEppUpdateTime())) .emitField("Creation Date", getFormattedString(domain.getCreationTime())) .emitField( diff --git a/java/google/registry/whois/NameserverWhoisResponse.java b/java/google/registry/whois/NameserverWhoisResponse.java index d17a81e96..3c84d9e65 100644 --- a/java/google/registry/whois/NameserverWhoisResponse.java +++ b/java/google/registry/whois/NameserverWhoisResponse.java @@ -61,7 +61,7 @@ final class NameserverWhoisResponse extends WhoisResponseImpl { .emitSet("IP Address", host.getInetAddresses(), InetAddresses::toAddrString) .emitField("Registrar", registrar.get().getRegistrarName()) .emitField("Registrar WHOIS Server", registrar.get().getWhoisServer()) - .emitField("Registrar URL", registrar.get().getReferralUrl()); + .emitField("Registrar URL", registrar.get().getUrl()); if (i < hosts.size() - 1) { emitter.emitNewline(); } diff --git a/java/google/registry/whois/RegistrarWhoisResponse.java b/java/google/registry/whois/RegistrarWhoisResponse.java index 4191ba84c..4ad52b191 100644 --- a/java/google/registry/whois/RegistrarWhoisResponse.java +++ b/java/google/registry/whois/RegistrarWhoisResponse.java @@ -57,7 +57,7 @@ class RegistrarWhoisResponse extends WhoisResponseImpl { .emitPhonesAndEmail( registrar.getPhoneNumber(), registrar.getFaxNumber(), registrar.getEmailAddress()) .emitField("Registrar WHOIS Server", registrar.getWhoisServer()) - .emitField("Registrar URL", registrar.getReferralUrl()) + .emitField("Registrar URL", registrar.getUrl()) .emitRegistrarContacts("Admin", contacts, AdminOrTech.ADMIN) .emitRegistrarContacts("Technical", contacts, AdminOrTech.TECH) .emitLastUpdated(getTimestamp()) diff --git a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java index 087f8b780..3689c637d 100644 --- a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java @@ -81,6 +81,7 @@ public final class FullFieldsTestEntityHelper { .setEmailAddress("contact-us@example.com") .setWhoisServer("whois.example.com") .setReferralUrl("http://www.example.com") + .setUrl("http://my.fake.url") .build(); } diff --git a/javatests/google/registry/whois/DomainWhoisResponseTest.java b/javatests/google/registry/whois/DomainWhoisResponseTest.java index fa6bf0bcc..2f476a917 100644 --- a/javatests/google/registry/whois/DomainWhoisResponseTest.java +++ b/javatests/google/registry/whois/DomainWhoisResponseTest.java @@ -70,7 +70,11 @@ public class DomainWhoisResponseTest { // Update the registrar to have an IANA ID. Registrar registrar = persistResource( - loadRegistrar("NewRegistrar").asBuilder().setIanaIdentifier(5555555L).build()); + loadRegistrar("NewRegistrar") + .asBuilder() + .setUrl("http://my.fake.url") + .setIanaIdentifier(5555555L) + .build()); persistResource( new RegistrarContact.Builder() diff --git a/javatests/google/registry/whois/NameserverWhoisResponseTest.java b/javatests/google/registry/whois/NameserverWhoisResponseTest.java index 2e0020c2b..3189ba3bc 100644 --- a/javatests/google/registry/whois/NameserverWhoisResponseTest.java +++ b/javatests/google/registry/whois/NameserverWhoisResponseTest.java @@ -16,7 +16,9 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; +import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistNewRegistrar; +import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.whois.WhoisTestData.loadFile; import com.google.common.collect.ImmutableList; @@ -51,6 +53,7 @@ public class NameserverWhoisResponseTest { @Before public void setUp() { persistNewRegistrar("example", "Example Registrar, Inc.", Registrar.Type.REAL, 8L); + persistResource(loadRegistrar("example").asBuilder().setUrl("http://my.fake.url").build()); createTld("tld"); hostResource1 = new HostResource.Builder() diff --git a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java index a1e6e3b9a..3f1811e51 100644 --- a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java +++ b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java @@ -63,6 +63,7 @@ public class RegistrarWhoisResponseTest { .setEmailAddress("registrar@example.tld") .setWhoisServer("whois.example-registrar.tld") .setReferralUrl("http://www.example-registrar.tld") + .setUrl("http://my.fake.url") .build(); // Use the registrar key for contacts' parent. ImmutableList contacts = ImmutableList.of( diff --git a/javatests/google/registry/whois/WhoisActionTest.java b/javatests/google/registry/whois/WhoisActionTest.java index 81a2fbfd5..e408b0bb9 100644 --- a/javatests/google/registry/whois/WhoisActionTest.java +++ b/javatests/google/registry/whois/WhoisActionTest.java @@ -20,6 +20,7 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE; import static google.registry.model.registrar.Registrar.Type.PDT; import static google.registry.model.registry.Registries.getTlds; import static google.registry.testing.DatastoreHelper.createTlds; +import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; @@ -304,6 +305,7 @@ public class WhoisActionTest { @Test public void testRun_nameserverQuery_works() throws Exception { + persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); @@ -568,6 +570,7 @@ public class WhoisActionTest { @Test public void testRun_retryOnTransientFailure() throws Exception { + persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); WhoisAction action = newWhoisAction("ns1.cat.lol"); WhoisResponse expectedResponse = diff --git a/javatests/google/registry/whois/WhoisHttpActionTest.java b/javatests/google/registry/whois/WhoisHttpActionTest.java index 8fd3911b6..950716331 100644 --- a/javatests/google/registry/whois/WhoisHttpActionTest.java +++ b/javatests/google/registry/whois/WhoisHttpActionTest.java @@ -17,6 +17,7 @@ package google.registry.whois; import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTlds; +import static google.registry.testing.DatastoreHelper.loadRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; @@ -239,6 +240,7 @@ public class WhoisHttpActionTest { @Test public void testRun_nameserverQuery_works() throws Exception { + persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.lol").run(); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt")); diff --git a/javatests/google/registry/whois/testdata/whois_action_domain.txt b/javatests/google/registry/whois/testdata/whois_action_domain.txt index 3fee4d008..a7822cd7e 100644 --- a/javatests/google/registry/whois/testdata/whois_action_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_action_domain.txt @@ -1,7 +1,7 @@ Domain Name: cat.lol Registry Domain ID: 9-LOL Registrar WHOIS Server: whois.example.com -Registrar URL: http://www.example.com +Registrar URL: http://my.fake.url Updated Date: 2009-05-29T20:13:00Z Creation Date: 2000-10-08T00:45:00Z Registry Expiry Date: 2110-10-08T00:44:59Z diff --git a/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt b/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt index 9af150e05..aa7f1b565 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_punycode.txt @@ -1,7 +1,7 @@ Domain Name: cat.xn--q9jyb4c Registry Domain ID: 9-Q9JYB4C Registrar WHOIS Server: whois.example.com -Registrar URL: http://www.example.com +Registrar URL: http://my.fake.url Updated Date: 2009-05-29T20:13:00Z Creation Date: 2000-10-08T00:45:00Z Registry Expiry Date: 2110-10-08T00:44:59Z diff --git a/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt b/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt index ba424d476..747234230 100644 --- a/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt +++ b/javatests/google/registry/whois/testdata/whois_action_idn_utf8.txt @@ -1,7 +1,7 @@ Domain Name: cat.みんな Registry Domain ID: 9-Q9JYB4C Registrar WHOIS Server: whois.example.com -Registrar URL: http://www.example.com +Registrar URL: http://my.fake.url Updated Date: 2009-05-29T20:13:00Z Creation Date: 2000-10-08T00:45:00Z Registry Expiry Date: 2110-10-08T00:44:59Z diff --git a/javatests/google/registry/whois/testdata/whois_action_nameserver.txt b/javatests/google/registry/whois/testdata/whois_action_nameserver.txt index dad7e7284..82510bdcc 100644 --- a/javatests/google/registry/whois/testdata/whois_action_nameserver.txt +++ b/javatests/google/registry/whois/testdata/whois_action_nameserver.txt @@ -2,7 +2,7 @@ Server Name: ns1.cat.lol IP Address: 1.2.3.4 Registrar: The Registrar Registrar WHOIS Server: whois.nic.fakewhois.example -Registrar URL: http://www.referral.example/path +Registrar URL: http://my.fake.url >>> Last update of WHOIS database: 2009-06-29T20:13:00Z <<< Doodle Disclaimer diff --git a/javatests/google/registry/whois/testdata/whois_action_registrar.txt b/javatests/google/registry/whois/testdata/whois_action_registrar.txt index e3a847cef..0c2508a2d 100644 --- a/javatests/google/registry/whois/testdata/whois_action_registrar.txt +++ b/javatests/google/registry/whois/testdata/whois_action_registrar.txt @@ -8,7 +8,7 @@ Phone Number: +1.2125551212 Fax Number: +1.2125551213 Email: contact-us@example.com Registrar WHOIS Server: whois.example.com -Registrar URL: http://www.example.com +Registrar URL: http://my.fake.url Admin Contact: Jane Doe Phone Number: +1.2125551215 Fax Number: +1.2125551216 diff --git a/javatests/google/registry/whois/testdata/whois_domain.txt b/javatests/google/registry/whois/testdata/whois_domain.txt index 3fc1de59e..f21e425f8 100644 --- a/javatests/google/registry/whois/testdata/whois_domain.txt +++ b/javatests/google/registry/whois/testdata/whois_domain.txt @@ -1,7 +1,7 @@ Domain Name: example.tld Registry Domain ID: 3-TLD Registrar WHOIS Server: whois.nic.fakewhois.example -Registrar URL: http://www.referral.example/path +Registrar URL: http://my.fake.url Updated Date: 2009-05-29T20:13:00Z Creation Date: 2000-10-08T00:45:00Z Registry Expiry Date: 2010-10-08T00:44:59Z diff --git a/javatests/google/registry/whois/testdata/whois_multiple_nameservers.txt b/javatests/google/registry/whois/testdata/whois_multiple_nameservers.txt index 4357228d8..8cf2bed28 100644 --- a/javatests/google/registry/whois/testdata/whois_multiple_nameservers.txt +++ b/javatests/google/registry/whois/testdata/whois_multiple_nameservers.txt @@ -3,14 +3,14 @@ IP Address: 192.0.2.123 IP Address: 2001:db8::1 Registrar: Example Registrar, Inc. Registrar WHOIS Server: whois.nic.fakewhois.example -Registrar URL: http://www.referral.example/path +Registrar URL: http://my.fake.url Server Name: ns2.example.tld IP Address: 192.0.2.123 IP Address: 2001:db8::1 Registrar: Example Registrar, Inc. Registrar WHOIS Server: whois.nic.fakewhois.example -Registrar URL: http://www.referral.example/path +Registrar URL: http://my.fake.url >>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<< Doodle Disclaimer diff --git a/javatests/google/registry/whois/testdata/whois_nameserver.txt b/javatests/google/registry/whois/testdata/whois_nameserver.txt index 2fc974325..67da48705 100644 --- a/javatests/google/registry/whois/testdata/whois_nameserver.txt +++ b/javatests/google/registry/whois/testdata/whois_nameserver.txt @@ -3,7 +3,7 @@ IP Address: 192.0.2.123 IP Address: 2001:db8::1 Registrar: Example Registrar, Inc. Registrar WHOIS Server: whois.nic.fakewhois.example -Registrar URL: http://www.referral.example/path +Registrar URL: http://my.fake.url >>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<< Doodle Disclaimer diff --git a/javatests/google/registry/whois/testdata/whois_registrar.txt b/javatests/google/registry/whois/testdata/whois_registrar.txt index 6536e8b18..d7f2ee3fb 100644 --- a/javatests/google/registry/whois/testdata/whois_registrar.txt +++ b/javatests/google/registry/whois/testdata/whois_registrar.txt @@ -8,7 +8,7 @@ Phone Number: +1.3105551212 Fax Number: +1.3105551213 Email: registrar@example.tld Registrar WHOIS Server: whois.example-registrar.tld -Registrar URL: http://www.example-registrar.tld +Registrar URL: http://my.fake.url Admin Contact: Jane Registrar Phone Number: +1.3105551214 Fax Number: +1.3105551213