Do not require fee extension on free updates

This CL fixes a bug introduced in [] which caused an exception to be thrown when an attempt was made to update a domain without a fee extension, even if the update was free, as it usually is. The fee extension should only be required if the update is not free.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134830250
This commit is contained in:
mountford 2016-09-30 14:49:27 -07:00 committed by Ben McIlwain
parent ee13ee35b0
commit 237e588d6c
4 changed files with 98 additions and 13 deletions

View file

@ -39,6 +39,7 @@ import google.registry.model.registry.Registry;
import google.registry.model.reporting.HistoryEntry;
import java.util.Set;
import javax.inject.Inject;
import org.joda.money.Money;
import org.joda.time.DateTime;
/**
@ -150,12 +151,17 @@ public class DomainUpdateFlow extends BaseDomainUpdateFlow<DomainResource, Build
getClientId(),
now,
eppInput);
// The fee extension must be present if the update is not free.
if ((feeUpdate == null) && !commandOperations.getTotalCost().isZero()) {
// If the fee extension is present, validate it (even if the cost is zero, to check for price
// mismatches). Don't rely on the the validateFeeChallenge check for feeUpdate nullness, because
// it throws an error if the name is premium, and we don't want to do that here.
Money totalCost = commandOperations.getTotalCost();
if (feeUpdate != null) {
validateFeeChallenge(targetId, existingResource.getTld(), now, feeUpdate, totalCost);
// If it's not present but the cost is not zero, throw an exception.
} else if (!totalCost.isZero()) {
throw new FeesRequiredForNonFreeUpdateException();
}
validateFeeChallenge(
targetId, existingResource.getTld(), now, feeUpdate, commandOperations.getTotalCost());
}
@Override