mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Add clientId and time parameters to pricing methods
This is a broken-out refactoring from [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121603352
This commit is contained in:
parent
4a9be60e0b
commit
6f69e96465
18 changed files with 105 additions and 62 deletions
|
@ -176,7 +176,8 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
||||||
tldState = registry.getTldState(now);
|
tldState = registry.getTldState(now);
|
||||||
checkRegistryStateForTld(tld);
|
checkRegistryStateForTld(tld);
|
||||||
domainLabel = domainName.parts().get(0);
|
domainLabel = domainName.parts().get(0);
|
||||||
createCost = registry.getDomainCreateCost(targetId, command.getPeriod().getValue());
|
createCost =
|
||||||
|
registry.getDomainCreateCost(targetId, now, getClientId(), command.getPeriod().getValue());
|
||||||
// The TLD should always be the parent of the requested domain name.
|
// The TLD should always be the parent of the requested domain name.
|
||||||
isAnchorTenantViaReservation = matchesAnchorTenantReservation(
|
isAnchorTenantViaReservation = matchesAnchorTenantReservation(
|
||||||
domainLabel, tld, command.getAuthInfo().getPw().getValue());
|
domainLabel, tld, command.getAuthInfo().getPw().getValue());
|
||||||
|
@ -201,7 +202,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
||||||
} else if (isClaimsCreate) {
|
} else if (isClaimsCreate) {
|
||||||
throw new ClaimsPeriodEndedException(tld);
|
throw new ClaimsPeriodEndedException(tld);
|
||||||
}
|
}
|
||||||
verifyPremiumNameIsNotBlocked(targetId, tld, getClientId());
|
verifyPremiumNameIsNotBlocked(targetId, now, getClientId(), tld);
|
||||||
}
|
}
|
||||||
verifyUnitIsYears(command.getPeriod());
|
verifyUnitIsYears(command.getPeriod());
|
||||||
verifyNotInPendingDelete(
|
verifyNotInPendingDelete(
|
||||||
|
|
|
@ -103,7 +103,8 @@ public class DomainAllocateFlow extends DomainCreateOrAllocateFlow {
|
||||||
.setFlags(billingFlagsBuilder.add(Flag.ALLOCATION).build())
|
.setFlags(billingFlagsBuilder.add(Flag.ALLOCATION).build())
|
||||||
.setTargetId(targetId)
|
.setTargetId(targetId)
|
||||||
.setClientId(getClientId())
|
.setClientId(getClientId())
|
||||||
.setCost(registry.getDomainCreateCost(targetId, command.getPeriod().getValue()))
|
.setCost(registry
|
||||||
|
.getDomainCreateCost(targetId, now, getClientId(), command.getPeriod().getValue()))
|
||||||
.setPeriodYears(command.getPeriod().getValue())
|
.setPeriodYears(command.getPeriod().getValue())
|
||||||
.setEventTime(now)
|
.setEventTime(now)
|
||||||
// If there are no nameservers on the domain, then they get the benefit of the sunrush add
|
// If there are no nameservers on the domain, then they get the benefit of the sunrush add
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class DomainApplicationCreateFlow extends BaseDomainCreateFlow<DomainAppl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verifyDomainCreateIsAllowed() throws EppException {
|
protected void verifyDomainCreateIsAllowed() throws EppException {
|
||||||
validateFeeChallenge(targetId, getTld(), feeCreate, createCost);
|
validateFeeChallenge(targetId, getTld(), now, getClientId(), feeCreate, createCost);
|
||||||
if (tldState == TldState.LANDRUSH && !superuser) {
|
if (tldState == TldState.LANDRUSH && !superuser) {
|
||||||
// Prohibit creating a landrush application in LANDRUSH (but not in SUNRUSH) if there is
|
// Prohibit creating a landrush application in LANDRUSH (but not in SUNRUSH) if there is
|
||||||
// exactly one sunrise application for the same name.
|
// exactly one sunrise application for the same name.
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
||||||
ReservationType reservationType = getReservationType(domainName);
|
ReservationType reservationType = getReservationType(domainName);
|
||||||
Registry registry = Registry.get(domainName.parent().toString());
|
Registry registry = Registry.get(domainName.parent().toString());
|
||||||
if (reservationType == UNRESERVED
|
if (reservationType == UNRESERVED
|
||||||
&& registry.isPremiumName(domainName)
|
&& registry.isPremiumName(domainName, now, getClientId())
|
||||||
&& registry.getPremiumPriceAckRequired()
|
&& registry.getPremiumPriceAckRequired()
|
||||||
&& !nullToEmpty(sessionMetadata.getServiceExtensionUris()).contains(
|
&& !nullToEmpty(sessionMetadata.getServiceExtensionUris()).contains(
|
||||||
ServiceExtension.FEE_0_6.getUri())) {
|
ServiceExtension.FEE_0_6.getUri())) {
|
||||||
|
@ -114,7 +114,8 @@ public class DomainCheckFlow extends BaseDomainCheckFlow {
|
||||||
throw new OnlyCheckedNamesCanBeFeeCheckedException();
|
throw new OnlyCheckedNamesCanBeFeeCheckedException();
|
||||||
}
|
}
|
||||||
FeeCheck.Builder builder = new FeeCheck.Builder();
|
FeeCheck.Builder builder = new FeeCheck.Builder();
|
||||||
handleFeeRequest(domainCheck, builder, domainName, getTldFromSld(domainName), now);
|
handleFeeRequest(
|
||||||
|
domainCheck, builder, domainName, getTldFromSld(domainName), getClientId(), now);
|
||||||
feeChecksBuilder.add(builder.setName(domainName).build());
|
feeChecksBuilder.add(builder.setName(domainName).build());
|
||||||
}
|
}
|
||||||
return ImmutableList.of(FeeCheckResponseExtension.create(feeChecksBuilder.build()));
|
return ImmutableList.of(FeeCheckResponseExtension.create(feeChecksBuilder.build()));
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
|
||||||
@Override
|
@Override
|
||||||
protected final void verifyDomainCreateIsAllowed() throws EppException {
|
protected final void verifyDomainCreateIsAllowed() throws EppException {
|
||||||
String tld = getTld();
|
String tld = getTld();
|
||||||
validateFeeChallenge(targetId, tld, feeCreate, createCost);
|
validateFeeChallenge(targetId, tld, now, getClientId(), feeCreate, createCost);
|
||||||
if (!superuser) {
|
if (!superuser) {
|
||||||
// Prohibit creating a domain if there is an open application for the same name.
|
// Prohibit creating a domain if there is an open application for the same name.
|
||||||
for (DomainApplication application : loadActiveApplicationsByDomainName(targetId, now)) {
|
for (DomainApplication application : loadActiveApplicationsByDomainName(targetId, now)) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class DomainDeleteFlow extends ResourceSyncDeleteFlow<DomainResource, Bui
|
||||||
checkNotNull(gracePeriod.getRecurringBillingEvent()).get().getRecurrenceTimeOfYear();
|
checkNotNull(gracePeriod.getRecurringBillingEvent()).get().getRecurrenceTimeOfYear();
|
||||||
DateTime autoRenewTime = recurrenceTimeOfYear.getLastInstanceBeforeOrAt(now);
|
DateTime autoRenewTime = recurrenceTimeOfYear.getLastInstanceBeforeOrAt(now);
|
||||||
cost = Registry.get(existingResource.getTld())
|
cost = Registry.get(existingResource.getTld())
|
||||||
.getDomainRenewCost(targetId, 1, autoRenewTime);
|
.getDomainRenewCost(targetId, autoRenewTime, getClientId(), 1);
|
||||||
} else {
|
} else {
|
||||||
cost = checkNotNull(gracePeriod.getOneTimeBillingEvent()).get().getCost();
|
cost = checkNotNull(gracePeriod.getOneTimeBillingEvent()).get().getCost();
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,9 +384,9 @@ public class DomainFlowUtils {
|
||||||
* where it would not be allowed is if domain name is premium, and premium names are blocked by
|
* where it would not be allowed is if domain name is premium, and premium names are blocked by
|
||||||
* this registrar.
|
* this registrar.
|
||||||
*/
|
*/
|
||||||
static void verifyPremiumNameIsNotBlocked(String domainName, String tld, String clientId)
|
static void verifyPremiumNameIsNotBlocked(
|
||||||
throws EppException {
|
String domainName, DateTime priceTime, String clientId, String tld) throws EppException {
|
||||||
if (Registry.get(tld).isPremiumName(domainName)) {
|
if (Registry.get(tld).isPremiumName(domainName, priceTime, clientId)) {
|
||||||
// NB: The load of the Registar object is transactionless, which means that it should hit
|
// NB: The load of the Registar object is transactionless, which means that it should hit
|
||||||
// memcache most of the time.
|
// memcache most of the time.
|
||||||
if (Registrar.loadByClientId(clientId).getBlockPremiumNames()) {
|
if (Registrar.loadByClientId(clientId).getBlockPremiumNames()) {
|
||||||
|
@ -561,6 +561,7 @@ public class DomainFlowUtils {
|
||||||
BaseFeeResponse.Builder<?, ?> builder,
|
BaseFeeResponse.Builder<?, ?> builder,
|
||||||
String domainName,
|
String domainName,
|
||||||
String tld,
|
String tld,
|
||||||
|
String clientIdentifier,
|
||||||
DateTime now) throws EppException {
|
DateTime now) throws EppException {
|
||||||
InternetDomainName domain = InternetDomainName.from(domainName);
|
InternetDomainName domain = InternetDomainName.from(domainName);
|
||||||
FeeCommandDescriptor feeCommand = feeRequest.getCommand();
|
FeeCommandDescriptor feeCommand = feeRequest.getCommand();
|
||||||
|
@ -584,7 +585,7 @@ public class DomainFlowUtils {
|
||||||
.setPeriod(feeRequest.getPeriod())
|
.setPeriod(feeRequest.getPeriod())
|
||||||
// Choose from four classes: premium, premium-collision, collision, or null (standard case).
|
// Choose from four classes: premium, premium-collision, collision, or null (standard case).
|
||||||
.setClass(emptyToNull(Joiner.on('-').skipNulls().join(
|
.setClass(emptyToNull(Joiner.on('-').skipNulls().join(
|
||||||
registry.isPremiumName(domainName) ? "premium" : null,
|
registry.isPremiumName(domainName, now, clientIdentifier) ? "premium" : null,
|
||||||
isNameCollisionInSunrise ? "collision" : null)));
|
isNameCollisionInSunrise ? "collision" : null)));
|
||||||
|
|
||||||
switch (feeCommand.getCommand()) {
|
switch (feeCommand.getCommand()) {
|
||||||
|
@ -595,7 +596,11 @@ public class DomainFlowUtils {
|
||||||
builder.setClass("reserved"); // Override whatever class we've set above.
|
builder.setClass("reserved"); // Override whatever class we've set above.
|
||||||
} else {
|
} else {
|
||||||
builder.setFee(
|
builder.setFee(
|
||||||
Fee.create(registry.getDomainCreateCost(domainName, years).getAmount(), "create"));
|
Fee.create(
|
||||||
|
registry
|
||||||
|
.getDomainCreateCost(domainName, now, clientIdentifier, years)
|
||||||
|
.getAmount(),
|
||||||
|
"create"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RESTORE:
|
case RESTORE:
|
||||||
|
@ -604,23 +609,32 @@ public class DomainFlowUtils {
|
||||||
}
|
}
|
||||||
// Restores have a "renew" and a "restore" fee.
|
// Restores have a "renew" and a "restore" fee.
|
||||||
builder.setFee(
|
builder.setFee(
|
||||||
Fee.create(registry.getDomainRenewCost(domainName, years, now).getAmount(), "renew"),
|
Fee.create(
|
||||||
|
registry.getDomainRenewCost(domainName, now, clientIdentifier, years).getAmount(),
|
||||||
|
"renew"),
|
||||||
Fee.create(registry.getStandardRestoreCost().getAmount(), "restore"));
|
Fee.create(registry.getStandardRestoreCost().getAmount(), "restore"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Anything else (transfer|renew) will have a "renew" fee.
|
// Anything else (transfer|renew) will have a "renew" fee.
|
||||||
builder.setFee(
|
builder.setFee(
|
||||||
Fee.create(registry.getDomainRenewCost(domainName, years, now).getAmount(), "renew"));
|
Fee.create(
|
||||||
|
registry.getDomainRenewCost(domainName, now, clientIdentifier, years).getAmount(),
|
||||||
|
"renew"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validateFeeChallenge(
|
static void validateFeeChallenge(
|
||||||
String domainName, String tld,
|
String domainName,
|
||||||
|
String tld,
|
||||||
|
DateTime priceTime,
|
||||||
|
String clientIdentifier,
|
||||||
final BaseFeeCommand feeCommand,
|
final BaseFeeCommand feeCommand,
|
||||||
Money cost, Money... otherCosts) throws EppException {
|
Money cost,
|
||||||
|
Money... otherCosts)
|
||||||
|
throws EppException {
|
||||||
Registry registry = Registry.get(tld);
|
Registry registry = Registry.get(tld);
|
||||||
if (registry.getPremiumPriceAckRequired()
|
if (registry.getPremiumPriceAckRequired()
|
||||||
&& registry.isPremiumName(domainName)
|
&& registry.isPremiumName(domainName, priceTime, clientIdentifier)
|
||||||
&& feeCommand == null) {
|
&& feeCommand == null) {
|
||||||
throw new FeesRequiredForPremiumNameException();
|
throw new FeesRequiredForPremiumNameException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,8 @@ public class DomainInfoFlow extends BaseDomainInfoFlow<DomainResource, Builder>
|
||||||
FeeInfoExtension feeInfo = eppInput.getSingleExtension(FeeInfoExtension.class);
|
FeeInfoExtension feeInfo = eppInput.getSingleExtension(FeeInfoExtension.class);
|
||||||
if (feeInfo != null) { // Fee check was requested.
|
if (feeInfo != null) { // Fee check was requested.
|
||||||
FeeInfoResponseExtension.Builder builder = new FeeInfoResponseExtension.Builder();
|
FeeInfoResponseExtension.Builder builder = new FeeInfoResponseExtension.Builder();
|
||||||
handleFeeRequest(feeInfo, builder, getTargetId(), existingResource.getTld(), now);
|
handleFeeRequest(
|
||||||
|
feeInfo, builder, getTargetId(), existingResource.getTld(), getClientId(), now);
|
||||||
extensions.add(builder.build());
|
extensions.add(builder.build());
|
||||||
}
|
}
|
||||||
return extensions.build();
|
return extensions.build();
|
||||||
|
|
|
@ -110,8 +110,9 @@ public class DomainRenewFlow extends OwnedResourceMutateFlow<DomainResource, Ren
|
||||||
throw new IncorrectCurrentExpirationDateException();
|
throw new IncorrectCurrentExpirationDateException();
|
||||||
}
|
}
|
||||||
renewCost = Registry.get(existingResource.getTld())
|
renewCost = Registry.get(existingResource.getTld())
|
||||||
.getDomainRenewCost(targetId, command.getPeriod().getValue(), now);
|
.getDomainRenewCost(targetId, now, getClientId(), command.getPeriod().getValue());
|
||||||
validateFeeChallenge(targetId, existingResource.getTld(), feeRenew, renewCost);
|
validateFeeChallenge(
|
||||||
|
targetId, existingResource.getTld(), now, getClientId(), feeRenew, renewCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -98,12 +98,12 @@ public class DomainRestoreRequestFlow extends OwnedResourceMutateFlow<DomainReso
|
||||||
checkAllowedAccessToTld(getAllowedTlds(), tld);
|
checkAllowedAccessToTld(getAllowedTlds(), tld);
|
||||||
if (!superuser) {
|
if (!superuser) {
|
||||||
verifyNotReserved(InternetDomainName.from(targetId), false);
|
verifyNotReserved(InternetDomainName.from(targetId), false);
|
||||||
verifyPremiumNameIsNotBlocked(targetId, tld, getClientId());
|
verifyPremiumNameIsNotBlocked(targetId, now, getClientId(), tld);
|
||||||
}
|
}
|
||||||
feeUpdate = eppInput.getSingleExtension(FeeUpdateExtension.class);
|
feeUpdate = eppInput.getSingleExtension(FeeUpdateExtension.class);
|
||||||
restoreCost = Registry.get(tld).getStandardRestoreCost();
|
restoreCost = Registry.get(tld).getStandardRestoreCost();
|
||||||
renewCost = Registry.get(tld).getDomainRenewCost(targetId, 1, now);
|
renewCost = Registry.get(tld).getDomainRenewCost(targetId, now, getClientId(), 1);
|
||||||
validateFeeChallenge(targetId, tld, feeUpdate, restoreCost, renewCost);
|
validateFeeChallenge(targetId, tld, now, getClientId(), feeUpdate, restoreCost, renewCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,8 +78,9 @@ public class DomainTransferApproveFlow extends
|
||||||
.setPeriodYears(extraYears)
|
.setPeriodYears(extraYears)
|
||||||
.setCost(Registry.get(tld).getDomainRenewCost(
|
.setCost(Registry.get(tld).getDomainRenewCost(
|
||||||
targetId,
|
targetId,
|
||||||
extraYears,
|
transferData.getTransferRequestTime(),
|
||||||
transferData.getTransferRequestTime()))
|
getClientId(),
|
||||||
|
extraYears))
|
||||||
.setEventTime(now)
|
.setEventTime(now)
|
||||||
.setBillingTime(now.plus(Registry.get(tld).getTransferGracePeriodLength()))
|
.setBillingTime(now.plus(Registry.get(tld).getTransferGracePeriodLength()))
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
|
|
|
@ -113,7 +113,8 @@ public class DomainTransferRequestFlow
|
||||||
}
|
}
|
||||||
Registry registry = Registry.get(existingResource.getTld());
|
Registry registry = Registry.get(existingResource.getTld());
|
||||||
automaticTransferTime = now.plus(registry.getAutomaticTransferLength());
|
automaticTransferTime = now.plus(registry.getAutomaticTransferLength());
|
||||||
renewCost = registry.getDomainRenewCost(targetId, command.getPeriod().getValue(), now);
|
renewCost = registry
|
||||||
|
.getDomainRenewCost(targetId, now, getClientId(), command.getPeriod().getValue());
|
||||||
transferBillingEvent = new BillingEvent.OneTime.Builder()
|
transferBillingEvent = new BillingEvent.OneTime.Builder()
|
||||||
.setReason(Reason.TRANSFER)
|
.setReason(Reason.TRANSFER)
|
||||||
.setTargetId(targetId)
|
.setTargetId(targetId)
|
||||||
|
@ -151,9 +152,10 @@ public class DomainTransferRequestFlow
|
||||||
protected final void verifyTransferRequestIsAllowed() throws EppException {
|
protected final void verifyTransferRequestIsAllowed() throws EppException {
|
||||||
verifyUnitIsYears(command.getPeriod());
|
verifyUnitIsYears(command.getPeriod());
|
||||||
if (!superuser) {
|
if (!superuser) {
|
||||||
verifyPremiumNameIsNotBlocked(targetId, existingResource.getTld(), getClientId());
|
verifyPremiumNameIsNotBlocked(targetId, now, getClientId(), existingResource.getTld());
|
||||||
}
|
}
|
||||||
validateFeeChallenge(targetId, existingResource.getTld(), feeTransfer, renewCost);
|
validateFeeChallenge(
|
||||||
|
targetId, existingResource.getTld(), now, getClientId(), feeTransfer, renewCost);
|
||||||
checkAllowedAccessToTld(getAllowedTlds(), existingResource.getTld());
|
checkAllowedAccessToTld(getAllowedTlds(), existingResource.getTld());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -492,26 +492,32 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the given domain name is on the premium price list. */
|
/** Returns true if the given domain name is on the premium price list. */
|
||||||
public boolean isPremiumName(String domainName) {
|
public boolean isPremiumName(String domainName, DateTime priceTime, String clientIdentifier) {
|
||||||
return isPremiumName(InternetDomainName.from(domainName));
|
return isPremiumName(InternetDomainName.from(domainName), priceTime, clientIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the given domain name is on the premium price list. */
|
/** Returns true if the given domain name is on the premium price list. */
|
||||||
public boolean isPremiumName(InternetDomainName domainName) {
|
@SuppressWarnings("unused")
|
||||||
|
public boolean isPremiumName(
|
||||||
|
InternetDomainName domainName, DateTime priceTime, String clientIdentifier) {
|
||||||
return getPremiumPriceForSld(domainName).isPresent();
|
return getPremiumPriceForSld(domainName).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the billing cost for registering the specified domain name for this many years. */
|
/** Returns the billing cost for registering the specified domain name for this many years. */
|
||||||
public Money getDomainCreateCost(String domainName, int years) {
|
@SuppressWarnings("unused")
|
||||||
|
public Money getDomainCreateCost(
|
||||||
|
String domainName, DateTime priceTime, String clientIdentifier, int years) {
|
||||||
checkArgument(years > 0, "Number of years must be positive");
|
checkArgument(years > 0, "Number of years must be positive");
|
||||||
Money annualCost = getPremiumPriceForSld(domainName).or(getStandardCreateCost());
|
Money annualCost = getPremiumPriceForSld(domainName).or(getStandardCreateCost());
|
||||||
return annualCost.multipliedBy(years);
|
return annualCost.multipliedBy(years);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the billing cost for renewing the specified domain name for this many years. */
|
/** Returns the billing cost for renewing the specified domain name for this many years. */
|
||||||
public Money getDomainRenewCost(String domainName, int years, DateTime now) {
|
@SuppressWarnings("unused")
|
||||||
|
public Money getDomainRenewCost(
|
||||||
|
String domainName, DateTime priceTime, String clientIdentifier, int years) {
|
||||||
checkArgument(years > 0, "Number of years must be positive");
|
checkArgument(years > 0, "Number of years must be positive");
|
||||||
Money annualCost = getPremiumPriceForSld(domainName).or(getStandardRenewCost(now));
|
Money annualCost = getPremiumPriceForSld(domainName).or(getStandardRenewCost(priceTime));
|
||||||
return annualCost.multipliedBy(years);
|
return annualCost.multipliedBy(years);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.tools;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
import static google.registry.model.registry.Registries.findTldForNameOrThrow;
|
import static google.registry.model.registry.Registries.findTldForNameOrThrow;
|
||||||
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
|
@ -29,6 +30,7 @@ import google.registry.tools.Command.GtechCommand;
|
||||||
import google.registry.tools.soy.CreateAnchorTenantSoyInfo;
|
import google.registry.tools.soy.CreateAnchorTenantSoyInfo;
|
||||||
|
|
||||||
import org.joda.money.Money;
|
import org.joda.money.Money;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -86,7 +88,9 @@ final class CreateAnchorTenantCommand extends MutatingEppToolCommand implements
|
||||||
|
|
||||||
Money cost = null;
|
Money cost = null;
|
||||||
if (fee) {
|
if (fee) {
|
||||||
cost = Registry.get(tld).getDomainCreateCost(domainName, DEFAULT_ANCHOR_TENANT_PERIOD_YEARS);
|
cost = Registry.get(tld)
|
||||||
|
.getDomainCreateCost(
|
||||||
|
domainName, DateTime.now(UTC), clientIdentifier, DEFAULT_ANCHOR_TENANT_PERIOD_YEARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSoyTemplate(CreateAnchorTenantSoyInfo.getInstance(),
|
setSoyTemplate(CreateAnchorTenantSoyInfo.getInstance(),
|
||||||
|
|
|
@ -179,7 +179,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.CREATE)
|
||||||
.setTargetId(getUniqueIdFromCommand())
|
.setTargetId(getUniqueIdFromCommand())
|
||||||
.setClientId("TheRegistrar")
|
.setClientId("TheRegistrar")
|
||||||
.setCost(Registry.get(domainTld).isPremiumName(getUniqueIdFromCommand())
|
.setCost(Registry.get(domainTld)
|
||||||
|
.isPremiumName(getUniqueIdFromCommand(), clock.nowUtc(), "TheRegistrar")
|
||||||
? Money.of(USD, 200)
|
? Money.of(USD, 200)
|
||||||
: Money.of(USD, 26))
|
: Money.of(USD, 26))
|
||||||
.setPeriodYears(2)
|
.setPeriodYears(2)
|
||||||
|
|
|
@ -185,6 +185,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||||
return createBillingEventForTransfer(
|
return createBillingEventForTransfer(
|
||||||
domain,
|
domain,
|
||||||
historyEntry,
|
historyEntry,
|
||||||
|
"NewRegistrar",
|
||||||
TRANSFER_REQUEST_TIME,
|
TRANSFER_REQUEST_TIME,
|
||||||
TRANSFER_EXPIRATION_TIME,
|
TRANSFER_EXPIRATION_TIME,
|
||||||
EXTENDED_REGISTRATION_YEARS);
|
EXTENDED_REGISTRATION_YEARS);
|
||||||
|
|
|
@ -311,9 +311,9 @@ public class RegistryTest extends EntityTestCase {
|
||||||
public void testIsPremiumDomain() throws Exception {
|
public void testIsPremiumDomain() throws Exception {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
Registry registry = Registry.get("example");
|
Registry registry = Registry.get("example");
|
||||||
assertThat(registry.isPremiumName("poor.example")).isFalse();
|
assertThat(registry.isPremiumName("poor.example", clock.nowUtc(), "TheRegistrar")).isFalse();
|
||||||
assertThat(registry.isPremiumName("rich.example")).isTrue();
|
assertThat(registry.isPremiumName("rich.example", clock.nowUtc(), "TheRegistrar")).isTrue();
|
||||||
assertThat(registry.isPremiumName("richer.example")).isTrue();
|
assertThat(registry.isPremiumName("richer.example", clock.nowUtc(), "TheRegistrar")).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetDomainCreateCost() throws Exception {
|
public void testGetDomainCreateCost() throws Exception {
|
||||||
|
@ -321,10 +321,14 @@ public class RegistryTest extends EntityTestCase {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
Registry registry = Registry.get("example");
|
Registry registry = Registry.get("example");
|
||||||
// The default value of 17 is set in createTld().
|
// The default value of 17 is set in createTld().
|
||||||
assertThat(registry.getDomainCreateCost("poor.example", 1)).isEqualTo(Money.of(USD, 13));
|
assertThat(registry.getDomainCreateCost("poor.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||||
assertThat(registry.getDomainCreateCost("poor.example", 2)).isEqualTo(Money.of(USD, 26));
|
.isEqualTo(Money.of(USD, 13));
|
||||||
assertThat(registry.getDomainCreateCost("rich.example", 1)).isEqualTo(Money.of(USD, 100));
|
assertThat(registry.getDomainCreateCost("poor.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||||
assertThat(registry.getDomainCreateCost("rich.example", 2)).isEqualTo(Money.of(USD, 200));
|
.isEqualTo(Money.of(USD, 26));
|
||||||
|
assertThat(registry.getDomainCreateCost("rich.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||||
|
.isEqualTo(Money.of(USD, 100));
|
||||||
|
assertThat(registry.getDomainCreateCost("rich.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||||
|
.isEqualTo(Money.of(USD, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -336,21 +340,21 @@ public class RegistryTest extends EntityTestCase {
|
||||||
START_OF_TIME, Money.of(USD, 8),
|
START_OF_TIME, Money.of(USD, 8),
|
||||||
clock.nowUtc(), Money.of(USD, 10)))
|
clock.nowUtc(), Money.of(USD, 10)))
|
||||||
.build();
|
.build();
|
||||||
assertThat(registry.getDomainRenewCost("poor.example", 1, START_OF_TIME))
|
assertThat(registry.getDomainRenewCost("poor.example", START_OF_TIME, "TheRegistrar", 1))
|
||||||
.isEqualTo(Money.of(USD, 8));
|
.isEqualTo(Money.of(USD, 8));
|
||||||
assertThat(registry.getDomainRenewCost("poor.example", 2, START_OF_TIME))
|
assertThat(registry.getDomainRenewCost("poor.example", START_OF_TIME, "TheRegistrar", 2))
|
||||||
.isEqualTo(Money.of(USD, 16));
|
.isEqualTo(Money.of(USD, 16));
|
||||||
assertThat(registry.getDomainRenewCost("poor.example", 1, clock.nowUtc()))
|
assertThat(registry.getDomainRenewCost("poor.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||||
.isEqualTo(Money.of(USD, 10));
|
.isEqualTo(Money.of(USD, 10));
|
||||||
assertThat(registry.getDomainRenewCost("poor.example", 2, clock.nowUtc()))
|
assertThat(registry.getDomainRenewCost("poor.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||||
.isEqualTo(Money.of(USD, 20));
|
.isEqualTo(Money.of(USD, 20));
|
||||||
assertThat(registry.getDomainRenewCost("rich.example", 1, START_OF_TIME))
|
assertThat(registry.getDomainRenewCost("rich.example", START_OF_TIME, "TheRegistrar", 1))
|
||||||
.isEqualTo(Money.of(USD, 100));
|
.isEqualTo(Money.of(USD, 100));
|
||||||
assertThat(registry.getDomainRenewCost("rich.example", 2, START_OF_TIME))
|
assertThat(registry.getDomainRenewCost("rich.example", START_OF_TIME, "TheRegistrar", 2))
|
||||||
.isEqualTo(Money.of(USD, 200));
|
.isEqualTo(Money.of(USD, 200));
|
||||||
assertThat(registry.getDomainRenewCost("rich.example", 1, clock.nowUtc()))
|
assertThat(registry.getDomainRenewCost("rich.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||||
.isEqualTo(Money.of(USD, 100));
|
.isEqualTo(Money.of(USD, 100));
|
||||||
assertThat(registry.getDomainRenewCost("rich.example", 2, clock.nowUtc()))
|
assertThat(registry.getDomainRenewCost("rich.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||||
.isEqualTo(Money.of(USD, 200));
|
.isEqualTo(Money.of(USD, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,39 +458,41 @@ public class RegistryTest extends EntityTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_isPremiumNameForSldNotUnderTld() {
|
public void testFailure_isPremiumNameForSldNotUnderTld() {
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("tld").isPremiumName("test.example");
|
Registry.get("tld").isPremiumName("test.example", clock.nowUtc(), "TheRegistrar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_isPremiumNameForSldSubdomain() throws Exception {
|
public void testFailure_isPremiumNameForSldSubdomain() throws Exception {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("example").isPremiumName("rich.sld.example");
|
Registry.get("example").isPremiumName("rich.sld.example", clock.nowUtc(), "TheRegistrar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_getCreateCostForSldNotUnderTld() {
|
public void testFailure_getCreateCostForSldNotUnderTld() {
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("tld").getDomainCreateCost("test.example", 1);
|
Registry.get("tld").getDomainCreateCost("test.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_getCreateCostForSldSubdomain() throws Exception {
|
public void testFailure_getCreateCostForSldSubdomain() throws Exception {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("example").getDomainCreateCost("rich.sld.example", 1);
|
Registry.get("example")
|
||||||
|
.getDomainCreateCost("rich.sld.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_getRenewCostForSldNotUnderTld() {
|
public void testFailure_getRenewCostForSldNotUnderTld() {
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("tld").getDomainRenewCost("test.example", 1, clock.nowUtc());
|
Registry.get("tld").getDomainRenewCost("test.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_getRenewCostForSldSubdomain() throws Exception {
|
public void testFailure_getRenewCostForSldSubdomain() throws Exception {
|
||||||
createTld("example");
|
createTld("example");
|
||||||
thrown.expect(IllegalArgumentException.class);
|
thrown.expect(IllegalArgumentException.class);
|
||||||
Registry.get("example").getDomainRenewCost("rich.sld.example", 1, clock.nowUtc());
|
Registry.get("example")
|
||||||
|
.getDomainRenewCost("rich.sld.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,6 +424,7 @@ public class DatastoreHelper {
|
||||||
public static BillingEvent.OneTime createBillingEventForTransfer(
|
public static BillingEvent.OneTime createBillingEventForTransfer(
|
||||||
DomainResource domain,
|
DomainResource domain,
|
||||||
HistoryEntry historyEntry,
|
HistoryEntry historyEntry,
|
||||||
|
String gainingClientId,
|
||||||
DateTime costLookupTime,
|
DateTime costLookupTime,
|
||||||
DateTime eventTime,
|
DateTime eventTime,
|
||||||
Integer extendedRegistrationYears) {
|
Integer extendedRegistrationYears) {
|
||||||
|
@ -437,8 +438,9 @@ public class DatastoreHelper {
|
||||||
.setPeriodYears(extendedRegistrationYears)
|
.setPeriodYears(extendedRegistrationYears)
|
||||||
.setCost(Registry.get(domain.getTld()).getDomainRenewCost(
|
.setCost(Registry.get(domain.getTld()).getDomainRenewCost(
|
||||||
domain.getFullyQualifiedDomainName(),
|
domain.getFullyQualifiedDomainName(),
|
||||||
extendedRegistrationYears,
|
costLookupTime,
|
||||||
costLookupTime))
|
gainingClientId,
|
||||||
|
extendedRegistrationYears))
|
||||||
.setParent(historyEntry)
|
.setParent(historyEntry)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -499,6 +501,7 @@ public class DatastoreHelper {
|
||||||
BillingEvent.OneTime transferBillingEvent = persistResource(createBillingEventForTransfer(
|
BillingEvent.OneTime transferBillingEvent = persistResource(createBillingEventForTransfer(
|
||||||
domain,
|
domain,
|
||||||
historyEntryDomainTransfer,
|
historyEntryDomainTransfer,
|
||||||
|
"NewRegistrar",
|
||||||
requestTime,
|
requestTime,
|
||||||
expirationTime,
|
expirationTime,
|
||||||
extendedRegistrationYears));
|
extendedRegistrationYears));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue