Don't delete or "redeem" unlimited use AllocationTokens

We haven't started dealing with timing or discounts yet, but unlimited use tokens should actually be unlimited use

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=243318266
This commit is contained in:
gbrodman 2019-04-12 13:05:06 -07:00 committed by Ben McIlwain
parent 416a39b003
commit d1e3194fce
5 changed files with 44 additions and 3 deletions

View file

@ -22,6 +22,7 @@ import static google.registry.model.billing.BillingEvent.Flag.ANCHOR_TENANT;
import static google.registry.model.billing.BillingEvent.Flag.SUNRISE;
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
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.eppcommon.StatusValue.OK;
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
import static google.registry.model.eppcommon.StatusValue.SERVER_HOLD;
@ -452,6 +453,20 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.isEqualTo(Key.create(historyEntry));
}
@Test
public void testSuccess_validAllocationToken_multiUse() throws Exception {
setEppInput("domain_create_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistContactsAndHosts();
persistResource(
new AllocationToken.Builder().setTokenType(UNLIMITED_USE).setToken("abc123").build());
clock.advanceOneMilli();
doSuccessfulTest();
clock.advanceOneMilli();
setEppInput("domain_create_allocationtoken.xml", ImmutableMap.of("DOMAIN", "otherexample.tld"));
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "otherexample.tld")));
}
@Test
public void testSuccess_multipartTld() throws Exception {
createTld("foo.tld");

View file

@ -23,6 +23,7 @@ import static google.registry.testing.JUnitBackports.assertThrows;
import com.beust.jcommander.ParameterException;
import com.googlecode.objectify.Key;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenType;
import google.registry.model.reporting.HistoryEntry;
import java.util.Collection;
import javax.annotation.Nullable;
@ -109,6 +110,18 @@ public class DeleteAllocationTokensCommandTest
.containsExactly(preRed1, preRed2, preDom2, othrRed, othrNot);
}
@Test
public void testSkipUnlimitedUseTokens() throws Exception {
AllocationToken unlimitedUseToken =
persistResource(
new AllocationToken.Builder()
.setToken("prefixasdfg897as")
.setTokenType(TokenType.UNLIMITED_USE)
.build());
runCommandForced("--prefix", "prefix");
assertThat(reloadTokens(unlimitedUseToken)).containsExactly(unlimitedUseToken);
}
@Test
public void test_batching() throws Exception {
for (int i = 0; i < 50; i++) {