diff --git a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java index bc60dd0eb..abc8e6851 100644 --- a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java +++ b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java @@ -300,6 +300,9 @@ public class AllocationToken extends BackupGroupRoot implements Buildable { !getInstance().tokenType.equals(TokenType.PACKAGE) || getInstance().renewalPriceBehavior.equals(RenewalPriceBehavior.SPECIFIED), "Package tokens must have renewalPriceBehavior set to SPECIFIED"); + checkArgument( + !getInstance().tokenType.equals(TokenType.PACKAGE) || !getInstance().discountPremiums, + "Package tokens cannot discount premium names"); checkArgument( getInstance().domainName == null || TokenType.SINGLE_USE.equals(getInstance().tokenType), "Domain name can only be specified for SINGLE_USE tokens"); diff --git a/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java b/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java index d89d89a7b..b863edd33 100644 --- a/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java +++ b/core/src/test/java/google/registry/model/domain/token/AllocationTokenTest.java @@ -228,6 +228,18 @@ public class AllocationTokenTest extends EntityTestCase { .isEqualTo("Package tokens must have renewalPriceBehavior set to SPECIFIED"); } + @Test + void testFail_packageTokenDiscountPremium() { + AllocationToken.Builder builder = + new AllocationToken.Builder() + .setToken("abc123") + .setTokenType(TokenType.PACKAGE) + .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) + .setDiscountPremiums(true); + IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, builder::build); + assertThat(thrown).hasMessageThat().isEqualTo("Package tokens cannot discount premium names"); + } + @Test void testBuild_DomainNameWithLessThanTwoParts() { IllegalArgumentException thrown =