mirror of
https://github.com/google/nomulus.git
synced 2025-05-21 19:59:34 +02:00
Fix RDE import pending transfer handling
Mostly based on the original PR, but with some tweaking by nfelt@, in particular to add some support for autorenew grace period subsumption. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=169922894
This commit is contained in:
parent
2814561e92
commit
3ad21e3834
7 changed files with 495 additions and 89 deletions
|
@ -46,6 +46,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
|
|||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.testing.FakeResponse;
|
||||
|
@ -70,6 +71,8 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
private static final ByteSource DEPOSIT_1_DOMAIN = RdeImportsTestData.get("deposit_1_domain.xml");
|
||||
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER =
|
||||
RdeImportsTestData.get("deposit_1_domain_pending_transfer.xml");
|
||||
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER_REG_CAP =
|
||||
RdeImportsTestData.get("deposit_1_domain_pending_transfer_registration_cap.xml");
|
||||
private static final String IMPORT_BUCKET_NAME = "import-bucket";
|
||||
private static final String IMPORT_FILE_NAME = "escrow-file.xml";
|
||||
|
||||
|
@ -191,7 +194,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
|
||||
// Domain should be assigned to RegistrarY after server approval
|
||||
DomainResource afterApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime.plus(Seconds.ONE));
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime);
|
||||
assertThat(afterApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarY");
|
||||
assertThat(loadAutorenewBillingEventForDomain(afterApproval).getClientId())
|
||||
.isEqualTo("RegistrarY");
|
||||
|
@ -213,6 +216,48 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
afterApproval, "RegistrarY", DateTime.parse("2016-04-03T22:00:00.0Z"), END_OF_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapreducePendingTransferRegistrationCap() throws Exception {
|
||||
DateTime serverApprovalTime = DateTime.parse("2015-02-03T22:00:00.0Z");
|
||||
pushToGcs(DEPOSIT_1_DOMAIN_PENDING_TRANSFER_REG_CAP);
|
||||
runMapreduce();
|
||||
List<DomainResource> domains = ofy().load().type(DomainResource.class).list();
|
||||
assertThat(domains).hasSize(1);
|
||||
checkDomain(domains.get(0));
|
||||
|
||||
// Domain should be assigned to RegistrarX before server approval
|
||||
DomainResource beforeApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime.minus(Seconds.ONE));
|
||||
assertThat(beforeApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarX");
|
||||
assertThat(loadAutorenewBillingEventForDomain(beforeApproval).getClientId())
|
||||
.isEqualTo("RegistrarX");
|
||||
assertThat(loadAutorenewPollMessageForDomain(beforeApproval).getClientId())
|
||||
.isEqualTo("RegistrarX");
|
||||
// Current expiration is 2024-04-03T22:00:00.0Z
|
||||
assertThat(beforeApproval.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2024-04-03T22:00:00.0Z"));
|
||||
|
||||
// Domain should be assigned to RegistrarY after server approval
|
||||
DomainResource afterApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime);
|
||||
assertThat(afterApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarY");
|
||||
// New expiration should be capped at 10 years from server approval time, which is 2025-02-03,
|
||||
// instead of 2025-04-03 which would be the current expiration plus a full year.
|
||||
assertThat(afterApproval.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2025-02-03T22:00:00.0Z"));
|
||||
|
||||
// Same checks for the autorenew billing event and poll message.
|
||||
checkAutorenewBillingEvent(
|
||||
afterApproval, "RegistrarY", DateTime.parse("2025-02-03T22:00:00.0Z"), END_OF_TIME);
|
||||
checkAutorenewPollMessage(
|
||||
afterApproval, "RegistrarY", DateTime.parse("2025-02-03T22:00:00.0Z"), END_OF_TIME);
|
||||
|
||||
// Check expiration time in losing registrar's poll message responseData.
|
||||
checkTransferRequestPollMessage(domains.get(0), "RegistrarX",
|
||||
DateTime.parse("2015-01-29T22:00:00.0Z"),
|
||||
DateTime.parse("2025-02-03T22:00:00.0Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapreducePendingTransferEvents() throws Exception {
|
||||
pushToGcs(DEPOSIT_1_DOMAIN_PENDING_TRANSFER);
|
||||
|
@ -220,11 +265,18 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
List<DomainResource> domains = ofy().load().type(DomainResource.class).list();
|
||||
assertThat(domains).hasSize(1);
|
||||
checkDomain(domains.get(0));
|
||||
checkTransferRequestPollMessage(domains.get(0), "RegistrarX",
|
||||
DateTime.parse("2015-01-03T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(domains.get(0), "RegistrarX",
|
||||
checkTransferRequestPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarX",
|
||||
DateTime.parse("2015-01-03T22:00:00.0Z"),
|
||||
DateTime.parse("2016-04-03T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarX",
|
||||
DateTime.parse("2015-01-08T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(domains.get(0), "RegistrarY",
|
||||
checkTransferServerApprovalPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarY",
|
||||
DateTime.parse("2015-01-08T22:00:00.0Z"));
|
||||
// Billing event is set to the end of the transfer grace period, 5 days after server approval
|
||||
checkTransferBillingEvent(domains.get(0), DateTime.parse("2015-01-13T22:00:00.0Z"));
|
||||
|
@ -244,11 +296,17 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
|
||||
/** Verifies the existence of a transfer request poll message */
|
||||
private static void checkTransferRequestPollMessage(
|
||||
DomainResource domain, String clientId, DateTime expectedAt) {
|
||||
DomainResource domain, String clientId, DateTime expectedAt, DateTime expectedExpiration) {
|
||||
for (PollMessage message : getPollMessages(domain)) {
|
||||
if (TransferStatus.PENDING.getMessage().equals(message.getMsg())
|
||||
&& clientId.equals(message.getClientId())
|
||||
&& expectedAt.equals(message.getEventTime())) {
|
||||
assertThat(message.getResponseData()).hasSize(1);
|
||||
DomainTransferResponse responseData =
|
||||
(DomainTransferResponse) message.getResponseData().get(0);
|
||||
// make sure expiration is set correctly
|
||||
assertThat(responseData.getExtendedRegistrationExpirationTime())
|
||||
.isEqualTo(expectedExpiration);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue