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

@ -138,8 +138,15 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
int extraYears = transferData.getTransferPeriod().getValue();
if (autorenewGrace != null) {
extraYears = 0;
ofy().save().entity(
BillingEvent.Cancellation.forGracePeriod(autorenewGrace, historyEntry, targetId));
// During a normal transfer, if the domain is in the auto-renew grace period, the auto-renew
// billing event is cancelled and the gaining registrar is charged for the one year renewal.
// But, if the superuser extension is used to request a transfer without an additional year
// then the gaining registrar is not charged for the one year renewal and the losing registrar
// still needs to be charged for the auto-renew.
if (billingEvent.isPresent()) {
ofy().save().entity(
BillingEvent.Cancellation.forGracePeriod(autorenewGrace, historyEntry, targetId));
}
}
// Close the old autorenew event and poll message at the transfer time (aka now). This may end
// up deleting the poll message.

View file

@ -46,7 +46,6 @@ import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.InvalidTransferPeriodValueException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.SuperuserExtensionAndAutorenewGracePeriodException;
import google.registry.flows.exceptions.TransferPeriodMustBeOneYearException;
import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException;
import google.registry.model.domain.DomainCommand.Transfer;
@ -99,7 +98,6 @@ import org.joda.time.DateTime;
* @error {@link google.registry.flows.exceptions.MissingTransferRequestAuthInfoException}
* @error {@link google.registry.flows.exceptions.ObjectAlreadySponsoredException}
* @error {@link google.registry.flows.exceptions.ResourceStatusProhibitsOperationException}
* @error {@link google.registry.flows.exceptions.SuperuserExtensionAndAutorenewGracePeriodException}
* @error {@link google.registry.flows.exceptions.TransferPeriodMustBeOneYearException}
* @error {@link InvalidTransferPeriodValueException}
* @error {@link google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensionException}
@ -184,10 +182,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
DomainResource domainAtTransferTime =
existingDomain.cloneProjectedAtTime(automaticTransferTime);
if (!domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW).isEmpty()) {
if (superuserExtension != null) {
// We don't allow the superuser extension for domains in the auto renew grace period
throw new SuperuserExtensionAndAutorenewGracePeriodException();
}
extraYears = 0;
}
// The new expiration time if there is a server approval.

View file

@ -119,7 +119,7 @@ public final class DomainTransferUtils {
return builder
.addAll(
createOptionalAutorenewCancellation(
automaticTransferTime, historyEntry, targetId, existingDomain)
automaticTransferTime, historyEntry, targetId, existingDomain, transferCost)
.asSet())
.add(
createGainingClientAutorenewEvent(
@ -229,7 +229,9 @@ public final class DomainTransferUtils {
* expiration time. Since the gaining registrar will still be billed for the transfer's 1-year
* renewal, we must issue a cancellation for the autorenew, so that the losing registrar will not
* be charged (essentially, the gaining registrar takes on the cost of the year of registration
* that the autorenew just added).
* that the autorenew just added). But, if the superuser extension is used to request a transfer
* without an additional year then the gaining registrar is not charged for the one year renewal
* and the losing registrar still needs to be charged for the auto-renew.
*
* <p>For details on the policy justification, see b/19430703#comment17 and <a
* href="https://www.icann.org/news/advisory-2002-06-06-en">this ICANN advisory</a>.
@ -238,13 +240,14 @@ public final class DomainTransferUtils {
DateTime automaticTransferTime,
HistoryEntry historyEntry,
String targetId,
DomainResource existingDomain) {
DomainResource existingDomain,
Optional<Money> transferCost) {
DomainResource domainAtTransferTime =
existingDomain.cloneProjectedAtTime(automaticTransferTime);
GracePeriod autorenewGracePeriod =
getOnlyElement(
domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);
if (autorenewGracePeriod != null) {
if (autorenewGracePeriod != null && transferCost.isPresent()) {
return Optional.of(
BillingEvent.Cancellation.forGracePeriod(autorenewGracePeriod, historyEntry, targetId)
.asBuilder()

View file

@ -1,25 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.flows.exceptions;
import google.registry.flows.EppException.StatusProhibitsOperationException;
/** Superuser extensions cannot be used during autorenew grace periods. */
public class SuperuserExtensionAndAutorenewGracePeriodException extends
StatusProhibitsOperationException {
public SuperuserExtensionAndAutorenewGracePeriodException() {
super("Superuser extensions cannot be used during autorenew grace periods.");
}
}