From 5bc70cbc99e5d4bd340addd5034be10d8727b11d Mon Sep 17 00:00:00 2001 From: shicong Date: Mon, 10 Dec 2018 10:00:30 -0800 Subject: [PATCH] Update lastEppUpdateTime after certain grace period is passed The lastEppUpdateTime should be updated asynchronously in the situations below: - Implicit transfer success after 5 day pending transfer period - Implicit end of any grace period ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=224831791 --- .../registry/model/domain/DomainResource.java | 33 ++- .../flows/EppLifecycleDomainTest.java | 3 +- .../flows/domain/DomainDeleteFlowTest.java | 24 +++ .../domain/DomainTransferRequestFlowTest.java | 6 +- ...site_3_nameservers_transfer_successful.xml | 2 +- ..._response_fakesite_ok_post_host_update.xml | 2 + ...se_fakesite_pending_transfer_autorenew.xml | 4 +- ...fo_response_fakesite_transfer_complete.xml | 2 +- ...info_response_fakesite_transfer_period.xml | 2 +- ...nfo_response_wildcard_after_redemption.xml | 38 ++++ .../model/domain/DomainResourceTest.java | 190 +++++++++++++----- ...pReduce_withDomain_producesExpectedXml.xml | 4 +- .../registry/whois/WhoisActionTest.java | 62 ++++-- .../whois_action_transferred_domain.txt | 59 ++++++ 14 files changed, 347 insertions(+), 84 deletions(-) create mode 100644 javatests/google/registry/flows/testdata/domain_info_response_wildcard_after_redemption.xml create mode 100644 javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt diff --git a/java/google/registry/model/domain/DomainResource.java b/java/google/registry/model/domain/DomainResource.java index aee074696..510d75a76 100644 --- a/java/google/registry/model/domain/DomainResource.java +++ b/java/google/registry/model/domain/DomainResource.java @@ -281,10 +281,15 @@ public class DomainResource extends DomainBase } // Set all remaining transfer properties. setAutomaticTransferSuccessProperties(builder, transferData); + builder + .setLastEppUpdateTime(transferExpirationTime) + .setLastEppUpdateClientId(transferData.getGainingClientId()); // Finish projecting to now. return builder.build().cloneProjectedAtTime(now); } + Optional newLastEppUpdateTime = Optional.empty(); + // There is no transfer. Do any necessary autorenews. Builder builder = asBuilder(); @@ -296,11 +301,13 @@ public class DomainResource extends DomainBase DateTime newExpirationTime = lastAutorenewTime.plusYears(1); builder .setRegistrationExpirationTime(newExpirationTime) - .addGracePeriod(GracePeriod.createForRecurring( - GracePeriodStatus.AUTO_RENEW, - lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()), - getCurrentSponsorClientId(), - autorenewBillingEvent)); + .addGracePeriod( + GracePeriod.createForRecurring( + GracePeriodStatus.AUTO_RENEW, + lastAutorenewTime.plus(Registry.get(getTld()).getAutoRenewGracePeriodLength()), + getCurrentSponsorClientId(), + autorenewBillingEvent)); + newLastEppUpdateTime = Optional.of(lastAutorenewTime); } // Remove any grace periods that have expired. @@ -309,6 +316,22 @@ public class DomainResource extends DomainBase for (GracePeriod gracePeriod : almostBuilt.getGracePeriods()) { if (isBeforeOrAt(gracePeriod.getExpirationTime(), now)) { builder.removeGracePeriod(gracePeriod); + if (!newLastEppUpdateTime.isPresent() + || isBeforeOrAt(newLastEppUpdateTime.get(), gracePeriod.getExpirationTime())) { + newLastEppUpdateTime = Optional.of(gracePeriod.getExpirationTime()); + } + } + } + + // It is possible that the lastEppUpdateClientId is different from current sponsor client + // id, so we have to do the comparison instead of having one variable just storing the most + // recent time. + if (newLastEppUpdateTime.isPresent()) { + if (getLastEppUpdateTime() == null + || newLastEppUpdateTime.get().isAfter(getLastEppUpdateTime())) { + builder + .setLastEppUpdateTime(newLastEppUpdateTime.get()) + .setLastEppUpdateClientId(getCurrentSponsorClientId()); } } diff --git a/javatests/google/registry/flows/EppLifecycleDomainTest.java b/javatests/google/registry/flows/EppLifecycleDomainTest.java index a47d1c97a..f553e35fd 100644 --- a/javatests/google/registry/flows/EppLifecycleDomainTest.java +++ b/javatests/google/registry/flows/EppLifecycleDomainTest.java @@ -171,7 +171,8 @@ public class EppLifecycleDomainTest extends EppTestCase { assertThatCommand("domain_info.xml", ImmutableMap.of("DOMAIN", "example.tld")) .atTime("2000-08-08T00:00:00Z") .hasResponse( - "domain_info_response_wildcard.xml", ImmutableMap.of("STATUS", "pendingDelete")); + "domain_info_response_wildcard_after_redemption.xml", + ImmutableMap.of("STATUS", "pendingDelete")); // Verify that the domain is non-existent (available for registration) later. assertThatCommand("domain_info.xml", ImmutableMap.of("DOMAIN", "example.tld")) diff --git a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java index 0795c2bd7..2a8b2d9bf 100644 --- a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -327,6 +327,30 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCaseNewRegistrar 2000-06-01T00:04:00Z TheRegistrar - 2002-05-30T00:00:00Z + 2002-06-09T00:00:00Z 2003-06-01T00:04:00Z 2002-06-04T00:00:00Z diff --git a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_ok_post_host_update.xml b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_ok_post_host_update.xml index 37df3cbc9..afe667d21 100644 --- a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_ok_post_host_update.xml +++ b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_ok_post_host_update.xml @@ -20,6 +20,8 @@ NewRegistrar NewRegistrar 2000-06-01T00:04:00Z + NewRegistrar + 2000-06-06T00:04:00Z 2002-06-01T00:04:00Z 2fooBAR diff --git a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_pending_transfer_autorenew.xml b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_pending_transfer_autorenew.xml index 4a75fe1ec..b55aef2f5 100644 --- a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_pending_transfer_autorenew.xml +++ b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_pending_transfer_autorenew.xml @@ -19,8 +19,8 @@ NewRegistrar NewRegistrar 2000-06-01T00:04:00Z - TheRegistrar - 2002-05-30T00:00:00Z + NewRegistrar + 2002-06-01T00:04:00.000Z 2003-06-01T00:04:00Z 2fooBAR diff --git a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_complete.xml b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_complete.xml index 31dd15655..7138956dd 100644 --- a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_complete.xml +++ b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_complete.xml @@ -20,7 +20,7 @@ NewRegistrar 2000-06-01T00:04:00Z TheRegistrar - 2002-05-30T00:00:00Z + 2002-06-09T00:00:00Z 2003-06-01T00:04:00Z 2002-06-04T00:00:00Z diff --git a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_period.xml b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_period.xml index 1a9e777e6..2f5263aad 100644 --- a/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_period.xml +++ b/javatests/google/registry/flows/testdata/domain_info_response_fakesite_transfer_period.xml @@ -20,7 +20,7 @@ NewRegistrar 2000-06-01T00:04:00Z TheRegistrar - 2002-05-30T00:00:00Z + 2002-06-04T00:00:00Z 2003-06-01T00:04:00Z 2002-06-04T00:00:00Z diff --git a/javatests/google/registry/flows/testdata/domain_info_response_wildcard_after_redemption.xml b/javatests/google/registry/flows/testdata/domain_info_response_wildcard_after_redemption.xml new file mode 100644 index 000000000..05e30eeb7 --- /dev/null +++ b/javatests/google/registry/flows/testdata/domain_info_response_wildcard_after_redemption.xml @@ -0,0 +1,38 @@ + + + + Command completed successfully + + + + example.tld + %ROID% + + + jd1234 + sh8013 + sh8013 + NewRegistrar + NewRegistrar + 2000-06-01T00:02:00.0Z + NewRegistrar + 2000-08-06T00:02:00Z + 2002-06-01T00:02:00.0Z + + 2fooBAR + + + + + + + + + + ABC-12345 + server-trid + + + diff --git a/javatests/google/registry/model/domain/DomainResourceTest.java b/javatests/google/registry/model/domain/DomainResourceTest.java index 6ea37ea22..d6393c783 100644 --- a/javatests/google/registry/model/domain/DomainResourceTest.java +++ b/javatests/google/registry/model/domain/DomainResourceTest.java @@ -92,55 +92,60 @@ public class DomainResourceTest extends EntityTestCase { Key onetimePollKey = Key.create(historyEntryKey, PollMessage.OneTime.class, 1); // Set up a new persisted domain entity. - domain = persistResource(cloneAndSetAutoTimestamps( - new DomainResource.Builder() - .setFullyQualifiedDomainName("example.com") - .setRepoId("4-COM") - .setCreationClientId("a registrar") - .setLastEppUpdateTime(clock.nowUtc()) - .setLastEppUpdateClientId("AnotherRegistrar") - .setLastTransferTime(clock.nowUtc()) - .setStatusValues(ImmutableSet.of( - StatusValue.CLIENT_DELETE_PROHIBITED, - StatusValue.SERVER_DELETE_PROHIBITED, - StatusValue.SERVER_TRANSFER_PROHIBITED, - StatusValue.SERVER_UPDATE_PROHIBITED, - StatusValue.SERVER_RENEW_PROHIBITED, - StatusValue.SERVER_HOLD)) - .setRegistrant(contact1Key) - .setContacts(ImmutableSet.of(DesignatedContact.create(Type.ADMIN, contact2Key))) - .setNameservers(ImmutableSet.of(hostKey)) - .setSubordinateHosts(ImmutableSet.of("ns1.example.com")) - .setPersistedCurrentSponsorClientId("ThirdRegistrar") - .setRegistrationExpirationTime(clock.nowUtc().plusYears(1)) - .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password"))) - .setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2}))) - .setLaunchNotice( - LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME)) - .setTransferData( - new TransferData.Builder() - .setGainingClientId("gaining") - .setLosingClientId("losing") - .setPendingTransferExpirationTime(clock.nowUtc()) - .setServerApproveEntities( - ImmutableSet.of(oneTimeBillKey, recurringBillKey, autorenewPollKey)) - .setServerApproveBillingEvent(oneTimeBillKey) - .setServerApproveAutorenewEvent(recurringBillKey) - .setServerApproveAutorenewPollMessage(autorenewPollKey) - .setTransferRequestTime(clock.nowUtc().plusDays(1)) - .setTransferStatus(TransferStatus.SERVER_APPROVED) - .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) - .setTransferredRegistrationExpirationTime(clock.nowUtc().plusYears(2)) - .build()) - .setDeletePollMessage(onetimePollKey) - .setAutorenewBillingEvent(recurringBillKey) - .setAutorenewPollMessage(autorenewPollKey) - .setSmdId("smdid") - .setApplicationTime(START_OF_TIME) - .setApplication(Key.create(DomainApplication.class, 1)) - .addGracePeriod(GracePeriod.create( - GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null)) - .build())); + domain = + persistResource( + cloneAndSetAutoTimestamps( + new DomainResource.Builder() + .setFullyQualifiedDomainName("example.com") + .setRepoId("4-COM") + .setCreationClientId("a registrar") + .setLastEppUpdateTime(clock.nowUtc()) + .setLastEppUpdateClientId("AnotherRegistrar") + .setLastTransferTime(clock.nowUtc()) + .setStatusValues( + ImmutableSet.of( + StatusValue.CLIENT_DELETE_PROHIBITED, + StatusValue.SERVER_DELETE_PROHIBITED, + StatusValue.SERVER_TRANSFER_PROHIBITED, + StatusValue.SERVER_UPDATE_PROHIBITED, + StatusValue.SERVER_RENEW_PROHIBITED, + StatusValue.SERVER_HOLD)) + .setRegistrant(contact1Key) + .setContacts(ImmutableSet.of(DesignatedContact.create(Type.ADMIN, contact2Key))) + .setNameservers(ImmutableSet.of(hostKey)) + .setSubordinateHosts(ImmutableSet.of("ns1.example.com")) + .setPersistedCurrentSponsorClientId("losing") + .setRegistrationExpirationTime(clock.nowUtc().plusYears(1)) + .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password"))) + .setDsData( + ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2}))) + .setLaunchNotice( + LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME)) + .setTransferData( + new TransferData.Builder() + .setGainingClientId("gaining") + .setLosingClientId("losing") + .setPendingTransferExpirationTime(clock.nowUtc()) + .setServerApproveEntities( + ImmutableSet.of(oneTimeBillKey, recurringBillKey, autorenewPollKey)) + .setServerApproveBillingEvent(oneTimeBillKey) + .setServerApproveAutorenewEvent(recurringBillKey) + .setServerApproveAutorenewPollMessage(autorenewPollKey) + .setTransferRequestTime(clock.nowUtc().plusDays(1)) + .setTransferStatus(TransferStatus.SERVER_APPROVED) + .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) + .setTransferredRegistrationExpirationTime(clock.nowUtc().plusYears(2)) + .build()) + .setDeletePollMessage(onetimePollKey) + .setAutorenewBillingEvent(recurringBillKey) + .setAutorenewPollMessage(autorenewPollKey) + .setSmdId("smdid") + .setApplicationTime(START_OF_TIME) + .setApplication(Key.create(DomainApplication.class, 1)) + .addGracePeriod( + GracePeriod.create( + GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null)) + .build())); } @Test @@ -344,6 +349,89 @@ public class DomainResourceTest extends EntityTestCase { doExpiredTransferTest(clock.nowUtc().minusDays(1)); } + private void setupPendingTransferDomain( + DateTime oldExpirationTime, DateTime transferRequestTime, DateTime transferSuccessTime) { + domain = + domain + .asBuilder() + .setRegistrationExpirationTime(oldExpirationTime) + .setTransferData( + domain + .getTransferData() + .asBuilder() + .setTransferStatus(TransferStatus.PENDING) + .setTransferRequestTime(transferRequestTime) + .setPendingTransferExpirationTime(transferSuccessTime) + .build()) + .setLastEppUpdateTime(transferRequestTime) + .setLastEppUpdateClientId(domain.getTransferData().getGainingClientId()) + .build(); + } + + @Test + public void testEppLastUpdateTimeAndClientId_autoRenewBeforeTransferSuccess() { + DateTime now = clock.nowUtc(); + DateTime transferRequestDateTime = now.plusDays(1); + DateTime autorenewDateTime = now.plusDays(3); + DateTime transferSuccessDateTime = now.plusDays(5); + setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime); + + DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime); + assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo("gaining"); + + // If autorenew happens before transfer succeeds(before transfer grace period starts as well), + // lastEppUpdateClientId should still be the current sponsor client id + DomainResource afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); + assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime); + assertThat(afterAutoRenew.getLastEppUpdateClientId()).isEqualTo("losing"); + } + + @Test + public void testEppLastUpdateTimeAndClientId_autoRenewAfterTransferSuccess() { + DateTime now = clock.nowUtc(); + DateTime transferRequestDateTime = now.plusDays(1); + DateTime autorenewDateTime = now.plusDays(3); + DateTime transferSuccessDateTime = now.plusDays(5); + setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime); + + DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime); + assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo("gaining"); + + DomainResource afterTransferSuccess = + domain.cloneProjectedAtTime(transferSuccessDateTime.plusDays(1)); + assertThat(afterTransferSuccess.getLastEppUpdateTime()).isEqualTo(transferSuccessDateTime); + assertThat(afterTransferSuccess.getLastEppUpdateClientId()).isEqualTo("gaining"); + } + + private void setupUnmodifiedDomain(DateTime oldExpirationTime) { + domain = + domain + .asBuilder() + .setRegistrationExpirationTime(oldExpirationTime) + .setTransferData(TransferData.EMPTY) + .setGracePeriods(ImmutableSet.of()) + .setLastEppUpdateTime(null) + .setLastEppUpdateClientId(null) + .build(); + } + + @Test + public void testEppLastUpdateTimeAndClientId_isSetCorrectlyWithNullPreviousValue() { + DateTime now = clock.nowUtc(); + DateTime autorenewDateTime = now.plusDays(3); + setupUnmodifiedDomain(autorenewDateTime); + + DomainResource beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); + assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(null); + assertThat(beforeAutoRenew.getLastEppUpdateClientId()).isEqualTo(null); + + DomainResource afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); + assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime); + assertThat(afterAutoRenew.getLastEppUpdateClientId()).isEqualTo("losing"); + } + @Test public void testStackedGracePeriods() { ImmutableList gracePeriods = ImmutableList.of( @@ -383,7 +471,7 @@ public class DomainResourceTest extends EntityTestCase { domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime()); assertThat(renewed.getRegistrationExpirationTime()) .isEqualTo(domain.getRegistrationExpirationTime().plusYears(1)); - assertThat(renewed.getLastEppUpdateTime()).isEqualTo(clock.nowUtc()); + assertThat(renewed.getLastEppUpdateTime()).isEqualTo(domain.getRegistrationExpirationTime()); assertThat(getOnlyElement(renewed.getGracePeriods()).getType()) .isEqualTo(GracePeriodStatus.AUTO_RENEW); } @@ -428,7 +516,7 @@ public class DomainResourceTest extends EntityTestCase { domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2)); assertThat(renewedThreeTimes.getRegistrationExpirationTime()) .isEqualTo(oldExpirationTime.plusYears(3)); - assertThat(renewedThreeTimes.getLastEppUpdateTime()).isEqualTo(clock.nowUtc()); + assertThat(renewedThreeTimes.getLastEppUpdateTime()).isEqualTo(oldExpirationTime.plusYears(2)); assertThat(renewedThreeTimes.getGracePeriods()) .containsExactly(GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, diff --git a/javatests/google/registry/rde/testdata/testMapReduce_withDomain_producesExpectedXml.xml b/javatests/google/registry/rde/testdata/testMapReduce_withDomain_producesExpectedXml.xml index c405dd205..ee2aa6249 100644 --- a/javatests/google/registry/rde/testdata/testMapReduce_withDomain_producesExpectedXml.xml +++ b/javatests/google/registry/rde/testdata/testMapReduce_withDomain_producesExpectedXml.xml @@ -150,8 +150,8 @@ TheRegistrar 1999-12-31T00:00:00Z 2001-01-01T00:00:00Z - IntoTheTempest - 1999-12-31T00:00:00Z + gaining + 2000-01-01T00:00:00Z 123 diff --git a/javatests/google/registry/whois/WhoisActionTest.java b/javatests/google/registry/whois/WhoisActionTest.java index 0b36dde1c..fa816b8b8 100644 --- a/javatests/google/registry/whois/WhoisActionTest.java +++ b/javatests/google/registry/whois/WhoisActionTest.java @@ -48,11 +48,14 @@ import com.google.common.net.InetAddresses; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainResource; +import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; +import google.registry.model.transfer.TransferData; +import google.registry.model.transfer.TransferStatus; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; @@ -79,7 +82,7 @@ public class WhoisActionTest { @Rule public final InjectRule inject = new InjectRule(); private final FakeResponse response = new FakeResponse(); - private final FakeClock clock = new FakeClock(DateTime.parse("2009-06-29T20:13:00Z")); + private FakeClock clock; private WhoisAction newWhoisAction(String input) { WhoisAction whoisAction = new WhoisAction(); @@ -97,6 +100,7 @@ public class WhoisActionTest { @Before public void setUp() { + clock = new FakeClock(DateTime.parse("2009-06-29T20:13:00Z")); createTlds("lol", "xn--q9jyb4c", "1.test"); inject.setStaticField(Ofy.class, "clock", clock); @@ -112,19 +116,22 @@ public class WhoisActionTest { assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_no_command.txt")); } + private DomainResource makeDomainResourceWithRegistrar(Registrar registrar) { + return makeDomainResource( + "cat.lol", + persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), + persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), + persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), + persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), + persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + registrar); + } + @Test public void testRun_domainQuery_works() { Registrar registrar = persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE)); - persistResource( - makeDomainResource( - "cat.lol", - persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), - persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), - persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), - registrar)); + persistResource(makeDomainResourceWithRegistrar(registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisAction("domain cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); @@ -135,15 +142,7 @@ public class WhoisActionTest { public void testRun_domainQuery_usesCache() { Registrar registrar = persistResource(makeRegistrar("evilregistrar", "Yes Virginia", ACTIVE)); - persistResource( - makeDomainResource( - "cat.lol", - persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), - persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), - persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), - registrar)); + persistResource(makeDomainResourceWithRegistrar(registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); // Populate the cache for both the domain and contact. DomainResource domain = @@ -167,6 +166,31 @@ public class WhoisActionTest { assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_domain.txt")); } + @Test + public void testRun_domainAfterTransfer_hasUpdatedEppTimeAndClientId() { + Registrar registrar = persistResource(makeRegistrar("TheRegistrar", "Yes Virginia", ACTIVE)); + persistResource( + makeDomainResourceWithRegistrar(registrar) + .asBuilder() + .setTransferData( + new TransferData.Builder() + .setGainingClientId("TheRegistrar") + .setLosingClientId("NewRegistrar") + .setTransferRequestTime(DateTime.parse("2009-05-29T20:13:00Z")) + .setPendingTransferExpirationTime(DateTime.parse("2010-03-01T00:00:00Z")) + .setTransferStatus(TransferStatus.PENDING) + .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) + .build()) + .build()); + persistSimpleResources(makeRegistrarContacts(registrar)); + clock.setTo(DateTime.parse("2011-01-01T00:00:00Z")); + + newWhoisAction("domain cat.lol\r\n").run(); + + assertThat(response.getStatus()).isEqualTo(200); + assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_transferred_domain.txt")); + } + @Test public void testRun_idnDomain_works() { Registrar registrar = persistResource(makeRegistrar( diff --git a/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt b/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt new file mode 100644 index 000000000..ab86d749b --- /dev/null +++ b/javatests/google/registry/whois/testdata/whois_action_transferred_domain.txt @@ -0,0 +1,59 @@ +Domain Name: cat.lol +Registry Domain ID: 9-LOL +Registrar WHOIS Server: whois.example.com +Registrar URL: http://my.fake.url +Updated Date: 2010-03-06T00:00:00Z +Creation Date: 2000-10-08T00:45:00Z +Registry Expiry Date: 2020-03-01T00:00:00Z +Registrar: Yes Virginia +Registrar IANA ID: 1 +Registrar Abuse Contact Email: jakedoe@example.com +Registrar Abuse Contact Phone: +1.2125551216 +Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited +Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited +Registry Registrant ID: REDACTED FOR PRIVACY +Registrant Name: REDACTED FOR PRIVACY +Registrant Organization: GOOGLE INCORPORATED