Allow domain transfers with 0 period and in auto-renew grace period

Normally, if a domain is in the auto-renew grace period, a transfer will cancel the auto-renew billing event. In the event of a transfer with no change to registration end date, the auto-renew billing event should not be cancelled and the gaining registrar should not be charged for the transfer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170576726
This commit is contained in:
bbilbo 2017-09-30 01:29:01 -07:00 committed by Ben McIlwain
parent 3c0b17dc6f
commit 7aa5629517
9 changed files with 120 additions and 50 deletions

View file

@ -60,7 +60,6 @@ import google.registry.flows.exceptions.InvalidTransferPeriodValueException;
import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.flows.exceptions.SuperuserExtensionAndAutorenewGracePeriodException;
import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException;
import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException;
import google.registry.model.billing.BillingEvent;
@ -713,20 +712,33 @@ public class DomainTransferRequestFlowTest
}
@Test
public void testFailure_superuserExtension_duringAutorenewGracePeriod() throws Exception {
setupDomain("example", "tld");
public void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive()
throws Exception {
eppRequestSource = EppRequestSource.TOOL;
DomainResource domain = reloadResourceByForeignKey();
DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
persistResource(domain.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
setupDomain("example", "tld");
Key<BillingEvent.Recurring> existingAutorenewEvent =
domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an
// active autorenew grace period spanning the entire transfer window.
DateTime autorenewTime = clock.nowUtc().minusDays(1);
DateTime expirationTime = autorenewTime.plusYears(1);
domain = persistResource(domain.asBuilder()
.setRegistrationExpirationTime(expirationTime)
.addGracePeriod(GracePeriod.createForRecurring(
GracePeriodStatus.AUTO_RENEW,
autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()),
"TheRegistrar",
existingAutorenewEvent))
.build());
clock.advanceOneMilli();
thrown.expect(SuperuserExtensionAndAutorenewGracePeriodException.class);
runTest(
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
UserPrivileges.SUPERUSER,
ImmutableMap.of("PERIOD", "1", "AUTOMATIC_TRANSFER_LENGTH", "5"));
"domain_transfer_request_response_su_ext_zero_period_autorenew_grace.xml",
domain.getRegistrationExpirationTime(),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.<Money>absent(),
Period.create(0, Unit.YEARS),
Duration.standardDays(0));
}
@Test