mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Require token transition schedules for default tokens (#2005)
This commit is contained in:
parent
2c258cd1bd
commit
d4a91ce65a
2 changed files with 15 additions and 0 deletions
|
@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.common.collect.Sets.difference;
|
import static com.google.common.collect.Sets.difference;
|
||||||
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT;
|
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT;
|
||||||
|
import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO;
|
||||||
import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE;
|
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.SINGLE_USE;
|
||||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||||
|
@ -259,6 +260,10 @@ class GenerateAllocationTokensCommand implements Command {
|
||||||
!(UNLIMITED_USE.equals(tokenType) && CollectionUtils.isNullOrEmpty(tokenStatusTransitions)),
|
!(UNLIMITED_USE.equals(tokenType) && CollectionUtils.isNullOrEmpty(tokenStatusTransitions)),
|
||||||
"For UNLIMITED_USE tokens, must specify --token_status_transitions");
|
"For UNLIMITED_USE tokens, must specify --token_status_transitions");
|
||||||
|
|
||||||
|
checkArgument(
|
||||||
|
!(DEFAULT_PROMO.equals(tokenType) && CollectionUtils.isNullOrEmpty(tokenStatusTransitions)),
|
||||||
|
"For DEFAULT_PROMO tokens, must specify --token_status_transitions");
|
||||||
|
|
||||||
// A list consisting solely of the empty string means user error when formatting parameters
|
// A list consisting solely of the empty string means user error when formatting parameters
|
||||||
checkArgument(
|
checkArgument(
|
||||||
!ImmutableList.of("").equals(allowedClientIds),
|
!ImmutableList.of("").equals(allowedClientIds),
|
||||||
|
|
|
@ -440,6 +440,16 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
||||||
.isEqualTo("For UNLIMITED_USE tokens, must specify --token_status_transitions");
|
.isEqualTo("For UNLIMITED_USE tokens, must specify --token_status_transitions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFailure_defaultPromoMustHaveTransitions() {
|
||||||
|
assertThat(
|
||||||
|
assertThrows(
|
||||||
|
IllegalArgumentException.class,
|
||||||
|
() -> runCommand("--number", "999", "--type", "DEFAULT_PROMO")))
|
||||||
|
.hasMessageThat()
|
||||||
|
.isEqualTo("For DEFAULT_PROMO tokens, must specify --token_status_transitions");
|
||||||
|
}
|
||||||
|
|
||||||
private AllocationToken createToken(
|
private AllocationToken createToken(
|
||||||
String token,
|
String token,
|
||||||
@Nullable HistoryEntryId redemptionHistoryEntryId,
|
@Nullable HistoryEntryId redemptionHistoryEntryId,
|
||||||
|
|
Loading…
Add table
Reference in a new issue