mirror of
https://github.com/google/nomulus.git
synced 2025-08-13 13:09:37 +02:00
Add tool changes to modify allowedEppActions on allocation tokens (#1970)
* Add tool changes to modify allowedEppActions on allocation tokens * Change enum value error message * Remove unnecessary variable * Prevent UNKNOWN command * Check command name instead of string
This commit is contained in:
parent
a549d537db
commit
fba137f1bb
5 changed files with 106 additions and 2 deletions
|
@ -35,6 +35,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Files;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
|
@ -136,6 +137,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
"--type", "UNLIMITED_USE",
|
||||
"--allowed_client_ids", "TheRegistrar,NewRegistrar",
|
||||
"--allowed_tlds", "tld,example",
|
||||
"--allowed_epp_actions", "CREATE,RENEW",
|
||||
"--discount_fraction", "0.5",
|
||||
"--discount_premiums", "true",
|
||||
"--discount_years", "6",
|
||||
|
@ -148,6 +150,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
.setTokenType(UNLIMITED_USE)
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar", "NewRegistrar"))
|
||||
.setAllowedTlds(ImmutableSet.of("tld", "example"))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountPremiums(true)
|
||||
.setDiscountYears(6)
|
||||
|
|
|
@ -36,6 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.RegistrationBehavior;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
|
@ -80,6 +81,57 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
|
|||
assertThat(reloadResource(token).getAllowedRegistrarIds()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateEppActions_setEppActions() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo().setAllowedEppActions(ImmutableSet.of(CommandName.CREATE)).build());
|
||||
runCommandForced("--prefix", "token", "--allowed_epp_actions", "RENEW,RESTORE");
|
||||
assertThat(reloadResource(token).getAllowedEppActions())
|
||||
.containsExactly(CommandName.RENEW, CommandName.RESTORE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateEppActions_clearEppActions() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo()
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||
.build());
|
||||
runCommandForced("--prefix", "token", "--allowed_epp_actions", "");
|
||||
assertThat(reloadResource(token).getAllowedEppActions()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateEppActions_invalidEppAction() throws Exception {
|
||||
persistResource(
|
||||
builderWithPromo().setAllowedEppActions(ImmutableSet.of(CommandName.CREATE)).build());
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--prefix", "token", "--allowed_epp_actions", "FAKE"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Invalid EPP action name. Valid actions are CREATE, RENEW, TRANSFER, RESTORE, and"
|
||||
+ " UPDATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateEppActions_unknownEppAction() throws Exception {
|
||||
persistResource(
|
||||
builderWithPromo().setAllowedEppActions(ImmutableSet.of(CommandName.CREATE)).build());
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--prefix", "token", "--allowed_epp_actions", "UNKNOWN"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Invalid EPP action name. Valid actions are CREATE, RENEW, TRANSFER, RESTORE, and"
|
||||
+ " UPDATE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateDiscountFraction() throws Exception {
|
||||
AllocationToken token = persistResource(builderWithPromo().setDiscountFraction(0.5).build());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue