mirror of
https://github.com/google/nomulus.git
synced 2025-08-15 05:54:06 +02:00
Change __REMOVEDOMAIN__ token to __REMOVE_BULK_PRICING__ (#2152)
This commit is contained in:
parent
dded258864
commit
58c7e3a52c
5 changed files with 44 additions and 40 deletions
|
@ -53,8 +53,8 @@ import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeResponseRet
|
||||||
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters;
|
import google.registry.flows.custom.DomainRenewFlowCustomLogic.BeforeSaveParameters;
|
||||||
import google.registry.flows.custom.EntityChanges;
|
import google.registry.flows.custom.EntityChanges;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnBulkPricingDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveBulkPricingTokenOnBulkPricingDomainException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonBulkPricingDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveBulkPricingTokenOnNonBulkPricingDomainException;
|
||||||
import google.registry.model.ImmutableObject;
|
import google.registry.model.ImmutableObject;
|
||||||
import google.registry.model.billing.BillingBase.Reason;
|
import google.registry.model.billing.BillingBase.Reason;
|
||||||
import google.registry.model.billing.BillingEvent;
|
import google.registry.model.billing.BillingEvent;
|
||||||
|
@ -121,8 +121,8 @@ import org.joda.time.Duration;
|
||||||
* @error {@link DomainFlowUtils.RegistrarMustBeActiveForThisOperationException}
|
* @error {@link DomainFlowUtils.RegistrarMustBeActiveForThisOperationException}
|
||||||
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
|
* @error {@link DomainFlowUtils.UnsupportedFeeAttributeException}
|
||||||
* @error {@link DomainRenewFlow.IncorrectCurrentExpirationDateException}
|
* @error {@link DomainRenewFlow.IncorrectCurrentExpirationDateException}
|
||||||
* @error {@link MissingRemoveDomainTokenOnBulkPricingDomainException}
|
* @error {@link MissingRemoveBulkPricingTokenOnBulkPricingDomainException}
|
||||||
* @error {@link RemoveDomainTokenOnNonBulkPricingDomainException}
|
* @error {@link RemoveBulkPricingTokenOnNonBulkPricingDomainException}
|
||||||
* @error {@link
|
* @error {@link
|
||||||
* google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForDomainException}
|
* google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForDomainException}
|
||||||
* @error {@link
|
* @error {@link
|
||||||
|
@ -328,7 +328,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||||
checkHasBillingAccount(registrarId, existingDomain.getTld());
|
checkHasBillingAccount(registrarId, existingDomain.getTld());
|
||||||
}
|
}
|
||||||
verifyUnitIsYears(command.getPeriod());
|
verifyUnitIsYears(command.getPeriod());
|
||||||
// We only allow __REMOVEDOMAIN__ token on bulk pricing domains for now
|
// We only allow __REMOVE_BULK_PRICING__ token on bulk pricing domains for now
|
||||||
verifyTokenAllowedOnDomain(existingDomain, allocationToken);
|
verifyTokenAllowedOnDomain(existingDomain, allocationToken);
|
||||||
// If the date they specify doesn't match the expiration, fail. (This is an idempotence check).
|
// If the date they specify doesn't match the expiration, fail. (This is an idempotence check).
|
||||||
if (!command.getCurrentExpirationDate().equals(
|
if (!command.getCurrentExpirationDate().equals(
|
||||||
|
|
|
@ -243,21 +243,21 @@ public class AllocationTokenFlowUtils {
|
||||||
Domain domain, Optional<AllocationToken> allocationToken) throws EppException {
|
Domain domain, Optional<AllocationToken> allocationToken) throws EppException {
|
||||||
|
|
||||||
boolean domainHasBulkToken = domain.getCurrentBulkToken().isPresent();
|
boolean domainHasBulkToken = domain.getCurrentBulkToken().isPresent();
|
||||||
boolean hasRemoveDomainToken =
|
boolean hasRemoveBulkPricingToken =
|
||||||
allocationToken.isPresent()
|
allocationToken.isPresent()
|
||||||
&& TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior());
|
&& TokenBehavior.REMOVE_BULK_PRICING.equals(allocationToken.get().getTokenBehavior());
|
||||||
|
|
||||||
if (hasRemoveDomainToken && !domainHasBulkToken) {
|
if (hasRemoveBulkPricingToken && !domainHasBulkToken) {
|
||||||
throw new RemoveDomainTokenOnNonBulkPricingDomainException();
|
throw new RemoveBulkPricingTokenOnNonBulkPricingDomainException();
|
||||||
} else if (!hasRemoveDomainToken && domainHasBulkToken) {
|
} else if (!hasRemoveBulkPricingToken && domainHasBulkToken) {
|
||||||
throw new MissingRemoveDomainTokenOnBulkPricingDomainException();
|
throw new MissingRemoveBulkPricingTokenOnBulkPricingDomainException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Domain maybeApplyBulkPricingRemovalToken(
|
public static Domain maybeApplyBulkPricingRemovalToken(
|
||||||
Domain domain, Optional<AllocationToken> allocationToken) {
|
Domain domain, Optional<AllocationToken> allocationToken) {
|
||||||
if (!allocationToken.isPresent()
|
if (!allocationToken.isPresent()
|
||||||
|| !TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior())) {
|
|| !TokenBehavior.REMOVE_BULK_PRICING.equals(allocationToken.get().getTokenBehavior())) {
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,19 +338,19 @@ public class AllocationTokenFlowUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The __REMOVEDOMAIN__ token is missing on a bulk pricing domain command */
|
/** The __REMOVE_BULK_PRICING__ token is missing on a bulk pricing domain command */
|
||||||
public static class MissingRemoveDomainTokenOnBulkPricingDomainException
|
public static class MissingRemoveBulkPricingTokenOnBulkPricingDomainException
|
||||||
extends AssociationProhibitsOperationException {
|
extends AssociationProhibitsOperationException {
|
||||||
MissingRemoveDomainTokenOnBulkPricingDomainException() {
|
MissingRemoveBulkPricingTokenOnBulkPricingDomainException() {
|
||||||
super("Domains that are inside bulk pricing cannot be explicitly renewed or transferred");
|
super("Domains that are inside bulk pricing cannot be explicitly renewed or transferred");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The __REMOVEDOMAIN__ token is not allowed on non bulk pricing domains */
|
/** The __REMOVE_BULK_PRICING__ token is not allowed on non bulk pricing domains */
|
||||||
public static class RemoveDomainTokenOnNonBulkPricingDomainException
|
public static class RemoveBulkPricingTokenOnNonBulkPricingDomainException
|
||||||
extends AssociationProhibitsOperationException {
|
extends AssociationProhibitsOperationException {
|
||||||
RemoveDomainTokenOnNonBulkPricingDomainException() {
|
RemoveBulkPricingTokenOnNonBulkPricingDomainException() {
|
||||||
super("__REMOVEDOMAIN__ token is not allowed on non bulk pricing domains");
|
super("__REMOVE_BULK_PRICING__ token is not allowed on non bulk pricing domains");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,10 @@ import org.joda.time.DateTime;
|
||||||
public class AllocationToken extends UpdateAutoTimestampEntity implements Buildable {
|
public class AllocationToken extends UpdateAutoTimestampEntity implements Buildable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3954475393220876903L;
|
private static final long serialVersionUID = -3954475393220876903L;
|
||||||
private static final String REMOVE_DOMAIN = "__REMOVEDOMAIN__";
|
private static final String REMOVE_BULK_PRICING = "__REMOVE_BULK_PRICING__";
|
||||||
|
|
||||||
private static final ImmutableMap<String, TokenBehavior> STATIC_TOKEN_BEHAVIORS =
|
private static final ImmutableMap<String, TokenBehavior> STATIC_TOKEN_BEHAVIORS =
|
||||||
ImmutableMap.of(REMOVE_DOMAIN, TokenBehavior.REMOVE_DOMAIN);
|
ImmutableMap.of(REMOVE_BULK_PRICING, TokenBehavior.REMOVE_BULK_PRICING);
|
||||||
|
|
||||||
// Promotions should only move forward, and ENDED / CANCELLED are terminal states.
|
// Promotions should only move forward, and ENDED / CANCELLED are terminal states.
|
||||||
private static final ImmutableMultimap<TokenStatus, TokenStatus> VALID_TOKEN_STATUS_TRANSITIONS =
|
private static final ImmutableMultimap<TokenStatus, TokenStatus> VALID_TOKEN_STATUS_TRANSITIONS =
|
||||||
|
@ -91,10 +91,10 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
|
|
||||||
private static final ImmutableMap<String, AllocationToken> BEHAVIORAL_TOKENS =
|
private static final ImmutableMap<String, AllocationToken> BEHAVIORAL_TOKENS =
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
REMOVE_DOMAIN,
|
REMOVE_BULK_PRICING,
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
.setTokenType(TokenType.UNLIMITED_USE)
|
.setTokenType(TokenType.UNLIMITED_USE)
|
||||||
.setToken(REMOVE_DOMAIN)
|
.setToken(REMOVE_BULK_PRICING)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
public static Optional<AllocationToken> maybeGetStaticTokenInstance(String name) {
|
public static Optional<AllocationToken> maybeGetStaticTokenInstance(String name) {
|
||||||
|
@ -142,10 +142,10 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
/** No special behavior */
|
/** No special behavior */
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
/**
|
/**
|
||||||
* REMOVE_DOMAIN triggers domain removal from a bulk pricing package, bypasses DEFAULT token
|
* REMOVE_BULK_PRICING triggers domain removal from a bulk pricing package, bypasses DEFAULT
|
||||||
* validations.
|
* token validations.
|
||||||
*/
|
*/
|
||||||
REMOVE_DOMAIN
|
REMOVE_BULK_PRICING
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The status of this token with regard to any potential promotion. */
|
/** The status of this token with regard to any potential promotion. */
|
||||||
|
|
|
@ -77,8 +77,8 @@ import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTok
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AlreadyRedeemedAllocationTokenException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AlreadyRedeemedAllocationTokenException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnBulkPricingDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveBulkPricingTokenOnBulkPricingDomainException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonBulkPricingDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveBulkPricingTokenOnNonBulkPricingDomainException;
|
||||||
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
|
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
|
||||||
import google.registry.model.billing.BillingBase.Flag;
|
import google.registry.model.billing.BillingBase.Flag;
|
||||||
import google.registry.model.billing.BillingBase.Reason;
|
import google.registry.model.billing.BillingBase.Reason;
|
||||||
|
@ -1276,12 +1276,13 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "token"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "token"));
|
||||||
|
|
||||||
EppException thrown =
|
EppException thrown =
|
||||||
assertThrows(MissingRemoveDomainTokenOnBulkPricingDomainException.class, this::runFlow);
|
assertThrows(
|
||||||
|
MissingRemoveBulkPricingTokenOnBulkPricingDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFailsToRenewBulkPricingDomainNoRemoveDomainToken() throws Exception {
|
void testFailsToRenewBulkPricingDomainNoRemoveBulkPricingToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1299,25 +1300,26 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5"));
|
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5"));
|
||||||
|
|
||||||
EppException thrown =
|
EppException thrown =
|
||||||
assertThrows(MissingRemoveDomainTokenOnBulkPricingDomainException.class, this::runFlow);
|
assertThrows(
|
||||||
|
MissingRemoveBulkPricingTokenOnBulkPricingDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFailsToRenewNonBulkPricingDomainWithRemoveDomainToken() throws Exception {
|
void testFailsToRenewNonBulkPricingDomainWithRemoveBulkPricingToken() throws Exception {
|
||||||
persistDomain();
|
persistDomain();
|
||||||
|
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"domain_renew_allocationtoken.xml",
|
"domain_renew_allocationtoken.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVE_BULK_PRICING__"));
|
||||||
|
|
||||||
EppException thrown =
|
EppException thrown =
|
||||||
assertThrows(RemoveDomainTokenOnNonBulkPricingDomainException.class, this::runFlow);
|
assertThrows(RemoveBulkPricingTokenOnNonBulkPricingDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSuccesfullyAppliesRemoveDomainToken() throws Exception {
|
void testSuccesfullyAppliesRemoveBulkPricingToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1333,7 +1335,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build());
|
reloadResourceByForeignKey().asBuilder().setCurrentBulkToken(token.createVKey()).build());
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"domain_renew_allocationtoken.xml",
|
"domain_renew_allocationtoken.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVE_BULK_PRICING__"));
|
||||||
|
|
||||||
doSuccessfulTest(
|
doSuccessfulTest(
|
||||||
"domain_renew_response.xml",
|
"domain_renew_response.xml",
|
||||||
|
@ -1347,7 +1349,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDryRunRemoveDomainToken() throws Exception {
|
void testDryRunRemoveBulkPricingToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1364,7 +1366,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
|
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"domain_renew_allocationtoken.xml",
|
"domain_renew_allocationtoken.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVE_BULK_PRICING__"));
|
||||||
|
|
||||||
dryRunFlowAssertResponse(
|
dryRunFlowAssertResponse(
|
||||||
loadFile(
|
loadFile(
|
||||||
|
|
|
@ -499,8 +499,10 @@ comes in at the exact millisecond that the domain would have expired.
|
||||||
* Resource status prohibits this operation.
|
* Resource status prohibits this operation.
|
||||||
* The allocation token is not currently valid.
|
* The allocation token is not currently valid.
|
||||||
* 2305
|
* 2305
|
||||||
* The __REMOVEDOMAIN__ token is missing on a bulk pricing domain command
|
* The __REMOVE_BULK_PRICING__ token is missing on a bulk pricing domain
|
||||||
* The __REMOVEDOMAIN__ token is not allowed on non bulk pricing domains
|
command
|
||||||
|
* The __REMOVE_BULK_PRICING__ token is not allowed on non bulk pricing
|
||||||
|
domains
|
||||||
* The allocation token is not valid for this domain.
|
* The allocation token is not valid for this domain.
|
||||||
* The allocation token is not valid for this registrar.
|
* The allocation token is not valid for this registrar.
|
||||||
* The allocation token is not valid for this TLD.
|
* The allocation token is not valid for this TLD.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue