mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Don't allow package tokens to discount premium names (#1804)
This commit is contained in:
parent
5b2c1ec655
commit
63b218a0b8
2 changed files with 15 additions and 0 deletions
|
@ -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");
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Add table
Reference in a new issue