mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Automatically refactor more exception testing to use new JUnit rules
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179072309
This commit is contained in:
parent
d5d29959b4
commit
9157930983
100 changed files with 3900 additions and 3192 deletions
|
@ -28,6 +28,7 @@ import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -131,20 +132,21 @@ public class AllocateDomainCommandTest extends CommandTestCase<AllocateDomainCom
|
|||
|
||||
@Test
|
||||
public void testFailure_notAsSuperuser() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--ids=1-TLD", "--force");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--ids=1-TLD", "--force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_forceAndDryRunIncompatible() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--ids=1-TLD", "--force", "--dry_run", "--superuser");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--ids=1-TLD", "--force", "--dry_run", "--superuser"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--ids=1-TLD", "--force", "--unrecognized=foo", "--superuser");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--ids=1-TLD", "--force", "--unrecognized=foo", "--superuser"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -28,9 +29,7 @@ import com.google.api.client.util.store.DataStore;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
|
@ -61,9 +60,6 @@ public class AuthModuleTest {
|
|||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void test_clientScopeQualifier() {
|
||||
AuthModule authModule = new AuthModule();
|
||||
|
@ -129,9 +125,8 @@ public class AuthModuleTest {
|
|||
|
||||
@Test
|
||||
public void test_provideCredential_notStored() {
|
||||
thrown.expect(AuthModule.LoginRequiredException.class);
|
||||
// Doing this without the mock setup should cause us to throw an exception because the
|
||||
// credential has not been stored.
|
||||
getCredential();
|
||||
assertThrows(AuthModule.LoginRequiredException.class, () -> getCredential());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.io.PrintStream;
|
|||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
@ -63,9 +62,6 @@ public abstract class CommandTestCase<C extends Command> {
|
|||
.withTaskQueue()
|
||||
.build();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmpDir = new TemporaryFolder();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.tools;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -83,43 +84,80 @@ public class CreateAnchorTenantCommandTest
|
|||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--tld=tld", "--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--tld=tld",
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--foo=bar", "--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--foo=bar",
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDomainName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingContact() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--domain_name=example.tld", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--domain_name=example.tld",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_notAsSuperuser() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import org.junit.Before;
|
||||
|
@ -58,30 +60,31 @@ public class CreateContactCommandTest extends EppToolCommandTestCase<CreateConta
|
|||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced();
|
||||
assertThrows(ParameterException.class, () -> runCommandForced());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyStreetLines() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--street=\"123 Example Dr.\"",
|
||||
"--street=\"Floor 3\"",
|
||||
"--street=\"Suite 100\"",
|
||||
"--street=\"Office 1\"");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--street=\"123 Example Dr.\"",
|
||||
"--street=\"Floor 3\"",
|
||||
"--street=\"Suite 100\"",
|
||||
"--street=\"Office 1\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badPhone() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--phone=3");
|
||||
assertThrows(
|
||||
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--phone=3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badFax() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--fax=3");
|
||||
assertThrows(
|
||||
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--fax=3"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -80,75 +81,96 @@ public class CreateCreditBalanceCommandTest extends CommandTestCase<CreateCredit
|
|||
|
||||
@Test
|
||||
public void testFailure_nonexistentParentRegistrar() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar FakeRegistrar not found");
|
||||
runCommandForced(
|
||||
"--registrar=FakeRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=FakeRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar FakeRegistrar not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonexistentCreditId() throws Exception {
|
||||
long badId = creditId + 1;
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("ID " + badId);
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + badId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + badId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("ID " + badId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeBalance() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("negative");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD -1\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD -1\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("negative");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noRegistrar() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--registrar");
|
||||
runCommandForced(
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--registrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noCreditId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--credit_id");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--credit_id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noBalance() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--balance");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--balance");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noEffectiveTime() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--effective_time");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\"");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--credit_id=" + creditId,
|
||||
"--balance=\"USD 100\""));
|
||||
assertThat(thrown).hasMessageThat().contains("--effective_time");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -93,104 +94,131 @@ public class CreateCreditCommandTest extends CommandTestCase<CreateCreditCommand
|
|||
|
||||
@Test
|
||||
public void testFailure_nonexistentParentRegistrar() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar FakeRegistrar not found");
|
||||
runCommandForced(
|
||||
"--registrar=FakeRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=FakeRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar FakeRegistrar not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonexistentTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("faketld");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=faketld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=faketld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("faketld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonexistentType() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Invalid value for --type");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=BADTYPE",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=BADTYPE",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid value for --type");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeBalance() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("negative");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD -1\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD -1\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("negative");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noRegistrar() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--registrar");
|
||||
runCommandForced(
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--registrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noType() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--type");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--type");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noTld() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--tld");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--balance=\"USD 100\"",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noBalance() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--balance");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--effective_time=2014-11-01T01:02:03Z");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--effective_time=2014-11-01T01:02:03Z"));
|
||||
assertThat(thrown).hasMessageThat().contains("--balance");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noEffectiveTime() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--effective_time");
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\"");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=TheRegistrar",
|
||||
"--type=PROMOTION",
|
||||
"--tld=tld",
|
||||
"--balance=\"USD 100\""));
|
||||
assertThat(thrown).hasMessageThat().contains("--effective_time");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import org.junit.Before;
|
||||
|
@ -69,86 +72,122 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
|
|||
|
||||
@Test
|
||||
public void testFailure_duplicateDomains() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Duplicate arguments found: \'example.tld\'");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"example.tld",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"example.tld",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("Duplicate arguments found: \'example.tld\'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDomain() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Main parameters are required");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech"));
|
||||
assertThat(thrown).hasMessageThat().contains("Main parameters are required");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--client");
|
||||
runCommandForced(
|
||||
"--admins=crr-admin", "--techs=crr-tech", "--registrant=crr-admin", "example.tld");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"--registrant=crr-admin",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("--client");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingRegistrant() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrant must be specified");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--admins=crr-admin", "--techs=crr-tech", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrant must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingAdmins() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("At least one admin must be specified");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--registrant=crr-admin", "--techs=crr-tech", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("At least one admin must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingTechs() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("At least one tech must be specified");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--registrant=crr-admin", "--admins=crr-admin", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("At least one tech must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyNameServers() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("There can be at most 13 nameservers");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"--nameservers=ns1.zdns.google,ns2.zdns.google,ns3.zdns.google,ns4.zdns.google,"
|
||||
+ "ns5.zdns.google,ns6.zdns.google,ns7.zdns.google,ns8.zdns.google,"
|
||||
+ "ns9.zdns.google,ns10.zdns.google,ns11.zdns.google,ns12.zdns.google,"
|
||||
+ "ns13.zdns.google,ns14.zdns.google",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"--nameservers=ns1.zdns.google,ns2.zdns.google,ns3.zdns.google,ns4.zdns.google,"
|
||||
+ "ns5.zdns.google,ns6.zdns.google,ns7.zdns.google,ns8.zdns.google,"
|
||||
+ "ns9.zdns.google,ns10.zdns.google,ns11.zdns.google,ns12.zdns.google,"
|
||||
+ "ns13.zdns.google,ns14.zdns.google",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("There can be at most 13 nameservers");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badPeriod() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--period");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"--period=x",
|
||||
"--domain=example.tld");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--admins=crr-admin",
|
||||
"--techs=crr-tech",
|
||||
"--period=x",
|
||||
"--domain=example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("--period");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
@ -43,18 +46,18 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
|
|||
|
||||
@Test
|
||||
public void testFailure_missingHost() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidIpAddress() throws Exception {
|
||||
createTld("tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("'a.b.c.d' is not an IP string literal.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--host=example.tld",
|
||||
"--addresses=a.b.c.d");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--host=example.tld", "--addresses=a.b.c.d"));
|
||||
assertThat(thrown).hasMessageThat().contains("'a.b.c.d' is not an IP string literal.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
@ -226,45 +227,69 @@ public class CreateLrpTokensCommandTest extends CommandTestCase<CreateLrpTokensC
|
|||
|
||||
@Test
|
||||
public void testFailure_missingAssigneeOrFile() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
|
||||
runCommand("--tlds=tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("--tlds=tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Exactly one of either assignee or filename must be specified.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bothAssigneeAndFile() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Exactly one of either assignee or filename must be specified.");
|
||||
runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath);
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--assignee=domain.tld", "--tlds=tld", "--input=" + assigneeFilePath));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Exactly one of either assignee or filename must be specified.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bothMetadataAndFile() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Metadata cannot be specified along with a filename.");
|
||||
runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--tlds=tld", "--input=" + assigneeFilePath, "--metadata=key=foo"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Metadata cannot be specified along with a filename.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bothAssigneeAndMetadataColumns() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Metadata columns cannot be specified along with an assignee.");
|
||||
runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--assignee=domain.tld", "--tlds=tld", "--metadata_columns=foo=1"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Metadata columns cannot be specified along with an assignee.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLDs do not exist: foo");
|
||||
runCommand("--assignee=domain.tld", "--tlds=foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--assignee=domain.tld", "--tlds=foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLDs do not exist: foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_oneAssignee_byFile_insufficientMetadata() throws Exception {
|
||||
Files.asCharSink(assigneeFile, UTF_8).write("domain.tld,foo");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Entry for domain.tld does not have a value for key2 (index 2)");
|
||||
runCommand("--input=" + assigneeFilePath, "--tlds=tld", "--metadata_columns=key=1,key2=2");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--input=" + assigneeFilePath,
|
||||
"--tlds=tld",
|
||||
"--metadata_columns=key=1,key2=2"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Entry for domain.tld does not have a value for key2 (index 2)");
|
||||
}
|
||||
|
||||
private void assertLrpTokens(LrpTokenEntity... expected) throws Exception {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
|
@ -50,17 +51,17 @@ public abstract class CreateOrUpdateReservedListCommandTestCase
|
|||
|
||||
@Test
|
||||
public void testFailure_fileDoesntExist() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced(
|
||||
"--name=xn--q9jyb4c-blah",
|
||||
"--input=" + reservedTermsPath + "-nonexistent");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--name=xn--q9jyb4c-blah", "--input=" + reservedTermsPath + "-nonexistent"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_fileDoesntParse() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced(
|
||||
"--name=xn--q9jyb4c-blork",
|
||||
"--input=" + invalidReservedTermsPath);
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--name=xn--q9jyb4c-blork", "--input=" + invalidReservedTermsPath));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.request.JsonResponse.JSON_SAFETY_PREFIX;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyMapOf;
|
||||
|
@ -92,16 +94,16 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
|||
any(byte[].class)))
|
||||
.thenReturn(
|
||||
JSON_SAFETY_PREFIX + "{\"status\":\"error\",\"error\":\"foo already exists\"}");
|
||||
thrown.expect(VerifyException.class);
|
||||
thrown.expectMessage("Server error:");
|
||||
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
||||
VerifyException thrown =
|
||||
expectThrows(
|
||||
VerifyException.class, () -> runCommandForced("-i=" + premiumTermsPath, "-n=foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("Server error:");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun_noInputFileSpecified_throwsException() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("The following option is required");
|
||||
runCommand();
|
||||
ParameterException thrown = expectThrows(ParameterException.class, () -> runCommand());
|
||||
assertThat(thrown).hasMessageThat().contains("The following option is required");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -110,8 +112,10 @@ public class CreatePremiumListCommandTest<C extends CreatePremiumListCommand>
|
|||
"tmp_file2",
|
||||
readResourceUtf8(
|
||||
CreatePremiumListCommandTest.class, "testdata/example_invalid_premium_terms.csv"));
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Could not parse line in premium list");
|
||||
runCommandForced("-i=" + premiumTermsPath, "-n=foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("-i=" + premiumTermsPath, "-n=foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("Could not parse line in premium list");
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
|
@ -54,9 +56,12 @@ public class CreateRegistrarGroupsCommandTest extends
|
|||
|
||||
@Test
|
||||
public void test_throwsExceptionForNonExistentRegistrar() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"Could not load registrar with id FakeRegistrarThatDefinitelyDoesNotExist");
|
||||
runCommandForced("FakeRegistrarThatDefinitelyDoesNotExist");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("FakeRegistrarThatDefinitelyDoesNotExist"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load registrar with id FakeRegistrarThatDefinitelyDoesNotExist");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED
|
|||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.tools.CreateReservedListCommand.INVALID_FORMAT_ERROR_MESSAGE;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -90,9 +91,11 @@ public class CreateReservedListCommandTest extends
|
|||
public void testFailure_reservedListWithThatNameAlreadyExists() throws Exception {
|
||||
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("A reserved list already exists by this name");
|
||||
runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath);
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--name=xn--q9jyb4c_foo", "--input=" + reservedTermsPath));
|
||||
assertThat(thrown).hasMessageThat().contains("A reserved list already exists by this name");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -78,16 +78,24 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_multipleArguments() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't create more than one TLD at a time");
|
||||
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c", "test");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c", "test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't create more than one TLD at a time");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_multipleDuplicateArguments() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Can't create more than one TLD at a time");
|
||||
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "test", "test");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "test", "test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Can't create more than one TLD at a time");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -303,13 +311,16 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidAddGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced(
|
||||
"--add_grace_period=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--add_grace_period=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -327,101 +338,131 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced(
|
||||
"--redemption_grace_period=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--redemption_grace_period=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidPendingDeleteLength() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced(
|
||||
"--pending_delete_length=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--pending_delete_length=5m",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidTldState() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Invalid value for --initial_tld_state parameter");
|
||||
runCommandForced(
|
||||
"--initial_tld_state=INVALID_STATE",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--initial_tld_state=INVALID_STATE",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid value for --initial_tld_state parameter");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bothTldStateFlags() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Don't pass both --initial_tld_state and --tld_state_transitions");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
now, now.plus(Duration.millis(1))),
|
||||
"--initial_tld_state=GENERAL_AVAILABILITY",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
now, now.plus(Duration.millis(1))),
|
||||
"--initial_tld_state=GENERAL_AVAILABILITY",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Don't pass both --initial_tld_state and --tld_state_transitions");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeInitialRenewBillingCost() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Renew billing cost cannot be negative");
|
||||
runCommandForced(
|
||||
"--initial_renew_billing_cost=USD -42",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--initial_renew_billing_cost=USD -42",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Renew billing cost cannot be negative");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidEapCurrency() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("All EAP fees must be in the registry's currency");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--eap_fee_schedule=\"%s=JPY 123456\"", START_OF_TIME.toString(DATETIME_FORMAT)),
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--eap_fee_schedule=\"%s=JPY 123456\"",
|
||||
START_OF_TIME.toString(DATETIME_FORMAT)),
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the registry's currency");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noTldName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Main parameters are required (\"Names of the TLDs\")");
|
||||
runCommandForced();
|
||||
ParameterException thrown = expectThrows(ParameterException.class, () -> runCommandForced());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Main parameters are required (\"Names of the TLDs\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noDnsWriter() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("At least one DNS writer must be specified");
|
||||
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C"));
|
||||
assertThat(thrown).hasMessageThat().contains("At least one DNS writer must be specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_alreadyExists() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("TLD 'xn--q9jyb4c' already exists");
|
||||
runCommandForced("--roid_suffix=NOTDUPE", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c");
|
||||
IllegalStateException thrown =
|
||||
expectThrows(
|
||||
IllegalStateException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--roid_suffix=NOTDUPE", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLD 'xn--q9jyb4c' already exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldStartsWithDigit() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLDs cannot begin with a number");
|
||||
runCommandForced("1foo", "--roid_suffix=1FOO", "--dns_writers=VoidDnsWriter");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("1foo", "--roid_suffix=1FOO", "--dns_writers=VoidDnsWriter"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLDs cannot begin with a number");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -556,43 +597,60 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The premium list 'phonies' doesn't exist");
|
||||
runCommandForced(
|
||||
"--premium_list=phonies",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--premium_list=phonies",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addLrpPeriod_backwardsInterval() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
|
||||
runCommandForced(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addLrpPeriod_badInterval() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--lrp_period=foobar not an ISO-8601 interval");
|
||||
runCommandForced(
|
||||
"--lrp_period=foobar",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--lrp_period=foobar",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("--lrp_period=foobar not an ISO-8601 interval");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_specifiedDnsWriters_dontExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid DNS writer name(s) specified: [Deadbeef, Invalid]");
|
||||
runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=Invalid,Deadbeef");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=Invalid,Deadbeef"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Invalid DNS writer name(s) specified: [Deadbeef, Invalid]");
|
||||
}
|
||||
|
||||
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -111,30 +112,34 @@ public class DeleteCreditCommandTest extends CommandTestCase<DeleteCreditCommand
|
|||
|
||||
@Test
|
||||
public void testFailure_nonexistentParentRegistrar() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar FakeRegistrar not found");
|
||||
runCommandForced("--registrar=FakeRegistrar", "--credit_id=" + creditAId);
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--registrar=FakeRegistrar", "--credit_id=" + creditAId));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar FakeRegistrar not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonexistentCreditId() throws Exception {
|
||||
long badId = creditAId + creditBId + 1;
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("ID " + badId);
|
||||
runCommandForced("--registrar=TheRegistrar", "--credit_id=" + badId);
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() -> runCommandForced("--registrar=TheRegistrar", "--credit_id=" + badId));
|
||||
assertThat(thrown).hasMessageThat().contains("ID " + badId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noRegistrar() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--registrar");
|
||||
runCommandForced("--credit_id=" + creditAId);
|
||||
ParameterException thrown =
|
||||
expectThrows(ParameterException.class, () -> runCommandForced("--credit_id=" + creditAId));
|
||||
assertThat(thrown).hasMessageThat().contains("--registrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noCreditId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--credit_id");
|
||||
runCommandForced("--registrar=TheRegistrar");
|
||||
ParameterException thrown =
|
||||
expectThrows(ParameterException.class, () -> runCommandForced("--registrar=TheRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().contains("--credit_id");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -57,33 +59,48 @@ public class DeleteDomainCommandTest extends EppToolCommandTestCase<DeleteDomain
|
|||
|
||||
@Test
|
||||
public void testFailure_noReason() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--domain_name=example.tld", "--force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--domain_name=example.tld", "--force", "--reason=Test");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--domain_name=example.tld", "--force", "--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDomainName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--client=NewRegistrar", "--force", "--reason=Test");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar", "--domain_name=example.tld", "--force", "--reason=Test", "--foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--force",
|
||||
"--reason=Test",
|
||||
"--foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar", "--domain_name=example.tld", "--force", "--reason=Test", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--force",
|
||||
"--reason=Test",
|
||||
"foo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -57,33 +59,48 @@ public class DeleteHostCommandTest extends EppToolCommandTestCase<DeleteHostComm
|
|||
|
||||
@Test
|
||||
public void testFailure_noReason() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--host=ns1.example.tld", "--force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--host=ns1.example.tld", "--force", "--reason=Test");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--host=ns1.example.tld", "--force", "--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingHostName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--client=NewRegistrar", "--force", "--reason=Test");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--force", "--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=Test", "--foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--host=ns1.example.tld",
|
||||
"--force",
|
||||
"--reason=Test",
|
||||
"--foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar", "--host=ns1.example.tld", "--force", "--reason=Test", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--host=ns1.example.tld",
|
||||
"--force",
|
||||
"--reason=Test",
|
||||
"foo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.loadPremiumListEntries;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
|
@ -48,9 +49,11 @@ public class DeletePremiumListCommandTest extends CommandTestCase<DeletePremiumL
|
|||
|
||||
@Test
|
||||
public void testFailure_whenPremiumListDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Cannot delete the premium list foo because it doesn't exist.");
|
||||
runCommandForced("--name=foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommandForced("--name=foo"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Cannot delete the premium list foo because it doesn't exist.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,6 +20,7 @@ import static com.google.common.truth.Truth8.assertThat;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
|
@ -47,9 +48,11 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
|
|||
public void testFailure_whenReservedListDoesNotExist() throws Exception {
|
||||
String expectedError =
|
||||
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(expectedError);
|
||||
runCommandForced("--name=doesntExistReservedList");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--name=doesntExistReservedList"));
|
||||
assertThat(thrown).hasMessageThat().contains(expectedError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,6 +18,7 @@ import static google.registry.testing.DatastoreHelper.allowRegistrarAccess;
|
|||
import static google.registry.testing.DatastoreHelper.newRegistry;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
|
@ -57,35 +58,30 @@ public class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
|||
runCommandForced("--tld=" + TLD_TEST);
|
||||
|
||||
Registry.get(TLD_REAL);
|
||||
thrown.expect(RegistryNotFoundException.class);
|
||||
Registry.get(TLD_TEST);
|
||||
assertThrows(RegistryNotFoundException.class, () -> Registry.get(TLD_TEST));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_whenTldDoesNotExist() throws Exception {
|
||||
thrown.expect(RegistryNotFoundException.class);
|
||||
runCommandForced("--tld=nonexistenttld");
|
||||
assertThrows(RegistryNotFoundException.class, () -> runCommandForced("--tld=nonexistenttld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_whenTldIsReal() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
runCommandForced("--tld=" + TLD_REAL);
|
||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_REAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_whenDomainsArePresent() throws Exception {
|
||||
persistDeletedDomain("domain." + TLD_TEST, DateTime.parse("2000-01-01TZ"));
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
runCommandForced("--tld=" + TLD_TEST);
|
||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_whenRegistrarLinksToTld() throws Exception {
|
||||
allowRegistrarAccess("TheRegistrar", TLD_TEST);
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
runCommandForced("--tld=" + TLD_TEST);
|
||||
assertThrows(IllegalStateException.class, () -> runCommandForced("--tld=" + TLD_TEST));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -38,41 +40,62 @@ public class DomainApplicationInfoCommandTest
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidPhase() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=landrise", "--id=123");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--phase=landrise",
|
||||
"--id=123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--domain_name=example.tld", "--phase=sunrush", "--id=123");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--domain_name=example.tld", "--phase=sunrush", "--id=123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingPhase() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--id=123");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--id=123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingApplicationId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=landrush");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--domain_name=example.tld", "--phase=landrush"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=landrush", "--id=123", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--phase=landrush",
|
||||
"--id=123",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld",
|
||||
"--phase=landrush", "--id=123", "--foo=bar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--phase=landrush",
|
||||
"--id=123",
|
||||
"--foo=bar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -59,19 +61,18 @@ public class DomainCheckClaimsCommandTest extends EppToolCommandTestCase<DomainC
|
|||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("example.tld");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_NoMainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -59,19 +61,18 @@ public class DomainCheckCommandTest extends EppToolCommandTestCase<DomainCheckCo
|
|||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("example.tld");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_NoMainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -59,19 +61,18 @@ public class DomainCheckFeeCommandTest extends EppToolCommandTestCase<DomainChec
|
|||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("example.tld");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_NoMainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar");
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "--unrecognized=foo", "example.tld"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import google.registry.tools.server.ToolsTestData;
|
||||
|
@ -71,8 +74,10 @@ public class EppToolCommandTest extends EppToolCommandTestCase<EppToolCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_nonexistentClientId() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("fakeclient");
|
||||
runCommandForced("--client=fakeclient", "fake-xml");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--client=fakeclient", "fake-xml"));
|
||||
assertThat(thrown).hasMessageThat().contains("fakeclient");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -77,19 +78,20 @@ public class ExecuteEppCommandTest extends EppToolCommandTestCase<ExecuteEppComm
|
|||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--force", "foo.xml");
|
||||
assertThrows(ParameterException.class, () -> runCommand("--force", "foo.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_forceAndDryRunIncompatible() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--client=NewRegistrar", "--force", "--dry_run", eppFile);
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--force", "--dry_run", eppFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--client=NewRegistrar", "--unrecognized=foo", "--force", "foo.xml");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "--force", "foo.xml"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.newContactResourceWithRoid
|
|||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.newSunriseApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -320,19 +321,16 @@ public class GenerateAuctionDataCommandTest extends CommandTestCase<GenerateAuct
|
|||
|
||||
@Test
|
||||
public void testFailure_missingTldName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyParameters() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("xn--q9jyb4c", "foobar");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c", "foobar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonexistentTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("foobarbaz");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("foobarbaz"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static google.registry.testing.DatastoreHelper.newHostResource;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -203,13 +204,11 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
|||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--tld=foobar");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--tld=foobar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingTldParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("");
|
||||
assertThrows(ParameterException.class, () -> runCommand(""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.appengine.api.taskqueue.QueueFactory.getQueue;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -51,89 +53,135 @@ public class GenerateEscrowDepositCommandTest
|
|||
|
||||
@Test
|
||||
public void testCommand_missingTld() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("The following option is required: -t, --tld");
|
||||
runCommand("--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand("--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("The following option is required: -t, --tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_emptyTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Null or empty TLD specified");
|
||||
runCommand("--tld=", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r 42",
|
||||
"-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Null or empty TLD specified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_invalidTld() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLDs do not exist: invalid");
|
||||
runCommand(
|
||||
"--tld=invalid", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42", "-o test");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=invalid",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r 42",
|
||||
"-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLDs do not exist: invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_missingWatermark() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("The following option is required: -w, --watermark");
|
||||
runCommand("--tld=tld", "--mode=full", "-r 42", "-o test");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--tld=tld", "--mode=full", "-r 42", "-o test"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("The following option is required: -w, --watermark");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_emptyWatermark() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"\"");
|
||||
runCommand("--tld=tld", "--watermark=", "--mode=full", "-r 42", "-o test");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--tld=tld", "--watermark=", "--mode=full", "-r 42", "-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_missingOutdir() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("The following option is required: -o, --outdir");
|
||||
runCommand("--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "-r 42"));
|
||||
assertThat(thrown).hasMessageThat().contains("The following option is required: -o, --outdir");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_emptyOutdir() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Output subdirectory must not be empty");
|
||||
runCommand(
|
||||
"--tld=tld", "--watermark=2017-01-01T00:00:00Z", "--mode=thin", "--outdir=", "-r 42");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"--outdir=",
|
||||
"-r 42"));
|
||||
assertThat(thrown).hasMessageThat().contains("Output subdirectory must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_invalidWatermark() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Each watermark date must be the start of a day");
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T10:00:00Z,2017-01-02T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r 42",
|
||||
"-o test");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T10:00:00Z,2017-01-02T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r 42",
|
||||
"-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Each watermark date must be the start of a day");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_invalidMode() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Invalid value for -m parameter. Allowed values:[FULL, THIN]");
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thing",
|
||||
"-r 42",
|
||||
"-o test");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thing",
|
||||
"-r 42",
|
||||
"-o test"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Invalid value for -m parameter. Allowed values:[FULL, THIN]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommand_invalidRevision() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Revision must be greater than or equal to zero");
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r -1",
|
||||
"-o test");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--tld=tld",
|
||||
"--watermark=2017-01-01T00:00:00Z",
|
||||
"--mode=thin",
|
||||
"-r -1",
|
||||
"-o test"));
|
||||
assertThat(thrown).hasMessageThat().contains("Revision must be greater than or equal to zero");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -87,8 +88,7 @@ public class GetApplicationCommandTest extends CommandTestCase<GetApplicationCom
|
|||
|
||||
@Test
|
||||
public void testFailure_noApplicationId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,10 +14,13 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -60,9 +63,9 @@ public class GetApplicationIdsCommandTest extends CommandTestCase<GetApplication
|
|||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Domain name is not under a recognized TLD");
|
||||
runCommand("example.foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("example.foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("Domain name is not under a recognized TLD");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,8 +78,7 @@ public class GetApplicationIdsCommandTest extends CommandTestCase<GetApplication
|
|||
|
||||
@Test
|
||||
public void testFailure_noDomainName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
private void persistDomainApplication(String domainName, String repoId) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.newContactResource;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -79,8 +80,7 @@ public class GetContactCommandTest extends CommandTestCase<GetContactCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_noContact() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -95,8 +96,7 @@ public class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_noDomainName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.DatastoreHelper.newHostResource;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -106,7 +107,6 @@ public class GetHostCommandTest extends CommandTestCase<GetHostCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_noHostName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,11 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
|
@ -79,8 +81,10 @@ public class GetLrpTokenCommandTest extends CommandTestCase<GetLrpTokenCommand>
|
|||
|
||||
@Test
|
||||
public void testFailure_noArgs() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Exactly one of either token or assignee must be specified.");
|
||||
runCommand();
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Exactly one of either token or assignee must be specified.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -34,21 +38,20 @@ public class GetRegistrarCommandTest extends CommandTestCase<GetRegistrarCommand
|
|||
|
||||
@Test
|
||||
public void testFailure_registrarDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar with id ClientZ does not exist");
|
||||
runCommand("ClientZ");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("ClientZ"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noRegistrarName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_oneRegistrarDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar with id ClientZ does not exist");
|
||||
runCommand("NewRegistrar", "ClientZ");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("NewRegistrar", "ClientZ"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar with id ClientZ does not exist");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
|
@ -21,6 +22,8 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
|||
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -68,10 +71,16 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
@Test
|
||||
public void testFailure_domain_oneDoesNotExist() throws Exception {
|
||||
persistActiveDomain("example.tld");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
|
||||
runCommand(
|
||||
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw",
|
||||
"agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -111,11 +120,16 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
@Test
|
||||
public void testFailure_contact_oneDoesNotExist() throws Exception {
|
||||
persistActiveContact("sh8013");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
|
||||
runCommand(
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -155,11 +169,16 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
@Test
|
||||
public void testFailure_host_oneDoesNotExist() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
|
||||
runCommand(
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -186,21 +205,25 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
|
|||
|
||||
@Test
|
||||
public void testFailure_keyDoesNotExist() throws Exception {
|
||||
thrown.expect(NullPointerException.class);
|
||||
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
|
||||
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
|
||||
NullPointerException thrown =
|
||||
expectThrows(
|
||||
NullPointerException.class,
|
||||
() -> runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonsenseKey() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Could not parse Reference");
|
||||
runCommand("agR0ZXN0chULEgpEb21haW5CYXN");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class, () -> runCommand("agR0ZXN0chULEgpEb21haW5CYXN"));
|
||||
assertThat(thrown).hasMessageThat().contains("Could not parse Reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noParameters() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.tools;
|
|||
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
@ -38,20 +39,17 @@ public class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("xn--q9jyb4c");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noTldName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand();
|
||||
assertThrows(ParameterException.class, () -> runCommand());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_oneTldDoesNotExist() throws Exception {
|
||||
createTld("xn--q9jyb4c");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("xn--q9jyb4c", "example");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("xn--q9jyb4c", "example"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.tools;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.model.common.Cursor;
|
||||
|
@ -49,9 +50,9 @@ public class ListCursorsCommandTest extends CommandTestCase<ListCursorsCommand>
|
|||
|
||||
@Test
|
||||
public void testListCursors_badCursor_throwsIae() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Invalid value for --type parameter.");
|
||||
runCommand("--type=love");
|
||||
ParameterException thrown =
|
||||
expectThrows(ParameterException.class, () -> runCommand("--type=love"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid value for --type parameter.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.tools.server.ListDomainsAction;
|
||||
|
@ -43,8 +46,10 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase<ListDomai
|
|||
@Test
|
||||
public void test_tldsParamTooLong() throws Exception {
|
||||
String tldsParam = "--tld=foo,bar" + Strings.repeat(",baz", 300);
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Total length of TLDs is too long for URL parameter");
|
||||
runCommand(tldsParam);
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand(tldsParam));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Total length of TLDs is too long for URL parameter");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,13 +92,6 @@ public class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
|||
eq(MediaType.PLAIN_TEXT_UTF_8),
|
||||
eq(new byte[0]));
|
||||
}
|
||||
@Test
|
||||
public void test_prompt() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
runCommand();
|
||||
verifyZeroInteractions(connection);
|
||||
assertInStderr("Unable to access stdin (are you running with bazel run?)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_badTLD() throws Exception {
|
||||
|
|
|
@ -22,6 +22,8 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -32,7 +34,6 @@ import org.joda.time.DateTime;
|
|||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
|
@ -44,10 +45,6 @@ public class MutatingCommandTest {
|
|||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.build();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
Registrar registrar1;
|
||||
Registrar registrar2;
|
||||
Registrar newRegistrar1;
|
||||
|
@ -298,8 +295,7 @@ public class MutatingCommandTest {
|
|||
stageEntityChange(null, null);
|
||||
}
|
||||
};
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
command.init();
|
||||
assertThrows(IllegalArgumentException.class, () -> command.init());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -313,9 +309,11 @@ public class MutatingCommandTest {
|
|||
.build());
|
||||
}
|
||||
};
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Cannot apply multiple changes for the same entity");
|
||||
command.init();
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> command.init());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Cannot apply multiple changes for the same entity");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -326,9 +324,11 @@ public class MutatingCommandTest {
|
|||
stageEntityChange(host1, host2);
|
||||
}
|
||||
};
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Both entity versions in an update must have the same Key.");
|
||||
command.init();
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> command.init());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Both entity versions in an update must have the same Key.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -339,9 +339,11 @@ public class MutatingCommandTest {
|
|||
stageEntityChange(registrar1, registrar2);
|
||||
}
|
||||
};
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Both entity versions in an update must have the same Key.");
|
||||
command.init();
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> command.init());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Both entity versions in an update must have the same Key.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -352,9 +354,11 @@ public class MutatingCommandTest {
|
|||
stageEntityChange(host1, registrar1);
|
||||
}
|
||||
};
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Both entity versions in an update must have the same Key.");
|
||||
command.init();
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> command.init());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Both entity versions in an update must have the same Key.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -367,9 +371,9 @@ public class MutatingCommandTest {
|
|||
};
|
||||
command.init();
|
||||
persistResource(newHost1);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Entity changed since init() was called.");
|
||||
command.execute();
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> command.execute());
|
||||
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -382,9 +386,9 @@ public class MutatingCommandTest {
|
|||
};
|
||||
command.init();
|
||||
persistResource(newHost1);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Entity changed since init() was called.");
|
||||
command.execute();
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> command.execute());
|
||||
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -397,9 +401,9 @@ public class MutatingCommandTest {
|
|||
};
|
||||
command.init();
|
||||
persistResource(newHost1);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Entity changed since init() was called.");
|
||||
command.execute();
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> command.execute());
|
||||
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -412,8 +416,8 @@ public class MutatingCommandTest {
|
|||
};
|
||||
command.init();
|
||||
deleteResource(host1);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Entity changed since init() was called.");
|
||||
command.execute();
|
||||
IllegalStateException thrown =
|
||||
expectThrows(IllegalStateException.class, () -> command.execute());
|
||||
assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
|
@ -26,13 +25,9 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class RegistryToolEnvironmentTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testGet_withoutSetup_throws() throws Exception {
|
||||
thrown.expect(IllegalStateException.class);
|
||||
RegistryToolEnvironment.get();
|
||||
assertThrows(IllegalStateException.class, () -> RegistryToolEnvironment.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -72,16 +67,18 @@ public class RegistryToolEnvironmentTest {
|
|||
|
||||
@Test
|
||||
public void testFromArgs_envFlagAfterCommandName_getsIgnored() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
RegistryToolEnvironment.parseFromArgs(new String[] {
|
||||
"registrar_activity_report",
|
||||
"-e", "1406851199"});
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
RegistryToolEnvironment.parseFromArgs(
|
||||
new String[] {"registrar_activity_report", "-e", "1406851199"}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromArgs_missingEnvironmentFlag_throwsIae() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
RegistryToolEnvironment.parseFromArgs(new String[] {});
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> RegistryToolEnvironment.parseFromArgs(new String[] {}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -106,7 +103,8 @@ public class RegistryToolEnvironmentTest {
|
|||
|
||||
@Test
|
||||
public void testFromArgs_badName_throwsIae() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
RegistryToolEnvironment.parseFromArgs(new String[] { "-e", "alphaville" });
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> RegistryToolEnvironment.parseFromArgs(new String[] {"-e", "alphaville"}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -203,132 +204,168 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_missingIpWhitelist() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("option is required: -w, --ip_whitelist");
|
||||
runCommandForced(
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("option is required: -w, --ip_whitelist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingRegistrar() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("option is required: -r, --registrar");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("option is required: -r, --registrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingCertificateFile() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("option is required: -c, --certfile");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--registrar=blobio");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1", "--dns_writers=VoidDnsWriter", "--registrar=blobio"));
|
||||
assertThat(thrown).hasMessageThat().contains("option is required: -c, --certfile");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDnsWriter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("option is required: --dns_writers");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--certfile=" + getCertFilename(),
|
||||
"--registrar=blobio");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--certfile=" + getCertFilename(),
|
||||
"--registrar=blobio"));
|
||||
assertThat(thrown).hasMessageThat().contains("option is required: --dns_writers");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidCert() throws Exception {
|
||||
thrown.expect(CertificateParsingException.class);
|
||||
thrown.expectMessage("No X509Certificate found");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=/dev/null");
|
||||
CertificateParsingException thrown =
|
||||
expectThrows(
|
||||
CertificateParsingException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=/dev/null"));
|
||||
assertThat(thrown).hasMessageThat().contains("No X509Certificate found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRegistrar() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar name is invalid");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=3blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=3blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar name is invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidDnsWriter() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=InvalidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=InvalidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registrarTooShort() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar name is invalid");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=bl",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=bl",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar name is invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registrarTooLong() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar name is invalid");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobiotoooolong",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobiotoooolong",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar name is invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registrarInvalidCharacter() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar name is invalid");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blo#bio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blo#bio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar name is invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidPremiumList() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The premium list 'foo' doesn't exist");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename(),
|
||||
"--premium_list=foo");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename(),
|
||||
"--premium_list=foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("The premium list 'foo' doesn't exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldExists() throws Exception {
|
||||
createTld("blobio-sunrise");
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("TLD 'blobio-sunrise' already exists");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalStateException thrown =
|
||||
expectThrows(
|
||||
IllegalStateException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("TLD 'blobio-sunrise' already exists");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -338,12 +375,15 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
.setRegistrarName("blobio-1")
|
||||
.build();
|
||||
persistResource(registrar);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Registrar blobio-1 already exists");
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename());
|
||||
IllegalStateException thrown =
|
||||
expectThrows(
|
||||
IllegalStateException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ip_whitelist=1.1.1.1",
|
||||
"--registrar=blobio",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar blobio-1 already exists");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,13 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -150,46 +152,58 @@ public class UniformRapidSuspensionCommandTest
|
|||
@Test
|
||||
public void testFailure_locksToPreserveWithoutUndo() throws Exception {
|
||||
persistActiveDomain("evil.tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("--undo");
|
||||
runCommandForced("--domain_name=evil.tld", "--locks_to_preserve=serverDeleteProhibited");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld", "--locks_to_preserve=serverDeleteProhibited"));
|
||||
assertThat(thrown).hasMessageThat().contains("--undo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_domainNameRequired() throws Exception {
|
||||
persistActiveDomain("evil.tld");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--domain_name");
|
||||
runCommandForced("--hosts=urs1.example.com,urs2.example.com");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--hosts=urs1.example.com,urs2.example.com"));
|
||||
assertThat(thrown).hasMessageThat().contains("--domain_name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_extraFieldInDsData() throws Exception {
|
||||
persistActiveDomain("evil.tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Incorrect fields on --dsdata JSON");
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld",
|
||||
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1,\"digest\":\"abc\",\"foo\":1}");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld",
|
||||
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1,\"digest\":\"abc\",\"foo\":1}"));
|
||||
assertThat(thrown).hasMessageThat().contains("Incorrect fields on --dsdata JSON");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingFieldInDsData() throws Exception {
|
||||
persistActiveDomain("evil.tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Incorrect fields on --dsdata JSON");
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld",
|
||||
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1}");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld",
|
||||
"--dsdata={\"keyTag\":1,\"alg\":1,\"digestType\":1}"));
|
||||
assertThat(thrown).hasMessageThat().contains("Incorrect fields on --dsdata JSON");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_malformedDsData() throws Exception {
|
||||
persistActiveDomain("evil.tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid --dsdata JSON");
|
||||
runCommandForced(
|
||||
"--domain_name=evil.tld",
|
||||
"--dsdata=[1,2,3]");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--domain_name=evil.tld", "--dsdata=[1,2,3]"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid --dsdata JSON");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
|||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
|
@ -270,16 +271,25 @@ public class UpdateApplicationStatusCommandTest
|
|||
|
||||
@Test
|
||||
public void testFailure_applicationDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--ids=555-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--ids=555-Q9JYB4C", "--msg=\"Application rejected\"", "--status=REJECTED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_historyClientIdDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("fakeclient");
|
||||
runCommandForced(
|
||||
"--history_client_id=fakeclient", "--ids=2-Q9JYB4C", "--msg=Ignored", "--status=REJECTED");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--history_client_id=fakeclient",
|
||||
"--ids=2-Q9JYB4C",
|
||||
"--msg=Ignored",
|
||||
"--status=REJECTED"));
|
||||
assertThat(thrown).hasMessageThat().contains("fakeclient");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
|
|||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
@ -131,12 +132,14 @@ public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsN
|
|||
|
||||
@Test
|
||||
public void testFailure_badClaimsNotice() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand(
|
||||
"--id=1-Q9JYB4C",
|
||||
"--tcn_id=foobarbaz",
|
||||
"--expiration_time=2010-08-16T09:00:00.0Z",
|
||||
"--accepted_time=2009-08-16T09:00:00.0Z");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--id=1-Q9JYB4C",
|
||||
"--tcn_id=foobarbaz",
|
||||
"--expiration_time=2010-08-16T09:00:00.0Z",
|
||||
"--accepted_time=2009-08-16T09:00:00.0Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -160,12 +163,13 @@ public class UpdateClaimsNoticeCommandTest extends CommandTestCase<UpdateClaimsN
|
|||
domainApplication = persistResource(domainApplication.asBuilder()
|
||||
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "AAAAA")))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
||||
runCommand(
|
||||
"--id=1-Q9JYB4C",
|
||||
"--tcn_id=370d0b7c9223372036854775807",
|
||||
"--expiration_time=2010-08-16T09:00:00.0Z",
|
||||
"--accepted_time=2009-08-16T09:00:00.0Z");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--id=1-Q9JYB4C",
|
||||
"--tcn_id=370d0b7c9223372036854775807",
|
||||
"--expiration_time=2010-08-16T09:00:00.0Z",
|
||||
"--accepted_time=2009-08-16T09:00:00.0Z"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.model.common.Cursor;
|
||||
|
@ -110,14 +112,17 @@ public class UpdateCursorsCommandTest extends CommandTestCase<UpdateCursorsComma
|
|||
|
||||
@Test
|
||||
public void testFailure_badTld() throws Exception {
|
||||
thrown.expect(RegistryNotFoundException.class);
|
||||
runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "bar");
|
||||
assertThrows(
|
||||
RegistryNotFoundException.class,
|
||||
() -> runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badCursorType() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Invalid value for --type parameter");
|
||||
runCommandForced("--type=rbda", "--timestamp=1984-12-18T00:00:00Z", "foo");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--type=rbda", "--timestamp=1984-12-18T00:00:00Z", "foo"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid value for --type parameter");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,130 +192,197 @@ public class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomain
|
|||
|
||||
@Test
|
||||
public void testFailure_duplicateDomains() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Duplicate arguments found");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--password=2fooBAR",
|
||||
"example.tld",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrant=crr-admin",
|
||||
"--password=2fooBAR",
|
||||
"example.tld",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("Duplicate arguments found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDomain() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Main parameters are required");
|
||||
runCommandForced("--client=NewRegistrar", "--registrant=crr-admin", "--password=2fooBAR");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--registrant=crr-admin", "--password=2fooBAR"));
|
||||
assertThat(thrown).hasMessageThat().contains("Main parameters are required");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--client");
|
||||
runCommandForced("--registrant=crr-admin", "--password=2fooBAR", "example.tld");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommandForced("--registrant=crr-admin", "--password=2fooBAR", "example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("--client");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addTooManyNameServers() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("You can add at most 13 nameservers");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_nameservers=ns1.zdns.google,ns2.zdns.google,ns3.zdns.google,ns4.zdns.google,"
|
||||
+ "ns5.zdns.google,ns6.zdns.google,ns7.zdns.google,ns8.zdns.google,"
|
||||
+ "ns9.zdns.google,ns10.zdns.google,ns11.zdns.google,ns12.zdns.google,"
|
||||
+ "ns13.zdns.google,ns14.zdns.google",
|
||||
"--add_admins=crr-admin2",
|
||||
"--add_techs=crr-tech2",
|
||||
"--add_statuses=serverDeleteProhibited",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_nameservers=ns1.zdns.google,ns2.zdns.google,ns3.zdns.google,ns4.zdns.google,"
|
||||
+ "ns5.zdns.google,ns6.zdns.google,ns7.zdns.google,ns8.zdns.google,"
|
||||
+ "ns9.zdns.google,ns10.zdns.google,ns11.zdns.google,ns12.zdns.google,"
|
||||
+ "ns13.zdns.google,ns14.zdns.google",
|
||||
"--add_admins=crr-admin2",
|
||||
"--add_techs=crr-tech2",
|
||||
"--add_statuses=serverDeleteProhibited",
|
||||
"example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("You can add at most 13 nameservers");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedNameserversAndAddNameservers() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("If you provide the nameservers flag, "
|
||||
+ "you cannot use the add_nameservers and remove_nameservers flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_nameservers=ns1.zdns.google",
|
||||
"--nameservers=ns2.zdns.google,ns3.zdns.google",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_nameservers=ns1.zdns.google",
|
||||
"--nameservers=ns2.zdns.google,ns3.zdns.google",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the nameservers flag, "
|
||||
+ "you cannot use the add_nameservers and remove_nameservers flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedNameserversAndRemoveNameservers() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("If you provide the nameservers flag, "
|
||||
+ "you cannot use the add_nameservers and remove_nameservers flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_nameservers=ns1.zdns.google",
|
||||
"--nameservers=ns2.zdns.google,ns3.zdns.google",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_nameservers=ns1.zdns.google",
|
||||
"--nameservers=ns2.zdns.google,ns3.zdns.google",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the nameservers flag, "
|
||||
+ "you cannot use the add_nameservers and remove_nameservers flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedAdminsAndAddAdmins() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"If you provide the admins flag, you cannot use the add_admins and remove_admins flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--add_admins=crr-admin2", "--admins=crr-admin2", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_admins=crr-admin2",
|
||||
"--admins=crr-admin2",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"If you provide the admins flag, "
|
||||
+ "you cannot use the add_admins and remove_admins flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedAdminsAndRemoveAdmins() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"If you provide the admins flag, you cannot use the add_admins and remove_admins flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_admins=crr-admin2",
|
||||
"--admins=crr-admin2",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_admins=crr-admin2",
|
||||
"--admins=crr-admin2",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"If you provide the admins flag, "
|
||||
+ "you cannot use the add_admins and remove_admins flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedTechsAndAddTechs() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--add_techs=crr-tech2", "--techs=crr-tech2", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_techs=crr-tech2",
|
||||
"--techs=crr-tech2",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedTechsAndRemoveTechs() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar", "--remove_techs=crr-tech2", "--techs=crr-tech2", "example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_techs=crr-tech2",
|
||||
"--techs=crr-tech2",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the techs flag, you cannot use the add_techs and remove_techs flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedStatusesAndAddStatuses() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("If you provide the statuses flag, "
|
||||
+ "you cannot use the add_statuses and remove_statuses flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_statuses=serverHold",
|
||||
"--statuses=crr-serverHold",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--add_statuses=serverHold",
|
||||
"--statuses=crr-serverHold",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the statuses flag, "
|
||||
+ "you cannot use the add_statuses and remove_statuses flags.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_providedStatusesAndRemoveStatuses() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("If you provide the statuses flag, "
|
||||
+ "you cannot use the add_statuses and remove_statuses flags.");
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_statuses=serverHold",
|
||||
"--statuses=crr-serverHold",
|
||||
"example.tld");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--remove_statuses=serverHold",
|
||||
"--statuses=crr-serverHold",
|
||||
"example.tld"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"If you provide the statuses flag, "
|
||||
+ "you cannot use the add_statuses and remove_statuses flags.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
|
|||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
@ -70,9 +72,11 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
.setIanaIdentifier(null)
|
||||
.setPhonePasscode(null)
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("--passcode is required for REAL registrars.");
|
||||
runCommand("--registrar_type=REAL", "--iana_id=1000", "--force", "NewRegistrar");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--registrar_type=REAL", "--iana_id=1000", "--force", "NewRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().contains("--passcode is required for REAL registrars.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -217,14 +221,17 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
public void testFailure_billingAccountMap_doesNotContainEntryForTldAllowed() throws Exception {
|
||||
createTlds("foo");
|
||||
assertThat(loadRegistrar("NewRegistrar").getBillingAccountMap()).isEmpty();
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("USD");
|
||||
runCommand(
|
||||
"--billing_account_map=JPY=789xyz",
|
||||
"--allowed_tlds=foo",
|
||||
"--force",
|
||||
"--registrar_type=REAL",
|
||||
"NewRegistrar");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--billing_account_map=JPY=789xyz",
|
||||
"--allowed_tlds=foo",
|
||||
"--force",
|
||||
"--registrar_type=REAL",
|
||||
"NewRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().contains("USD");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -276,11 +283,15 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build());
|
||||
assertThat(registrar.getBillingMethod()).isEqualTo(BillingMethod.EXTERNAL);
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(
|
||||
"Refusing to change billing method on Registrar 'NewRegistrar' from EXTERNAL to BRAINTREE"
|
||||
+ " because current balance is non-zero: {USD=USD 10.00}");
|
||||
runCommand("--billing_method=braintree", "--force", "NewRegistrar");
|
||||
IllegalStateException thrown =
|
||||
expectThrows(
|
||||
IllegalStateException.class,
|
||||
() -> runCommand("--billing_method=braintree", "--force", "NewRegistrar"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
"Refusing to change billing method on Registrar 'NewRegistrar' from EXTERNAL to "
|
||||
+ "BRAINTREE because current balance is non-zero: {USD=USD 10.00}");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -437,174 +448,267 @@ public class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarC
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidRegistrarType() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--registrar_type=INVALID_TYPE", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--registrar_type=INVALID_TYPE", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRegistrarState() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--registrar_state=INVALID_STATE", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--registrar_state=INVALID_STATE", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeIanaId() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--iana_id=-1", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--iana_id=-1", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonIntegerIanaId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--iana_id=ABC123", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
ParameterException.class, () -> runCommand("--iana_id=ABC123", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeBillingId() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--billing_id=-1", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--billing_id=-1", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonIntegerBillingId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--billing_id=ABC123", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--billing_id=ABC123", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_passcodeTooShort() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--passcode=0123", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--passcode=0123", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_passcodeTooLong() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--passcode=012345", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--passcode=012345", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidPasscode() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--passcode=code1", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--passcode=code1", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_allowedTldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--allowed_tlds=foobar", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--allowed_tlds=foobar", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_addAllowedTldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--add_allowed_tlds=foobar", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--add_allowed_tlds=foobar", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_allowedTldsAndAddAllowedTlds() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--allowed_tlds=bar", "--add_allowed_tlds=foo", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand("--allowed_tlds=bar", "--add_allowed_tlds=foo", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidIpWhitelist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--ip_whitelist=foobarbaz", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--ip_whitelist=foobarbaz", "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidCertFileContents() throws Exception {
|
||||
thrown.expect(Exception.class);
|
||||
runCommand("--cert_file=" + writeToTmpFile("ABCDEF"), "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
Exception.class,
|
||||
() -> runCommand("--cert_file=" + writeToTmpFile("ABCDEF"), "--force", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_certHashAndCertFile() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--cert_file=" + getCertFilename(), "--cert_hash=ABCDEF", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--cert_file=" + getCertFilename(),
|
||||
"--cert_hash=ABCDEF",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--force");
|
||||
assertThrows(ParameterException.class, () -> runCommand("--force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingStreetLines() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--city Brooklyn", "--state NY", "--zip 11223", "--cc US", "--force",
|
||||
"NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--cc US",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingCity() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
|
||||
"--state NY", "--zip 11223", "--cc US", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street=\"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--cc US",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingState() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
|
||||
"--city Brooklyn", "--zip 11223", "--cc US", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street=\"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--city Brooklyn",
|
||||
"--zip 11223",
|
||||
"--cc US",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingZip() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
|
||||
"--city Brooklyn", "--state NY", "--cc US", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street=\"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--cc US",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingCc() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
|
||||
"--city Brooklyn", "--state NY", "--zip 11223", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street=\"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingInvalidCc() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street=\"1234 Main St\"", "--street \"4th Floor\"", "--street \"Suite 1\"",
|
||||
"--city Brooklyn", "--state NY", "--zip 11223", "--cc USA", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street=\"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--cc USA",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyStreetLines() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street \"Attn:Hey You Guys\"", "--street \"1234 Main St\"",
|
||||
"--street \"4th Floor\"", "--street \"Suite 1\"", "--city Brooklyn", "--state NY",
|
||||
"--zip 11223", "--cc USA", "--force", "NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street \"Attn:Hey You Guys\"",
|
||||
"--street \"1234 Main St\"",
|
||||
"--street \"4th Floor\"",
|
||||
"--street \"Suite 1\"",
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--cc USA",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooFewStreetLines() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--street", "--city Brooklyn", "--state NY", "--zip 11223", "--cc USA", "--force",
|
||||
"NewRegistrar");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--street",
|
||||
"--city Brooklyn",
|
||||
"--state NY",
|
||||
"--zip 11223",
|
||||
"--cc USA",
|
||||
"--force",
|
||||
"NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand("--force", "--unrecognized_flag=foo", "NewRegistrar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() -> runCommand("--force", "--unrecognized_flag=foo", "NewRegistrar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_doesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar ClientZ not found");
|
||||
runCommand("--force", "ClientZ");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("--force", "ClientZ"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar ClientZ not found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registrarNameSimilarToExisting() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
// Normalizes identically to "The Registrar" which is created by AppEngineRule.
|
||||
runCommand("--name tHeRe GiStRaR", "--force", "NewRegistrar");
|
||||
// Note that "tHeRe GiStRaR" normalizes identically to "The Registrar", which is created by
|
||||
// AppEngineRule.
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommand("--name tHeRe GiStRaR", "--force", "NewRegistrar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -92,8 +93,11 @@ public class UpdateReservedListCommandTest extends
|
|||
public void testFailure_reservedListDoesntExist() throws Exception {
|
||||
String errorMessage =
|
||||
"Could not update reserved list xn--q9jyb4c_poobah because it doesn't exist.";
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(errorMessage);
|
||||
runCommand("--force", "--name=xn--q9jyb4c_poobah", "--input=" + reservedTermsPath);
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand("--force", "--name=xn--q9jyb4c_poobah", "--input=" + reservedTermsPath));
|
||||
assertThat(thrown).hasMessageThat().contains(errorMessage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -57,69 +59,123 @@ public class UpdateServerLocksCommandTest extends EppToolCommandTestCase<UpdateS
|
|||
|
||||
@Test
|
||||
public void testFailure_applyAllRemoveOne_failsDueToOverlap() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=all", "--remove=serverRenewProhibited");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=all",
|
||||
"--remove=serverRenewProhibited"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_illegalStatus() throws Exception {
|
||||
// The EPP status is a valid one by RFC, but invalid for this command.
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=clientRenewProhibited");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=clientRenewProhibited"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unrecognizedStatus() throws Exception {
|
||||
// Handles a status passed to the command that doesn't correspond to any
|
||||
// EPP-valid status.
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=foo");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "example2.tld", "--apply=serverRenewProhibited");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"example2.tld",
|
||||
"--apply=serverRenewProhibited"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noOp() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--domain_name=example.tld", "--apply=all",
|
||||
"--remove=serverRenewProhibited,serverTransferProhibited,"
|
||||
+ "serverDeleteProhibited,serverUpdateProhibited,serverHold",
|
||||
"--registrar_request=true", "--reason=Test");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=all",
|
||||
"--remove=serverRenewProhibited,serverTransferProhibited,"
|
||||
+ "serverDeleteProhibited,serverUpdateProhibited,serverHold",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--domain_name=example.tld", "--registrar_request=true",
|
||||
"--apply=serverRenewProhibited", "--reason=Test");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--domain_name=example.tld",
|
||||
"--registrar_request=true",
|
||||
"--apply=serverRenewProhibited",
|
||||
"--reason=Test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=true", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=serverRenewProhibited", "--foo=bar");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=true",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=serverRenewProhibited",
|
||||
"--foo=bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noReasonWhenNotRegistrarRequested() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--registrar_request=false",
|
||||
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--registrar_request=false",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=serverRenewProhibited"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingRegistrarRequest() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--reason=Test",
|
||||
"--domain_name=example.tld", "--apply=serverRenewProhibited");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--reason=Test",
|
||||
"--domain_name=example.tld",
|
||||
"--apply=serverRenewProhibited"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,88 +465,128 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidAddGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--add_grace_period=5m", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--add_grace_period=5m", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidPendingDeleteLength() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Invalid format: \"5m\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidTldState() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidTldStateTransitionTime() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldStatesOutOfOrder() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION", now, now.plusMonths(1)),
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION",
|
||||
now, now.plusMonths(1)),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("The TLD states are chronologically out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateTldStateTransitions() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)),
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("The TLD states are chronologically out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateTldStateTransitionTimes() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now),
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_outOfOrderTldStateTransitionTimes() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
now, now.minus(Duration.millis(1))),
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
now, now.minus(Duration.millis(1))),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_bothTldStateFlags() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Don't pass both --set_current_tld_state and --tld_state_transitions");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.plusDays(1)),
|
||||
"--set_current_tld_state=GENERAL_AVAILABILITY",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
now, now.plusDays(1)),
|
||||
"--set_current_tld_state=GENERAL_AVAILABILITY",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Don't pass both --set_current_tld_state and --tld_state_transitions");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -558,9 +598,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("The TLD states are chronologically out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -572,9 +614,13 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.plusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(" when there is a later transition already scheduled");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(" when there is a later transition already scheduled");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -586,99 +632,139 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("--set_current_tld_state is not safe to use in production.");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--set_current_tld_state=SUNRISE",
|
||||
"xn--q9jyb4c",
|
||||
"--force");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--set_current_tld_state=SUNRISE",
|
||||
"xn--q9jyb4c",
|
||||
"--force"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("--set_current_tld_state is not safe to use in production.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRenewBillingCost() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME), "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeRenewBillingCost() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Renew billing cost cannot be negative");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME),
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Renew billing cost cannot be negative");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRenewCostTransitionTime() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateRenewCostTransitionTimes() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now),
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_outOfOrderRenewCostTransitionTimes() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"",
|
||||
now, now.minus(Duration.millis(1))),
|
||||
"xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"",
|
||||
now, now.minus(Duration.millis(1))),
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("not formatted correctly or has transition times out of order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noTldName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Main parameters are required (\"Names of the TLDs\")");
|
||||
runCommandForced();
|
||||
ParameterException thrown = expectThrows(ParameterException.class, () -> runCommandForced());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Main parameters are required (\"Names of the TLDs\")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_oneTldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLD foo does not exist");
|
||||
runCommandForced("foo", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommandForced("foo", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLD foo does not exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateArguments() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Duplicate arguments found: 'xn--q9jyb4c'");
|
||||
runCommandForced("xn--q9jyb4c", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class, () -> runCommandForced("xn--q9jyb4c", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("Duplicate arguments found: 'xn--q9jyb4c'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLD foobarbaz does not exist");
|
||||
runCommandForced("foobarbaz");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommandForced("foobarbaz"));
|
||||
assertThat(thrown).hasMessageThat().contains("TLD foobarbaz does not exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_specifiedDnsWriter_doesntExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
runCommandForced("xn--q9jyb4c", "--dns_writers=InvalidDnsWriter");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("xn--q9jyb4c", "--dns_writers=InvalidDnsWriter"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setNonExistentReservedLists() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
|
||||
runCommandForced("--reserved_lists", "xn--q9jyb4c_ZZZ", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--reserved_lists", "xn--q9jyb4c_ZZZ", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -686,9 +772,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_r1");
|
||||
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("xn--q9jyb4c_r1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -696,19 +784,24 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_Z");
|
||||
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_Z", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--remove_reserved_lists=xn--q9jyb4c_Z", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("xn--q9jyb4c_Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameReservedListSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_r1");
|
||||
runCommandForced(
|
||||
"--add_reserved_lists=xn--q9jyb4c_r1",
|
||||
"--remove_reserved_lists=xn--q9jyb4c_r1",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--add_reserved_lists=xn--q9jyb4c_r1",
|
||||
"--remove_reserved_lists=xn--q9jyb4c_r1",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("xn--q9jyb4c_r1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -717,9 +810,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("alice");
|
||||
runCommandForced("--add_allowed_registrants=alice", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--add_allowed_registrants=alice", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("alice");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -728,19 +823,24 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setAllowedRegistrantContactIds(ImmutableSet.of("alice"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("bob");
|
||||
runCommandForced("--remove_allowed_registrants=bob", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--remove_allowed_registrants=bob", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("bob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameAllowedRegistrantsSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("alice");
|
||||
runCommandForced(
|
||||
"--add_allowed_registrants=alice",
|
||||
"--remove_allowed_registrants=alice",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--add_allowed_registrants=alice",
|
||||
"--remove_allowed_registrants=alice",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("alice");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -750,9 +850,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setAllowedFullyQualifiedHostNames(
|
||||
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns1.example.com");
|
||||
runCommandForced("--add_allowed_nameservers=ns1.example.com", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--add_allowed_nameservers=ns1.example.com", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("ns1.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -762,19 +864,24 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setAllowedFullyQualifiedHostNames(
|
||||
ImmutableSet.of("ns1.example.com"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns2.example.com");
|
||||
runCommandForced("--remove_allowed_nameservers=ns2.example.com", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--remove_allowed_nameservers=ns2.example.com", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("ns2.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameAllowedNameserversSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns1.example.com");
|
||||
runCommandForced(
|
||||
"--add_allowed_nameservers=ns1.example.com",
|
||||
"--remove_allowed_nameservers=ns1.example.com",
|
||||
"xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--add_allowed_nameservers=ns1.example.com",
|
||||
"--remove_allowed_nameservers=ns1.example.com",
|
||||
"xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("ns1.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -895,9 +1002,11 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The premium list 'phonies' doesn't exist");
|
||||
runCommandForced("--premium_list=phonies", "xn--q9jyb4c");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--premium_list=phonies", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -910,17 +1019,24 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_updateLrpPeriod_backwardsInterval() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
|
||||
runCommandForced("--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_updateLrpPeriod_badInterval() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--lrp_period=foobar not an ISO-8601 interval");
|
||||
runCommandForced("--lrp_period=foobar", "xn--q9jyb4c");
|
||||
ParameterException thrown =
|
||||
expectThrows(
|
||||
ParameterException.class, () -> runCommandForced("--lrp_period=foobar", "xn--q9jyb4c"));
|
||||
assertThat(thrown).hasMessageThat().contains("--lrp_period=foobar not an ISO-8601 interval");
|
||||
}
|
||||
|
||||
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import google.registry.model.tmch.ClaimsListShard;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -52,8 +53,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -64,8 +64,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,8 +75,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,8 +86,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -100,8 +97,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -112,8 +108,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -124,8 +119,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -136,8 +130,7 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z,extra",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -148,25 +141,21 @@ public class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsLis
|
|||
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
|
||||
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,foo",
|
||||
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", filename);
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_fileDoesNotExist() throws Exception {
|
||||
thrown.expect(FileNotFoundException.class);
|
||||
runCommand("--force", "nonexistent_file.csv");
|
||||
assertThrows(FileNotFoundException.class, () -> runCommand("--force", "nonexistent_file.csv"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noFileNamePassed() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tooManyArguments() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand("--force", "foo", "bar");
|
||||
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", "foo", "bar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import google.registry.rde.RdeTestData;
|
||||
import google.registry.xml.XmlException;
|
||||
|
@ -101,9 +102,11 @@ public class ValidateEscrowDepositCommandTest
|
|||
@Test
|
||||
public void testRun_badXml() throws Exception {
|
||||
String file = writeToTmpFile(RdeTestData.loadFile("deposit_full.xml").substring(0, 2000));
|
||||
thrown.expect(XmlException.class);
|
||||
thrown.expectMessage("Syntax error at line 46, column 38: "
|
||||
+ "XML document structures must start and end within the same entity.");
|
||||
runCommand("--input=" + file);
|
||||
XmlException thrown = expectThrows(XmlException.class, () -> runCommand("--input=" + file));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Syntax error at line 46, column 38: "
|
||||
+ "XML document structures must start and end within the same entity.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -62,71 +63,81 @@ public class ValidateLoginCredentialsCommandTest
|
|||
|
||||
@Test
|
||||
public void testFailure_loginWithBadPassword() throws Exception {
|
||||
thrown.expect(BadRegistrarPasswordException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + new StringBuffer(PASSWORD).reverse(),
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP);
|
||||
assertThrows(
|
||||
BadRegistrarPasswordException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + new StringBuilder(PASSWORD).reverse(),
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_loginWithBadCertificateHash() throws Exception {
|
||||
thrown.expect(EppException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + new StringBuffer(CERT_HASH).reverse(),
|
||||
"--ip_address=" + CLIENT_IP);
|
||||
assertThrows(
|
||||
EppException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + new StringBuilder(CERT_HASH).reverse(),
|
||||
"--ip_address=" + CLIENT_IP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_loginWithBadIp() throws Exception {
|
||||
thrown.expect(EppException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + new StringBuffer(CLIENT_IP).reverse());
|
||||
assertThrows(
|
||||
EppException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + new StringBuilder(CLIENT_IP).reverse()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP);
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--password=" + PASSWORD, "--cert_hash=" + CERT_HASH, "--ip_address=" + CLIENT_IP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingPassword() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP);
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar", "--cert_hash=" + CERT_HASH, "--ip_address=" + CLIENT_IP));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP,
|
||||
"--unrecognized_flag=foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--ip_address=" + CLIENT_IP,
|
||||
"--unrecognized_flag=foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_certHashAndCertFile() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--cert_file=" + tmpDir.newFile(),
|
||||
"--ip_address=" + CLIENT_IP);
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommand(
|
||||
"--client=NewRegistrar",
|
||||
"--password=" + PASSWORD,
|
||||
"--cert_hash=" + CERT_HASH,
|
||||
"--cert_file=" + tmpDir.newFile(),
|
||||
"--ip_address=" + CLIENT_IP));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
import static org.mockito.Matchers.anyMapOf;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
|
@ -66,16 +68,17 @@ public class VerifyOteCommandTest extends CommandTestCase<VerifyOteCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_registrarDoesntExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Registrar blobio does not exist.");
|
||||
runCommand("blobio");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand("blobio"));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar blobio does not exist.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noRegistrarsNoCheckAll() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(
|
||||
"Must provide at least one registrar name, or supply --check-all with no names.");
|
||||
runCommand("");
|
||||
IllegalArgumentException thrown =
|
||||
expectThrows(IllegalArgumentException.class, () -> runCommand(""));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Must provide at least one registrar name, or supply --check-all with no names.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue