diff --git a/java/google/registry/model/registry/Registry.java b/java/google/registry/model/registry/Registry.java index 415d5a605..b11603de6 100644 --- a/java/google/registry/model/registry/Registry.java +++ b/java/google/registry/model/registry/Registry.java @@ -641,7 +641,7 @@ public class Registry extends ImmutableObject implements Buildable { } public Builder setTldStr(String tldStr) { - checkArgument(tldStr != null, "TLD must not be null."); + checkArgument(tldStr != null, "TLD must not be null"); getInstance().tldStr = tldStr; return this; } @@ -746,7 +746,7 @@ public class Registry extends ImmutableObject implements Buildable { } public Builder setCreateBillingCost(Money amount) { - checkArgument(amount.isPositiveOrZero(), "create billing cost cannot be negative"); + checkArgument(amount.isPositiveOrZero(), "createBillingCost cannot be negative"); getInstance().createBillingCost = amount; return this; } @@ -813,7 +813,7 @@ public class Registry extends ImmutableObject implements Buildable { } public Builder setRestoreBillingCost(Money amount) { - checkArgument(amount.isPositiveOrZero(), "restore billing cost cannot be negative"); + checkArgument(amount.isPositiveOrZero(), "restoreBillingCost cannot be negative"); getInstance().restoreBillingCost = amount; return this; } @@ -828,7 +828,7 @@ public class Registry extends ImmutableObject implements Buildable { */ public Builder setRenewBillingCostTransitions( ImmutableSortedMap renewCostsMap) { - checkArgumentNotNull(renewCostsMap, "renew billing costs map cannot be null"); + checkArgumentNotNull(renewCostsMap, "Renew billing costs map cannot be null"); checkArgument(Iterables.all( renewCostsMap.values(), new Predicate() { @@ -836,7 +836,7 @@ public class Registry extends ImmutableObject implements Buildable { public boolean apply(Money amount) { return amount.isPositiveOrZero(); }}), - "renew billing cost cannot be negative"); + "Renew billing cost cannot be negative"); getInstance().renewBillingCostTransitions = TimedTransitionProperty.fromValueMap(renewCostsMap, BillingCostTransition.class); return this; @@ -868,7 +868,7 @@ public class Registry extends ImmutableObject implements Buildable { public Builder setServerStatusChangeBillingCost(Money amount) { checkArgument( - amount.isPositiveOrZero(), "server status change billing cost cannot be negative"); + amount.isPositiveOrZero(), "Server status change billing cost cannot be negative"); getInstance().serverStatusChangeBillingCost = amount; return this; } @@ -906,7 +906,7 @@ public class Registry extends ImmutableObject implements Buildable { final Registry instance = getInstance(); // Pick up the name of the associated TLD from the instance object. String tldName = instance.tldStr; - checkArgument(tldName != null, "No registry TLD specified."); + checkArgument(tldName != null, "No registry TLD specified"); // Check for canonical form by converting to an InternetDomainName and then back. checkArgument( InternetDomainName.isValid(tldName) @@ -945,6 +945,9 @@ public class Registry extends ImmutableObject implements Buildable { "All EAP fees must be in the registry's currency"); checkArgumentNotNull( instance.pricingEngineClassName, "All registries must have a configured pricing engine"); + checkArgumentNotNull( + instance.dnsWriter, + "A DNS writer must be specified. VoidDnsWriter can be used if DNS writing isn't wanted"); instance.tldStrId = tldName; instance.tldUnicode = Idn.toUnicode(tldName); return super.build(); diff --git a/java/google/registry/tools/CreateOrUpdateTldCommand.java b/java/google/registry/tools/CreateOrUpdateTldCommand.java index 4b9d10d77..47bda613e 100644 --- a/java/google/registry/tools/CreateOrUpdateTldCommand.java +++ b/java/google/registry/tools/CreateOrUpdateTldCommand.java @@ -260,7 +260,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { assertAllowedEnvironment(); initTldCommand(); String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters)); - checkArgument(duplicates.isEmpty(), "Duplicate arguments found: \"%s\"", duplicates); + checkArgument(duplicates.isEmpty(), "Duplicate arguments found: '%s'", duplicates); Set tlds = ImmutableSet.copyOf(mainParameters); checkArgument(roidSuffix == null || tlds.size() == 1, "Can't update roid suffixes on multiple TLDs simultaneously"); @@ -268,7 +268,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { checkArgument(tld.equals(canonicalizeDomainName(tld))); checkArgument( !CharMatcher.javaDigit().matches(tld.charAt(0)), - "TLDs cannot begin with a number."); + "TLDs cannot begin with a number"); Registry oldRegistry = getOldRegistry(tld); // TODO(b/26901539): Add a flag to set the pricing engine once we have more than one option. Registry.Builder builder = @@ -388,14 +388,12 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } } - if (dnsWriter != null) { - if (dnsWriter.isPresent()) { + if (dnsWriter != null && dnsWriter.isPresent()) { checkArgument( dnsWriterNames.contains(dnsWriter.get()), "The DNS writer '%s' doesn't exist", dnsWriter.get()); builder.setDnsWriter(dnsWriter.get()); - } } if (lrpPeriod != null) { diff --git a/java/google/registry/tools/CreateTldCommand.java b/java/google/registry/tools/CreateTldCommand.java index 1c13b4c89..37d5b5b1b 100644 --- a/java/google/registry/tools/CreateTldCommand.java +++ b/java/google/registry/tools/CreateTldCommand.java @@ -86,7 +86,7 @@ class CreateTldCommand extends CreateOrUpdateTldCommand { @Override Registry getOldRegistry(String tld) { - checkState(!getTlds().contains(tld), "TLD already exists"); + checkState(!getTlds().contains(tld), "TLD '%s' already exists", tld); return null; } diff --git a/java/google/registry/tools/SetupOteCommand.java b/java/google/registry/tools/SetupOteCommand.java index 8a0c16448..6cbe4cf8c 100644 --- a/java/google/registry/tools/SetupOteCommand.java +++ b/java/google/registry/tools/SetupOteCommand.java @@ -32,7 +32,9 @@ import google.registry.util.StringGenerator; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.inject.Inject; +import javax.inject.Named; import org.joda.time.Duration; /** Composite command to set up OT&E TLDs and accounts. */ @@ -52,6 +54,10 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman private static final String DEFAULT_PREMIUM_LIST = "default_sandbox_list"; + @Inject + @Named("dnsWriterNames") + Set dnsWriterNames; + @Parameter( names = {"-r", "--registrar"}, description = "must 1) consist of only lowercase letters, numbers, or hyphens, " @@ -75,6 +81,12 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman validateWith = PathParameter.InputFile.class) private Path certFile; + @Parameter( + names = {"--dns_writer"}, + description = "DNS writer to use on all TLDs", + required = true) + private String dnsWriter; + @Parameter( names = {"--premium_list"}, description = "premium list to apply to all TLDs") @@ -97,15 +109,17 @@ final class SetupOteCommand extends ConfirmingCommand implements RemoteApiComman Duration redemptionGracePeriod, Duration pendingDeleteLength) throws Exception { CreateTldCommand command = new CreateTldCommand(); + command.addGracePeriod = addGracePeriod; + command.dnsWriter = Optional.of(dnsWriter); + command.dnsWriterNames = dnsWriterNames; + command.force = force; command.initialTldState = initialTldState; command.mainParameters = ImmutableList.of(tldName); - command.roidSuffix = String.format( - "%S%X", tldName.replaceAll("[^a-z0-9]", "").substring(0, 7), roidSuffixCounter++); - command.addGracePeriod = addGracePeriod; - command.redemptionGracePeriod = redemptionGracePeriod; command.pendingDeleteLength = pendingDeleteLength; command.premiumListName = Optional.of(premiumList); - command.force = force; + command.roidSuffix = String.format( + "%S%X", tldName.replaceAll("[^a-z0-9]", "").substring(0, 7), roidSuffixCounter++); + command.redemptionGracePeriod = redemptionGracePeriod; command.run(); } diff --git a/java/google/registry/tools/params/TransitionListParameter.java b/java/google/registry/tools/params/TransitionListParameter.java index d07d65c43..89dbf46d5 100644 --- a/java/google/registry/tools/params/TransitionListParameter.java +++ b/java/google/registry/tools/params/TransitionListParameter.java @@ -30,7 +30,9 @@ public abstract class TransitionListParameter extends KeyValueMapParameter extends KeyValueMapParameter processMap(ImmutableMap map) { - checkArgument(Ordering.natural().isOrdered(map.keySet()), "Transition times out of order."); + checkArgument(Ordering.natural().isOrdered(map.keySet()), "Transition times out of order"); return ImmutableSortedMap.copyOf(map); } - + /** Converter-validator for TLD state transitions. */ public static class TldStateTransitions extends TransitionListParameter { @Override diff --git a/javatests/google/registry/model/BUILD b/javatests/google/registry/model/BUILD index c576b70bf..fe833b57d 100644 --- a/javatests/google/registry/model/BUILD +++ b/javatests/google/registry/model/BUILD @@ -20,6 +20,7 @@ java_library( ] + glob(["**/testdata/*.xml"]), deps = [ "//java/google/registry/config", + "//java/google/registry/dns/writer", "//java/google/registry/flows", "//java/google/registry/model", "//java/google/registry/monitoring/metrics/contrib", diff --git a/javatests/google/registry/model/registry/RegistryTest.java b/javatests/google/registry/model/registry/RegistryTest.java index 2f37d830b..6e670da8c 100644 --- a/javatests/google/registry/model/registry/RegistryTest.java +++ b/javatests/google/registry/model/registry/RegistryTest.java @@ -345,13 +345,13 @@ public class RegistryTest extends EntityTestCase { @Test public void testFailure_tldNeverSet() { - thrown.expect(IllegalArgumentException.class, "No registry TLD specified."); + thrown.expect(IllegalArgumentException.class, "No registry TLD specified"); new Registry.Builder().build(); } @Test public void testFailure_setTldStr_null() { - thrown.expect(IllegalArgumentException.class, "TLD must not be null."); + thrown.expect(IllegalArgumentException.class, "TLD must not be null"); new Registry.Builder().setTldStr(null); } @@ -405,13 +405,13 @@ public class RegistryTest extends EntityTestCase { @Test public void testFailure_negativeCreateBillingCost() { - thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative"); + thrown.expect(IllegalArgumentException.class, "createBillingCost cannot be negative"); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42)); } @Test public void testFailure_negativeRestoreBillingCost() { - thrown.expect(IllegalArgumentException.class, "billing cost cannot be negative"); + thrown.expect(IllegalArgumentException.class, "restoreBillingCost cannot be negative"); Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42)); } diff --git a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java index 1958cd6ea..3a8545bea 100644 --- a/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java +++ b/javatests/google/registry/model/registry/label/PremiumListUtilsTest.java @@ -38,6 +38,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.googlecode.objectify.Key; import com.googlecode.objectify.VoidWork; +import google.registry.dns.writer.VoidDnsWriter; import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.registry.Registry; import google.registry.model.registry.label.PremiumList.PremiumListEntry; @@ -95,6 +96,7 @@ public class PremiumListUtilsTest { new Registry.Builder() .setTldStr("ghost") .setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME) + .setDnsWriter(VoidDnsWriter.NAME) .build()); assertThat(Registry.get("ghost").getPremiumList()).isNull(); assertThat(getPremiumPrice("blah", Registry.get("ghost"))).isAbsent(); diff --git a/javatests/google/registry/tools/CreateTldCommandTest.java b/javatests/google/registry/tools/CreateTldCommandTest.java index 68690b877..02f5ad477 100644 --- a/javatests/google/registry/tools/CreateTldCommandTest.java +++ b/javatests/google/registry/tools/CreateTldCommandTest.java @@ -27,6 +27,7 @@ import static org.joda.time.DateTimeZone.UTC; import static org.joda.time.Duration.standardMinutes; import com.beust.jcommander.ParameterException; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; @@ -51,35 +52,46 @@ public class CreateTldCommandTest extends CommandTestCase { persistReservedList("tld_banned", "kilo,FULLY_BLOCKED", "lima,MISTAKEN_PREMIUM"); persistReservedList("soy_expurgated", "fireflies,FULLY_BLOCKED"); persistPremiumList("xn--q9jyb4c", "minecraft,USD 1000"); + command.dnsWriterNames = ImmutableSet.of("VoidDnsWriter", "FooDnsWriter"); } @Test public void testSuccess() throws Exception { DateTime before = DateTime.now(UTC); - runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C"); + runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writer=FooDnsWriter"); DateTime after = DateTime.now(UTC); Registry registry = Registry.get("xn--q9jyb4c"); assertThat(registry).isNotNull(); - assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(TldState.PREDELEGATION); assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD); + assertThat(registry.getCreationTime()).isIn(Range.closed(before, after)); + assertThat(registry.getDomainCreateRestricted()).isFalse(); + assertThat(registry.getDnsWriter()).isEqualTo("FooDnsWriter"); + assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(TldState.PREDELEGATION); assertThat(registry.getRedemptionGracePeriodLength()) .isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD); assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH); - assertThat(registry.getCreationTime()).isIn(Range.closed(before, after)); - assertThat(registry.getDomainCreateRestricted()).isFalse(); } @Test public void testFailure_multipleArguments() throws Exception { thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time"); - runCommandForced("--roid_suffix=blah", "xn--q9jyb4c", "test"); + runCommandForced("--roid_suffix=blah", "--dns_writer=VoidDnsWriter", "xn--q9jyb4c", "test"); + } + + @Test + public void testFailure_multipleDuplicateArguments() throws Exception { + thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time"); + runCommandForced("--roid_suffix=blah", "--dns_writer=VoidDnsWriter", "test", "test"); } @Test public void testSuccess_initialTldStateFlag() throws Exception { runCommandForced( - "--initial_tld_state=GENERAL_AVAILABILITY", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--initial_tld_state=GENERAL_AVAILABILITY", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getTldState(DateTime.now(UTC))) .isEqualTo(TldState.GENERAL_AVAILABILITY); } @@ -87,7 +99,10 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_initialRenewBillingCostFlag() throws Exception { runCommandForced( - "--initial_renew_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--initial_renew_billing_cost=\"USD 42.42\"", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getStandardRenewCost(DateTime.now(UTC))) .isEqualTo(Money.of(USD, 42.42)); } @@ -103,6 +118,7 @@ public class CreateTldCommandTest extends CommandTestCase { now.toString(DATETIME_FORMAT), tomorrow.toString(DATETIME_FORMAT)), "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); Registry registry = Registry.get("xn--q9jyb4c"); @@ -116,58 +132,83 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_addGracePeriodFlag() throws Exception { - runCommandForced("--add_grace_period=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--add_grace_period=PT300S", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } @Test public void testSuccess_roidSuffixWorks() throws Exception { - runCommandForced("--roid_suffix=RSUFFIX", "tld"); + runCommandForced("--roid_suffix=RSUFFIX", "--dns_writer=VoidDnsWriter", "tld"); assertThat(Registry.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX"); } @Test public void testSuccess_escrow() throws Exception { - runCommandForced("--escrow=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--escrow=true", "--roid_suffix=Q9JYB4C", "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue(); } @Test public void testSuccess_noEscrow() throws Exception { - runCommandForced("--escrow=false", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--escrow=false", "--roid_suffix=Q9JYB4C", "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse(); } @Test public void testSuccess_redemptionGracePeriodFlag() throws Exception { - runCommandForced("--redemption_grace_period=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--redemption_grace_period=PT300S", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isEqualTo(standardMinutes(5)); } @Test public void testSuccess_pendingDeleteLengthFlag() throws Exception { - runCommandForced("--pending_delete_length=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--pending_delete_length=PT300S", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); } @Test public void testSuccess_automaticTransferLengthFlag() throws Exception { - runCommandForced("--automatic_transfer_length=PT300S", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--automatic_transfer_length=PT300S", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getAutomaticTransferLength()) .isEqualTo(standardMinutes(5)); } @Test public void testSuccess_createBillingCostFlag() throws Exception { - runCommandForced("--create_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--create_billing_cost=\"USD 42.42\"", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42)); } @Test public void testSuccess_restoreBillingCostFlag() throws Exception { runCommandForced( - "--restore_billing_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--restore_billing_cost=\"USD 42.42\"", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost()) .isEqualTo(Money.of(USD, 42.42)); } @@ -175,7 +216,10 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_serverStatusChangeCostFlag() throws Exception { runCommandForced( - "--server_status_change_cost=\"USD 42.42\"", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--server_status_change_cost=\"USD 42.42\"", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getServerStatusChangeCost()) .isEqualTo(Money.of(USD, 42.42)); } @@ -188,6 +232,7 @@ public class CreateTldCommandTest extends CommandTestCase { "--initial_renew_billing_cost=\"JPY 101112\"", "--server_status_change_cost=\"JPY 97865\"", "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); Registry registry = Registry.get("xn--q9jyb4c"); assertThat(registry.getStandardCreateCost()).isEqualTo(Money.ofMajor(JPY, 12345)); @@ -197,7 +242,7 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_multipartTld() throws Exception { - runCommandForced("co.uk", "--roid_suffix=COUK"); + runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writer=VoidDnsWriter"); Registry registry = Registry.get("co.uk"); assertThat(registry.getTldState(new DateTime())).isEqualTo(TldState.PREDELEGATION); @@ -210,7 +255,10 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_setReservedLists() throws Exception { runCommandForced( - "--reserved_lists=xn--q9jyb4c_abuse,common_abuse", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--reserved_lists=xn--q9jyb4c_abuse,common_abuse", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(transform(Registry.get("xn--q9jyb4c").getReservedLists(), GET_NAME_FUNCTION)) .containsExactly("xn--q9jyb4c_abuse", "common_abuse"); } @@ -220,6 +268,7 @@ public class CreateTldCommandTest extends CommandTestCase { runCommandForced( "--lrp_period=2004-06-09T12:30:00Z/2004-07-10T13:30:00Z", "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod()).isEqualTo( new Interval( @@ -228,89 +277,121 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_setPremiumPriceAckRequired() throws Exception { - runCommandForced("--premium_price_ack_required=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--premium_price_ack_required=true", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getPremiumPriceAckRequired()).isTrue(); } @Test public void testFailure_invalidAddGracePeriod() throws Exception { - thrown.expect(IllegalArgumentException.class); - runCommandForced("--add_grace_period=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); + runCommandForced( + "--add_grace_period=5m", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test public void testFailure_invalidRedemptionGracePeriod() throws Exception { - thrown.expect(IllegalArgumentException.class); - runCommandForced("--redemption_grace_period=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); + runCommandForced( + "--redemption_grace_period=5m", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test public void testFailure_invalidPendingDeleteLength() throws Exception { - thrown.expect(IllegalArgumentException.class); - runCommandForced("--pending_delete_length=5m", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); + runCommandForced( + "--pending_delete_length=5m", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test public void testFailure_invalidTldState() throws Exception { - thrown.expect(ParameterException.class); - runCommandForced("--initial_tld_state=INVALID_STATE", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + thrown.expect(ParameterException.class, "Invalid value for --initial_tld_state parameter"); + runCommandForced( + "--initial_tld_state=INVALID_STATE", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test public void testFailure_bothTldStateFlags() throws Exception { DateTime now = DateTime.now(UTC); - thrown.expect(IllegalArgumentException.class); + thrown.expect( + IllegalArgumentException.class, + "Don't pass both --initial_tld_state and --tld_state_transitions"); runCommandForced( String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.plus(1)), "--initial_tld_state=GENERAL_AVAILABILITY", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); } @Test public void testFailure_negativeInitialRenewBillingCost() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Renew billing cost cannot be negative"); runCommandForced( - "--initial_renew_billing_cost=USD -42", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + "--initial_renew_billing_cost=USD -42", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test public void testFailure_invalidEapCurrency() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect( + IllegalArgumentException.class, "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_writer=VoidDnsWriter", "xn--q9jyb4c"); } @Test public void testFailure_noTldName() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect(ParameterException.class, "Main parameters are required (\"Names of the TLDs\")"); runCommandForced(); } @Test - public void testFailure_duplicateArguments() throws Exception { - thrown.expect(IllegalArgumentException.class); - runCommandForced("foo", "xn--q9jyb4c", "xn--q9jyb4c"); + public void testFailure_noDnsWriter() throws Exception { + thrown.expect(IllegalArgumentException.class, "A DNS writer must be specified"); + runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C"); } @Test public void testFailure_alreadyExists() throws Exception { createTld("xn--q9jyb4c"); - thrown.expect(IllegalStateException.class); - runCommandForced("--roid_suffix=NOTDUPE", "xn--q9jyb4c"); + thrown.expect(IllegalStateException.class, "TLD 'xn--q9jyb4c' already exists"); + runCommandForced("--roid_suffix=NOTDUPE", "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); } @Test public void testFailure_tldStartsWithDigit() throws Exception { - thrown.expect(IllegalArgumentException.class); - runCommandForced("1foo", "--roid_suffix=1FOO"); + thrown.expect(IllegalArgumentException.class, "TLDs cannot begin with a number"); + runCommandForced("1foo", "--roid_suffix=1FOO", "--dns_writer=VoidDnsWriter"); } @Test public void testSuccess_setAllowedRegistrants() throws Exception { - runCommandForced("--allowed_registrants=alice,bob", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--allowed_registrants=alice,bob", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) .containsExactly("alice", "bob"); } @@ -320,6 +401,7 @@ public class CreateTldCommandTest extends CommandTestCase { runCommandForced( "--allowed_nameservers=ns1.example.com,ns2.example.com", "--roid_suffix=Q9JYB4C", + "--dns_writer=FooDnsWriter", "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns1.example.com", "ns2.example.com"); @@ -327,7 +409,11 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_setDomainCreateRestricted() throws Exception { - runCommandForced("--domain_create_restricted=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--domain_create_restricted=true", + "--roid_suffix=Q9JYB4C", + "--dns_writer=FooDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getDomainCreateRestricted()).isTrue(); } @@ -401,26 +487,42 @@ public class CreateTldCommandTest extends CommandTestCase { @Test public void testSuccess_setPremiumList() throws Exception { - runCommandForced("--premium_list=xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--premium_list=xn--q9jyb4c", + "--roid_suffix=Q9JYB4C", + "--dns_writer=FooDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getPremiumList().getName()).isEqualTo("xn--q9jyb4c"); } @Test public void testSuccess_setDriveFolderIdToValue() throws Exception { - runCommandForced("--drive_folder_id=madmax2030", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--drive_folder_id=madmax2030", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030"); } @Test public void testSuccess_setDriveFolderIdToNull() throws Exception { - runCommandForced("--drive_folder_id=null", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--drive_folder_id=null", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isNull(); } @Test public void testFailure_setPremiumListThatDoesntExist() throws Exception { thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist"); - runCommandForced("--premium_list=phonies", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--premium_list=phonies", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } @Test @@ -431,17 +533,34 @@ public class CreateTldCommandTest extends CommandTestCase { runCommandForced( "--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); } @Test public void testFailure_addLrpPeriod_badInterval() throws Exception { thrown.expect(ParameterException.class, "--lrp_period=foobar not an ISO-8601 interval"); - runCommandForced("--lrp_period=foobar", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--lrp_period=foobar", + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); + } + + @Test + public void testFailure_specifiedDnsWriter_doesntExist() throws Exception { + thrown.expect( + IllegalArgumentException.class, "The DNS writer 'InvalidDnsWriter' doesn't exist"); + runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writer=InvalidDnsWriter"); } private void runSuccessfulReservedListsTest(String reservedLists) throws Exception { - runCommandForced("--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--reserved_lists", + reservedLists, + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } private void runReservedListsTestOverride(String reservedLists) throws Exception { @@ -450,6 +569,7 @@ public class CreateTldCommandTest extends CommandTestCase { "--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", "xn--q9jyb4c"); } @@ -457,6 +577,11 @@ public class CreateTldCommandTest extends CommandTestCase { String reservedLists, Class errorClass, String errorMsg) throws Exception { thrown.expect(errorClass, errorMsg); - runCommandForced("--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", "xn--q9jyb4c"); + runCommandForced( + "--reserved_lists", + reservedLists, + "--roid_suffix=Q9JYB4C", + "--dns_writer=VoidDnsWriter", + "xn--q9jyb4c"); } } diff --git a/javatests/google/registry/tools/SetupOteCommandTest.java b/javatests/google/registry/tools/SetupOteCommandTest.java index 687a8e66c..36584727d 100644 --- a/javatests/google/registry/tools/SetupOteCommandTest.java +++ b/javatests/google/registry/tools/SetupOteCommandTest.java @@ -47,6 +47,7 @@ public class SetupOteCommandTest extends CommandTestCase { @Before public void init() { + command.dnsWriterNames = ImmutableSet.of("FooDnsWriter", "BarDnsWriter", "VoidDnsWriter"); command.passwordGenerator = passwordGenerator; persistPremiumList("default_sandbox_list", "sandbox,USD 1000"); persistPremiumList("alternate_list", "rich,USD 3000"); @@ -57,6 +58,7 @@ public class SetupOteCommandTest extends CommandTestCase { String tldName, String roidSuffix, TldState tldState, + String dnsWriter, String premiumList, Duration addGracePeriodLength, Duration redemptionGracePeriodLength, @@ -65,10 +67,9 @@ public class SetupOteCommandTest extends CommandTestCase { assertThat(registry).isNotNull(); assertThat(registry.getRoidSuffix()).isEqualTo(roidSuffix); assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(tldState); - + assertThat(registry.getDnsWriter()).isEqualTo(dnsWriter); assertThat(registry.getPremiumList()).isNotNull(); assertThat(registry.getPremiumList().getName()).isEqualTo(premiumList); - assertThat(registry.getAddGracePeriodLength()).isEqualTo(addGracePeriodLength); assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(redemptionGracePeriodLength); assertThat(registry.getPendingDeleteLength()).isEqualTo(pendingDeleteLength); @@ -76,11 +77,12 @@ public class SetupOteCommandTest extends CommandTestCase { /** Verify TLD creation with registry default durations. */ private void verifyTldCreation( - String tldName, String roidSuffix, TldState tldState, String premiumList) { + String tldName, String roidSuffix, TldState tldState, String dnsWriter, String premiumList) { verifyTldCreation( tldName, roidSuffix, tldState, + dnsWriter, premiumList, Registry.DEFAULT_ADD_GRACE_PERIOD, Registry.DEFAULT_REDEMPTION_GRACE_PERIOD, @@ -108,14 +110,18 @@ public class SetupOteCommandTest extends CommandTestCase { runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "default_sandbox_list"); - verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "default_sandbox_list"); + verifyTldCreation( + "blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "VoidDnsWriter", "default_sandbox_list"); + verifyTldCreation( + "blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "VoidDnsWriter", "default_sandbox_list"); verifyTldCreation( "blobio-ga", "BLOBIOG2", TldState.GENERAL_AVAILABILITY, + "VoidDnsWriter", "default_sandbox_list", Duration.standardMinutes(60), Duration.standardMinutes(10), @@ -135,14 +141,18 @@ public class SetupOteCommandTest extends CommandTestCase { runCommandForced( "--ip_whitelist=1.1.1.1,2.2.2.2", "--registrar=blobio", + "--dns_writer=FooDnsWriter", "--certfile=" + getCertFilename()); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "default_sandbox_list"); - verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "default_sandbox_list"); + verifyTldCreation( + "blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "FooDnsWriter", "default_sandbox_list"); + verifyTldCreation( + "blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "FooDnsWriter", "default_sandbox_list"); verifyTldCreation( "blobio-ga", "BLOBIOG2", TldState.GENERAL_AVAILABILITY, + "FooDnsWriter", "default_sandbox_list", Duration.standardMinutes(60), Duration.standardMinutes(10), @@ -163,14 +173,18 @@ public class SetupOteCommandTest extends CommandTestCase { "--ip_whitelist=1.1.1.1", "--registrar=blobio", "--certfile=" + getCertFilename(), + "--dns_writer=BarDnsWriter", "--premium_list=alternate_list"); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "alternate_list"); - verifyTldCreation("blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "alternate_list"); + verifyTldCreation( + "blobio-sunrise", "BLOBIOS0", TldState.SUNRISE, "BarDnsWriter", "alternate_list"); + verifyTldCreation( + "blobio-landrush", "BLOBIOL1", TldState.LANDRUSH, "BarDnsWriter", "alternate_list"); verifyTldCreation( "blobio-ga", "BLOBIOG2", TldState.GENERAL_AVAILABILITY, + "BarDnsWriter", "alternate_list", Duration.standardMinutes(60), Duration.standardMinutes(10), @@ -187,79 +201,108 @@ public class SetupOteCommandTest extends CommandTestCase { @Test public void testFailure_missingIpWhitelist() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect(ParameterException.class, "option is required: -w, --ip_whitelist"); runCommandForced( "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_missingRegistrar() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect(ParameterException.class, "option is required: -r, --registrar"); runCommandForced( "--ip_whitelist=1.1.1.1", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_missingCertificateFile() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect(ParameterException.class, "option is required: -c, --certfile"); runCommandForced( "--ip_whitelist=1.1.1.1", + "--dns_writer=VoidDnsWriter", + "--registrar=blobio"); + } + + @Test + public void testFailure_missingDnsWriter() throws Exception { + thrown.expect(ParameterException.class, "option is required: --dns_writer"); + runCommandForced( + "--ip_whitelist=1.1.1.1", + "--certfile=" + getCertFilename(), "--registrar=blobio"); } @Test public void testFailure_invalidCert() throws Exception { - thrown.expect(CertificateParsingException.class); + thrown.expect(CertificateParsingException.class, "No X509Certificate found"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=/dev/null"); } @Test public void testFailure_invalidRegistrar() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Registrar name is invalid"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=3blobio", + "--dns_writer=VoidDnsWriter", + "--certfile=" + getCertFilename()); + } + + @Test + public void testFailure_invalidDnsWriter() throws Exception { + thrown.expect( + IllegalArgumentException.class, "The DNS writer 'InvalidDnsWriter' doesn't exist"); + runCommandForced( + "--ip_whitelist=1.1.1.1", + "--registrar=blobio", + "--dns_writer=InvalidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_registrarTooShort() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Registrar name is invalid"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=bl", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_registrarTooLong() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Registrar name is invalid"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobiotoooolong", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_registrarInvalidCharacter() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Registrar name is invalid"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blo#bio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @Test public void testFailure_invalidPremiumList() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "The premium list 'foo' doesn't exist"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename(), "--premium_list=foo"); } @@ -267,10 +310,11 @@ public class SetupOteCommandTest extends CommandTestCase { @Test public void testFailure_tldExists() throws Exception { createTld("blobio-sunrise"); - thrown.expect(IllegalStateException.class); + thrown.expect(IllegalStateException.class, "TLD 'blobio-sunrise' already exists"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } @@ -281,10 +325,11 @@ public class SetupOteCommandTest extends CommandTestCase { .setRegistrarName("blobio-1") .build(); persistResource(registrar); - thrown.expect(IllegalStateException.class); + thrown.expect(IllegalStateException.class, "Registrar blobio-1 already exists"); runCommandForced( "--ip_whitelist=1.1.1.1", "--registrar=blobio", + "--dns_writer=VoidDnsWriter", "--certfile=" + getCertFilename()); } } diff --git a/javatests/google/registry/tools/UpdateTldCommandTest.java b/javatests/google/registry/tools/UpdateTldCommandTest.java index 234e449d3..59911798f 100644 --- a/javatests/google/registry/tools/UpdateTldCommandTest.java +++ b/javatests/google/registry/tools/UpdateTldCommandTest.java @@ -59,6 +59,7 @@ public class UpdateTldCommandTest extends CommandTestCase { persistReservedList("xn--q9jyb4c_r1", "foo,FULLY_BLOCKED"); persistReservedList("xn--q9jyb4c_r2", "moop,FULLY_BLOCKED"); createTld("xn--q9jyb4c"); + command.dnsWriterNames = ImmutableSet.of("VoidDnsWriter", "FooDnsWriter"); } @Test @@ -173,6 +174,13 @@ public class UpdateTldCommandTest extends CommandTestCase { assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); } + @Test + public void testSuccess_dnsWriter() throws Exception { + assertThat(Registry.get("xn--q9jyb4c").getDnsWriter()).isEqualTo("VoidDnsWriter"); + runCommandForced("--dns_writer=FooDnsWriter", "xn--q9jyb4c"); + assertThat(Registry.get("xn--q9jyb4c").getDnsWriter()).isEqualTo("FooDnsWriter"); + } + @Test public void testSuccess_escrow() throws Exception { runCommandForced("--escrow=true", "xn--q9jyb4c"); @@ -445,37 +453,42 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_invalidAddGracePeriod() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); runCommandForced("--add_grace_period=5m", "xn--q9jyb4c"); } @Test public void testFailure_invalidRedemptionGracePeriod() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c"); } @Test public void testFailure_invalidPendingDeleteLength() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c"); } @Test public void testFailure_invalidTldState() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, + "INVALID_STATE not formatted correctly or has transition times out of order"); runCommandForced("--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c"); } @Test public void testFailure_invalidTldStateTransitionTime() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, + "INVALID_STATE not formatted correctly or has transition times out of order"); runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c"); } @Test public void testFailure_tldStatesOutOfOrder() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect( + IllegalArgumentException.class, "The TLD states are chronologically out of order"); runCommandForced( String.format( "--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION", now, now.plusMonths(1)), @@ -484,7 +497,9 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_duplicateTldStateTransitions() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect( + IllegalArgumentException.class, + "The TLD states are chronologically out of order"); runCommandForced( String.format("--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)), "xn--q9jyb4c"); @@ -492,7 +507,8 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_duplicateTldStateTransitionTimes() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "not formatted correctly or has transition times out of order"); runCommandForced( String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now), "xn--q9jyb4c"); @@ -500,7 +516,8 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_outOfOrderTldStateTransitionTimes() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "not formatted correctly or has transition times out of order"); runCommandForced( String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.minus(1)), "xn--q9jyb4c"); @@ -567,15 +584,15 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_invalidRenewBillingCost() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "not formatted correctly or has transition times out of order"); runCommandForced( - String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME), - "xn--q9jyb4c"); + String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME), "xn--q9jyb4c"); } @Test public void testFailure_negativeRenewBillingCost() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Renew billing cost cannot be negative"); runCommandForced( String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME), "xn--q9jyb4c"); @@ -583,13 +600,15 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_invalidRenewCostTransitionTime() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "not formatted correctly or has transition times out of order"); runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c"); } @Test public void testFailure_duplicateRenewCostTransitionTimes() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "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"); @@ -597,7 +616,8 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_outOfOrderRenewCostTransitionTimes() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect( + ParameterException.class, "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(1)), "xn--q9jyb4c"); @@ -605,28 +625,35 @@ public class UpdateTldCommandTest extends CommandTestCase { @Test public void testFailure_noTldName() throws Exception { - thrown.expect(ParameterException.class); + thrown.expect(ParameterException.class, "Main parameters are required (\"Names of the TLDs\")"); runCommandForced(); } @Test - public void testFailure_oneArgumentDoesNotExist() throws Exception { - thrown.expect(IllegalArgumentException.class); + public void testFailure_oneTldDoesNotExist() throws Exception { + thrown.expect(IllegalArgumentException.class, "TLD foo does not exist"); runCommandForced("foo", "xn--q9jyb4c"); } @Test public void testFailure_duplicateArguments() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "Duplicate arguments found: 'xn--q9jyb4c'"); runCommandForced("xn--q9jyb4c", "xn--q9jyb4c"); } @Test public void testFailure_tldDoesNotExist() throws Exception { - thrown.expect(IllegalArgumentException.class); + thrown.expect(IllegalArgumentException.class, "TLD foobarbaz does not exist"); runCommandForced("foobarbaz"); } + @Test + public void testFailure_specifiedDnsWriter_doesntExist() throws Exception { + thrown.expect( + IllegalArgumentException.class, "The DNS writer 'InvalidDnsWriter' doesn't exist"); + runCommandForced("xn--q9jyb4c", "--dns_writer=InvalidDnsWriter"); + } + @Test public void testFailure_setNonExistentReservedLists() throws Exception { thrown.expect(