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
This commit is contained in:
larryruili 2018-04-26 08:09:15 -07:00 committed by jianglai
parent d618ae758b
commit 4657b8ab51
18 changed files with 28 additions and 14 deletions

View file

@ -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(

View file

@ -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();
}

View file

@ -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())

View file

@ -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();
}

View file

@ -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()

View file

@ -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()

View file

@ -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<RegistrarContact> contacts = ImmutableList.of(

View file

@ -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 =

View file

@ -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"));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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