Allow square bracket expansion when specifying nameservers

I'm finally fed up enough with all the nameserver changes we've had to make on our
self-allocated domains to improve the command.  Now you can simply run:

$ nomulus ... update_domain ... -n ns[1-4].foo.bar

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205282317
This commit is contained in:
mcilwain 2018-07-19 12:27:07 -07:00 committed by jianglai
parent 4b99fae1dd
commit a2fe058865
9 changed files with 305 additions and 32 deletions

View file

@ -47,6 +47,22 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
eppVerifier.verifySent("domain_create_complete.xml");
}
@Test
public void testSuccess_completeWithSquareBrackets() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"--period=1",
"--nameservers=ns[1-4].zdns.google",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--password=2fooBAR",
"--ds_records=1 2 3 abcd,4 5 6 EF01",
"--ds_records=60485 5 2 D4B7D520E7BB5F0F67674A0CCEB1E3E0614B93C4F9E99B8383F6A1E4469DA50A",
"example.tld");
eppVerifier.verifySent("domain_create_complete.xml");
}
@Test
public void testSuccess_minimal() throws Exception {
// Test that each optional field can be omitted. Also tests the auto-gen password.
@ -216,6 +232,22 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
assertThat(thrown).hasMessageThat().contains("There can be at most 13 nameservers");
}
@Test
public void testFailure_tooManyNameServers_usingSquareBracketRange() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() ->
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--nameservers=ns[1-14].zdns.google",
"example.tld"));
assertThat(thrown).hasMessageThat().contains("There can be at most 13 nameservers");
}
@Test
public void testFailure_badPeriod() {
ParameterException thrown =