From 8eff021de245e0a332155c342f8add2fc99c0ada Mon Sep 17 00:00:00 2001 From: sarahcaseybot Date: Tue, 11 Oct 2022 11:37:52 -0400 Subject: [PATCH] Remove allocation token check for transfering package domains (#1814) --- .../domain/DomainTransferRequestFlow.java | 8 -- .../domain/DomainTransferRequestFlowTest.java | 85 ------------------- docs/flows.md | 1 - 3 files changed, 94 deletions(-) diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java index b330ac9ef..ae89c0fea 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -32,8 +32,6 @@ import static google.registry.flows.domain.DomainTransferUtils.createLosingTrans import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData; import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse; import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities; -import static google.registry.flows.domain.token.AllocationTokenFlowUtils.maybeApplyPackageRemovalToken; -import static google.registry.flows.domain.token.AllocationTokenFlowUtils.verifyTokenAllowedOnDomain; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -135,8 +133,6 @@ import org.joda.time.DateTime; * google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException} * @error {@link * google.registry.flows.domain.token.AllocationTokenFlowUtils.AlreadyRedeemedAllocationTokenException} - * @error {@link - * google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemovePackageTokenOnPackageDomainException} */ @ReportingSpec(ActivityReportField.DOMAIN_TRANSFER_REQUEST) public final class DomainTransferRequestFlow implements TransactionalFlow { @@ -189,9 +185,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { : ((Transfer) resourceCommand).getPeriod(); verifyTransferAllowed(existingDomain, period, now, superuserExtension, allocationToken); - // If client passed an applicable static token this updates the domain - existingDomain = maybeApplyPackageRemovalToken(existingDomain, allocationToken); - String tld = existingDomain.getTld(); Registry registry = Registry.get(tld); // An optional extension from the client specifying what they think the transfer should cost. @@ -307,7 +300,6 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { Optional allocationToken) throws EppException { verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES); - verifyTokenAllowedOnDomain(existingDomain, allocationToken); if (!isSuperuser) { verifyAuthInfoPresentForResourceTransfer(authInfo); verifyAuthInfo(authInfo.get(), existingDomain); diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java index 4c631e804..6f24c9423 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -21,9 +21,6 @@ import static com.google.common.truth.Truth8.assertThat; import static google.registry.batch.AsyncTaskEnqueuer.PARAM_REQUESTED_TIME; import static google.registry.batch.AsyncTaskEnqueuer.PARAM_RESOURCE_KEY; import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS; -import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT; -import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SPECIFIED; -import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; @@ -64,7 +61,6 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.collect.Streams; -import com.google.common.truth.Truth8; import com.googlecode.objectify.Key; import google.registry.batch.ResaveEntityAction; import google.registry.flows.EppException; @@ -89,7 +85,6 @@ import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTok import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException; import google.registry.flows.domain.token.AllocationTokenFlowUtils.AlreadyRedeemedAllocationTokenException; import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException; -import google.registry.flows.domain.token.AllocationTokenFlowUtils.MissingRemovePackageTokenOnPackageDomainException; import google.registry.flows.exceptions.AlreadyPendingTransferException; import google.registry.flows.exceptions.InvalidTransferPeriodValueException; import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException; @@ -1812,84 +1807,4 @@ class DomainTransferRequestFlowTest assertThrows(AlreadyRedeemedAllocationTokenException.class, this::runFlow); assertAboutEppExceptions().that(thrown).marshalsToXml(); } - - @Test - void testFailsPackageDomainInvalidAllocationToken() throws Exception { - AllocationToken token = - persistResource( - new AllocationToken.Builder() - .setToken("abc123") - .setTokenType(PACKAGE) - .setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar")) - .setAllowedTlds(ImmutableSet.of("example", "tld")) - .setRenewalPriceBehavior(SPECIFIED) - .build()); - setupDomain("example", "tld"); - persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); - - setEppInput("domain_transfer_request_allocation_token.xml", ImmutableMap.of("TOKEN", "abc123")); - assertThrows(MissingRemovePackageTokenOnPackageDomainException.class, this::runFlow); - } - - @Test - void testFailsToTransferPackageDomainNoRemovePackageToken() throws Exception { - AllocationToken token = - persistResource( - new AllocationToken.Builder() - .setToken("abc123") - .setTokenType(PACKAGE) - .setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar")) - .setAllowedTlds(ImmutableSet.of("example", "tld")) - .setRenewalPriceBehavior(SPECIFIED) - .build()); - setupDomain("example", "tld"); - persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); - - setEppInput("domain_transfer_request.xml"); - assertThrows(MissingRemovePackageTokenOnPackageDomainException.class, this::runFlow); - } - - @Test - void testSuccesfullyAppliesRemovePackageToken() throws Exception { - setupDomain("example", "tld"); - AllocationToken token = - persistResource( - new AllocationToken.Builder() - .setToken("abc123") - .setTokenType(PACKAGE) - .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) - .setAllowedTlds(ImmutableSet.of("tld")) - .setRenewalPriceBehavior(SPECIFIED) - .build()); - domain = loadByEntity(domain); - persistResource( - loadByKey(domain.getAutorenewBillingEvent()) - .asBuilder() - .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) - .setRenewalPrice(Money.of(USD, new BigDecimal("10.00"))) - .build()); - persistResource( - reloadResourceByForeignKey() - .asBuilder() - .setCurrentPackageToken(token.createVKey()) - .build()); - - doSuccessfulTest( - "domain_transfer_request_allocation_token.xml", - "domain_transfer_request_response.xml", - ImmutableMap.of("TOKEN", "__REMOVEPACKAGE__")); - Domain domain = reloadResourceByForeignKey(); - Truth8.assertThat(domain.getCurrentPackageToken()).isEmpty(); - RenewalPriceBehavior priceBehavior = - loadByKey(domain.getAutorenewBillingEvent()).getRenewalPriceBehavior(); - assertThat(priceBehavior).isEqualTo(DEFAULT); - } } diff --git a/docs/flows.md b/docs/flows.md index d0c02fc91..1ea25fff1 100644 --- a/docs/flows.md +++ b/docs/flows.md @@ -754,7 +754,6 @@ new ones with the correct approval time). * The allocation token is not valid for this registrar. * The allocation token is not valid for this TLD. * The allocation token was already redeemed. - * The __REMOVEPACKAGE__ token is missing on a package domain command * 2306 * Domain transfer period must be one year. * Domain transfer period must be zero or one year when using the superuser