Make name and address fields required on Registrar

The absence of these fields causes RDE failures, so they are in effect
required on any functioning registry system. We are currently
experiencing problems in sandbox caused by null values on these fields.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155474895
This commit is contained in:
mcilwain 2017-05-09 00:27:41 -07:00 committed by Ben McIlwain
parent 5313ca58d6
commit ef1487cb57
18 changed files with 460 additions and 272 deletions

View file

@ -15,7 +15,6 @@
package google.registry.tools;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.Iterables.filter;
@ -25,11 +24,11 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE;
import static google.registry.tools.RegistryToolEnvironment.PRODUCTION;
import static google.registry.tools.RegistryToolEnvironment.SANDBOX;
import static google.registry.tools.RegistryToolEnvironment.UNITTEST;
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import static google.registry.util.RegistrarUtils.normalizeClientId;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
@ -45,10 +44,6 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand
private static final ImmutableSet<RegistryToolEnvironment> ENVIRONMENTS_ALLOWING_GROUP_CREATION =
ImmutableSet.of(PRODUCTION, SANDBOX, UNITTEST);
// Allows test cases to be cleaner.
@VisibleForTesting
static boolean requireAddress = true;
@Parameter(
names = "--create_groups",
description = "Whether the Google Groups for this registrar should be created",
@ -65,12 +60,10 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand
@Override
protected void initRegistrarCommand() throws Exception {
checkArgument(mainParameters.size() == 1, "Must specify exactly one client identifier.");
checkNotNull(emptyToNull(password), "--password is a required field");
checkNotNull(registrarName, "--name is a required field");
checkNotNull(icannReferralEmail, "--icann_referral_email is a required field");
if (requireAddress) {
checkNotNull(street, "Address fields are required when creating a registrar");
}
checkArgumentNotNull(emptyToNull(password), "--password is a required field");
checkArgumentNotNull(registrarName, "--name is a required field");
checkArgumentNotNull(icannReferralEmail, "--icann_referral_email is a required field");
checkArgumentNotNull(street, "Address fields are required when creating a registrar");
// Default new registrars to active.
registrarState = Optional.fromNullable(registrarState).or(ACTIVE);
}