mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Change static __REMOVEPACKAGE__ token to __REMOVEDOMAIN__ token (#2090)
* Change static __REMOVEPACKAGE__ token to __REMOVEDOMAIN__ token * FIx some references * Fix variable name * Update docs
This commit is contained in:
parent
733e9a4a6a
commit
6ea548a35d
5 changed files with 39 additions and 39 deletions
|
@ -53,6 +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.MissingRemoveDomainTokenOnPackageDomainException;
|
||||||
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonPackageDomainException;
|
||||||
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;
|
||||||
|
@ -119,10 +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
|
* @error {@link MissingRemoveDomainTokenOnPackageDomainException}
|
||||||
* google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemovePackageTokenOnPackageDomainException}
|
* @error {@link RemoveDomainTokenOnNonPackageDomainException}
|
||||||
* @error {@link
|
|
||||||
* google.registry.flows.domain.token.AllocationTokenFlowUtils.RemovePackageTokenOnNonPackageDomainException}
|
|
||||||
* @error {@link
|
* @error {@link
|
||||||
* google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForDomainException}
|
* google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForDomainException}
|
||||||
* @error {@link
|
* @error {@link
|
||||||
|
|
|
@ -243,21 +243,21 @@ public class AllocationTokenFlowUtils {
|
||||||
Domain domain, Optional<AllocationToken> allocationToken) throws EppException {
|
Domain domain, Optional<AllocationToken> allocationToken) throws EppException {
|
||||||
|
|
||||||
boolean domainHasPackageToken = domain.getCurrentPackageToken().isPresent();
|
boolean domainHasPackageToken = domain.getCurrentPackageToken().isPresent();
|
||||||
boolean hasRemovePackageToken =
|
boolean hasRemoveDomainToken =
|
||||||
allocationToken.isPresent()
|
allocationToken.isPresent()
|
||||||
&& TokenBehavior.REMOVE_PACKAGE.equals(allocationToken.get().getTokenBehavior());
|
&& TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior());
|
||||||
|
|
||||||
if (hasRemovePackageToken && !domainHasPackageToken) {
|
if (hasRemoveDomainToken && !domainHasPackageToken) {
|
||||||
throw new RemovePackageTokenOnNonPackageDomainException();
|
throw new RemoveDomainTokenOnNonPackageDomainException();
|
||||||
} else if (!hasRemovePackageToken && domainHasPackageToken) {
|
} else if (!hasRemoveDomainToken && domainHasPackageToken) {
|
||||||
throw new MissingRemovePackageTokenOnPackageDomainException();
|
throw new MissingRemoveDomainTokenOnPackageDomainException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Domain maybeApplyPackageRemovalToken(
|
public static Domain maybeApplyPackageRemovalToken(
|
||||||
Domain domain, Optional<AllocationToken> allocationToken) {
|
Domain domain, Optional<AllocationToken> allocationToken) {
|
||||||
if (!allocationToken.isPresent()
|
if (!allocationToken.isPresent()
|
||||||
|| !TokenBehavior.REMOVE_PACKAGE.equals(allocationToken.get().getTokenBehavior())) {
|
|| !TokenBehavior.REMOVE_DOMAIN.equals(allocationToken.get().getTokenBehavior())) {
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,19 +338,19 @@ public class AllocationTokenFlowUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The __REMOVEPACKAGE__ token is missing on a package domain command */
|
/** The __REMOVEDOMAIN__ token is missing on a package domain command */
|
||||||
public static class MissingRemovePackageTokenOnPackageDomainException
|
public static class MissingRemoveDomainTokenOnPackageDomainException
|
||||||
extends AssociationProhibitsOperationException {
|
extends AssociationProhibitsOperationException {
|
||||||
MissingRemovePackageTokenOnPackageDomainException() {
|
MissingRemoveDomainTokenOnPackageDomainException() {
|
||||||
super("Domains that are inside packages cannot be explicitly renewed or transferred");
|
super("Domains that are inside packages cannot be explicitly renewed or transferred");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The __REMOVEPACKAGE__ token is not allowed on non package domains */
|
/** The __REMOVEDOMAIN__ token is not allowed on non package domains */
|
||||||
public static class RemovePackageTokenOnNonPackageDomainException
|
public static class RemoveDomainTokenOnNonPackageDomainException
|
||||||
extends AssociationProhibitsOperationException {
|
extends AssociationProhibitsOperationException {
|
||||||
RemovePackageTokenOnNonPackageDomainException() {
|
RemoveDomainTokenOnNonPackageDomainException() {
|
||||||
super("__REMOVEPACKAGE__ token is not allowed on non package domains");
|
super("__REMOVEDOMAIN__ token is not allowed on non package 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_PACKAGE = "__REMOVEPACKAGE__";
|
private static final String REMOVE_DOMAIN = "__REMOVEDOMAIN__";
|
||||||
|
|
||||||
private static final ImmutableMap<String, TokenBehavior> STATIC_TOKEN_BEHAVIORS =
|
private static final ImmutableMap<String, TokenBehavior> STATIC_TOKEN_BEHAVIORS =
|
||||||
ImmutableMap.of(REMOVE_PACKAGE, TokenBehavior.REMOVE_PACKAGE);
|
ImmutableMap.of(REMOVE_DOMAIN, TokenBehavior.REMOVE_DOMAIN);
|
||||||
|
|
||||||
// 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_PACKAGE,
|
REMOVE_DOMAIN,
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
.setTokenType(TokenType.UNLIMITED_USE)
|
.setTokenType(TokenType.UNLIMITED_USE)
|
||||||
.setToken(REMOVE_PACKAGE)
|
.setToken(REMOVE_DOMAIN)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
public static Optional<AllocationToken> maybeGetStaticTokenInstance(String name) {
|
public static Optional<AllocationToken> maybeGetStaticTokenInstance(String name) {
|
||||||
|
@ -137,10 +137,10 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||||
/** No special behavior */
|
/** No special behavior */
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
/**
|
/**
|
||||||
* REMOVE_PACKAGE triggers domain removal from promotional package, bypasses DEFAULT token
|
* REMOVE_DOMAIN triggers domain removal from promotional bulk (package) pricing, bypasses
|
||||||
* validations.
|
* DEFAULT token validations.
|
||||||
*/
|
*/
|
||||||
REMOVE_PACKAGE
|
REMOVE_DOMAIN
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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.MissingRemovePackageTokenOnPackageDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemoveDomainTokenOnPackageDomainException;
|
||||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemovePackageTokenOnNonPackageDomainException;
|
import google.registry.flows.domain.token.AllocationTokenFlowUtils.RemoveDomainTokenOnNonPackageDomainException;
|
||||||
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;
|
||||||
|
@ -1271,12 +1271,12 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "abc123"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "abc123"));
|
||||||
|
|
||||||
EppException thrown =
|
EppException thrown =
|
||||||
assertThrows(MissingRemovePackageTokenOnPackageDomainException.class, this::runFlow);
|
assertThrows(MissingRemoveDomainTokenOnPackageDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFailsToRenewPackageDomainNoRemovePackageToken() throws Exception {
|
void testFailsToRenewPackageDomainNoRemoveDomainToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1296,25 +1296,25 @@ 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(MissingRemovePackageTokenOnPackageDomainException.class, this::runFlow);
|
assertThrows(MissingRemoveDomainTokenOnPackageDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFailsToRenewNonPackageDomainWithRemovePackageToken() throws Exception {
|
void testFailsToRenewNonPackageDomainWithRemoveDomainToken() throws Exception {
|
||||||
persistDomain();
|
persistDomain();
|
||||||
|
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"domain_renew_allocationtoken.xml",
|
"domain_renew_allocationtoken.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEPACKAGE__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
||||||
|
|
||||||
EppException thrown =
|
EppException thrown =
|
||||||
assertThrows(RemovePackageTokenOnNonPackageDomainException.class, this::runFlow);
|
assertThrows(RemoveDomainTokenOnNonPackageDomainException.class, this::runFlow);
|
||||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSuccesfullyAppliesRemovePackageToken() throws Exception {
|
void testSuccesfullyAppliesRemoveDomainToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1332,7 +1332,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
.build());
|
.build());
|
||||||
setEppInput(
|
setEppInput(
|
||||||
"domain_renew_allocationtoken.xml",
|
"domain_renew_allocationtoken.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEPACKAGE__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
||||||
|
|
||||||
doSuccessfulTest(
|
doSuccessfulTest(
|
||||||
"domain_renew_response.xml",
|
"domain_renew_response.xml",
|
||||||
|
@ -1346,7 +1346,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDryRunRemovePackageToken() throws Exception {
|
void testDryRunRemoveDomainToken() throws Exception {
|
||||||
AllocationToken token =
|
AllocationToken token =
|
||||||
persistResource(
|
persistResource(
|
||||||
new AllocationToken.Builder()
|
new AllocationToken.Builder()
|
||||||
|
@ -1365,7 +1365,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", "__REMOVEPACKAGE__"));
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "__REMOVEDOMAIN__"));
|
||||||
|
|
||||||
dryRunFlowAssertResponse(
|
dryRunFlowAssertResponse(
|
||||||
loadFile(
|
loadFile(
|
||||||
|
|
|
@ -499,8 +499,8 @@ 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 __REMOVEPACKAGE__ token is missing on a package domain command
|
* The __REMOVEDOMAIN__ token is missing on a package domain command
|
||||||
* The __REMOVEPACKAGE__ token is not allowed on non package domains
|
* The __REMOVEDOMAIN__ token is not allowed on non package 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