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

@ -42,6 +42,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.googlecode.objectify.Key;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
@ -52,6 +53,7 @@ import google.registry.model.billing.BillingEvent.Cancellation;
import google.registry.model.billing.BillingEvent.Cancellation.Builder;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainResource;
@ -568,7 +570,6 @@ public class DomainTransferApproveFlowTest
previousSuccessRecord.asBuilder().setReportAmount(-1).build(),
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusDays(3), TRANSFER_SUCCESSFUL, 1));
}
@Test
@ -589,4 +590,37 @@ public class DomainTransferApproveFlowTest
domain.getRegistrationExpirationTime().plusYears(0));
assertHistoryEntriesDoNotContainTransferBillingEventsOrGracePeriods();
}
@Test
public void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive()
throws Exception {
DomainResource domain = reloadResourceByForeignKey();
Key<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);
TransferData.Builder transferDataBuilder = domain.getTransferData().asBuilder();
domain =
persistResource(
domain
.asBuilder()
.setTransferData(
transferDataBuilder.setTransferPeriod(Period.create(0, Unit.YEARS)).build())
.setRegistrationExpirationTime(expirationTime)
.addGracePeriod(
GracePeriod.createForRecurring(
GracePeriodStatus.AUTO_RENEW,
autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()),
"TheRegistrar",
existingAutorenewEvent))
.build());
clock.advanceOneMilli();
runSuccessfulFlowWithAssertions(
"tld",
"domain_transfer_approve.xml",
"domain_transfer_approve_response_zero_period_autorenew_grace.xml",
domain.getRegistrationExpirationTime());
assertHistoryEntriesDoNotContainTransferBillingEventsOrGracePeriods();
}
}