Require that DNS writer be set on Registry entities

We ran into a bunch of prober deployment issues this past week when
attempting to spin up a new cluster because the newly created prober
TLDs had null values for the dnsWriter field. Given that VoidDnsWriter
exists, we can require that dnsWriter always be set, and have people
use that if DNS publishing is not required.

Also cleans up a bunch of related inconsistent exception messages and
tests not verifying said exception messages properly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154325830
This commit is contained in:
mcilwain 2017-04-26 11:58:09 -07:00 committed by Ben McIlwain
parent d7da112c19
commit d30f9411d8
11 changed files with 332 additions and 115 deletions

View file

@ -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<String> 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();
}