mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add registrar contact to OTE registrars
When creating the various registrar objects in Sandbox for OTE, we also give access to all the registrars' data to a given google account (identified by the email) This email has to belong to the registry's G-Suite account, just like in the registrar_contact command. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217728407
This commit is contained in:
parent
bc2c0350d7
commit
0f1f418034
3 changed files with 146 additions and 14 deletions
|
@ -15,15 +15,20 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.tools.CommandUtilities.promptForYes;
|
||||
import static google.registry.util.X509Utils.loadCertificate;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.re2j.Pattern;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.common.GaeUserIdConverter;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.tools.params.PathParameter;
|
||||
|
@ -53,6 +58,10 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
private static final Duration SHORT_REDEMPTION_GRACE_PERIOD = Duration.standardMinutes(10);
|
||||
private static final Duration SHORT_PENDING_DELETE_LENGTH = Duration.standardMinutes(5);
|
||||
|
||||
// Whether to prompt the user on command failures. Set to false for testing of these failures.
|
||||
@VisibleForTesting
|
||||
static boolean interactive = true;
|
||||
|
||||
private static final ImmutableSortedMap<DateTime, Money> EAP_FEE_SCHEDULE =
|
||||
ImmutableSortedMap.of(
|
||||
new DateTime(0),
|
||||
|
@ -87,6 +96,14 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
)
|
||||
private List<String> ipWhitelist = new ArrayList<>();
|
||||
|
||||
@Parameter(
|
||||
names = {"--email"},
|
||||
description =
|
||||
"the registrar's account to use for console access. "
|
||||
+ "Must be on the registry's G-Suite domain.",
|
||||
required = true)
|
||||
private String email;
|
||||
|
||||
@Parameter(
|
||||
names = {"-c", "--certfile"},
|
||||
description = "full path to cert file in PEM format (best if on local storage)",
|
||||
|
@ -130,6 +147,21 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
*/
|
||||
private int roidSuffixCounter = 0;
|
||||
|
||||
/** Runs a command, clearing the cache before and prompting the user on failures. */
|
||||
private void runCommand(Command command) {
|
||||
ofy().clearSessionCache();
|
||||
try {
|
||||
command.run();
|
||||
} catch (Exception e) {
|
||||
System.err.format("Command failed with error %s\n", e);
|
||||
if (interactive && promptForYes("Continue to next command?")) {
|
||||
return;
|
||||
}
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructs and runs a CreateTldCommand. */
|
||||
private void createTld(
|
||||
String tldName,
|
||||
|
@ -137,8 +169,7 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
Duration addGracePeriod,
|
||||
Duration redemptionGracePeriod,
|
||||
Duration pendingDeleteLength,
|
||||
boolean isEarlyAccess)
|
||||
throws Exception {
|
||||
boolean isEarlyAccess) {
|
||||
CreateTldCommand command = new CreateTldCommand();
|
||||
command.addGracePeriod = addGracePeriod;
|
||||
command.dnsWriters = dnsWriters;
|
||||
|
@ -158,11 +189,11 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
if (isEarlyAccess) {
|
||||
command.eapFeeSchedule = EAP_FEE_SCHEDULE;
|
||||
}
|
||||
command.run();
|
||||
runCommand(command);
|
||||
}
|
||||
|
||||
/** Constructs and runs a CreateRegistrarCommand */
|
||||
private void createRegistrar(String registrarName, String password, String tld) throws Exception {
|
||||
private void createRegistrar(String registrarName, String password, String tld) {
|
||||
CreateRegistrarCommand command = new CreateRegistrarCommand();
|
||||
command.mainParameters = ImmutableList.of(registrarName);
|
||||
command.createGoogleGroups = false; // Don't create Google Groups for OT&E registrars.
|
||||
|
@ -183,7 +214,19 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
command.phone = Optional.of("+1.2125550100");
|
||||
command.icannReferralEmail = "nightmare@registrar.test";
|
||||
command.force = force;
|
||||
command.run();
|
||||
runCommand(command);
|
||||
}
|
||||
|
||||
/** Constructs and runs a RegistrarContactCommand */
|
||||
private void createRegistrarContact(String registrarName) {
|
||||
RegistrarContactCommand command = new RegistrarContactCommand();
|
||||
command.mainParameters = ImmutableList.of(registrarName);
|
||||
command.mode = RegistrarContactCommand.Mode.CREATE;
|
||||
command.name = email;
|
||||
command.email = email;
|
||||
command.allowConsoleAccess = true;
|
||||
command.force = force;
|
||||
runCommand(command);
|
||||
}
|
||||
|
||||
/** Run any pre-execute command checks */
|
||||
|
@ -193,6 +236,14 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
REGISTRAR_PATTERN.matcher(registrar).matches(),
|
||||
"Registrar name is invalid (see usage text for requirements).");
|
||||
|
||||
// Make sure the email is "correct" - as in it's a valid email we can convert to gaeId
|
||||
// There's no need to look at the result - it'll be converted again inside
|
||||
// RegistrarContactCommand.
|
||||
checkNotNull(
|
||||
GaeUserIdConverter.convertEmailAddressToGaeUserId(email),
|
||||
"Email address %s is not associated with any GAE ID",
|
||||
email);
|
||||
|
||||
boolean warned = false;
|
||||
if (RegistryEnvironment.get() != RegistryEnvironment.SANDBOX
|
||||
&& RegistryEnvironment.get() != RegistryEnvironment.UNITTEST) {
|
||||
|
@ -227,7 +278,9 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
return "Creating TLD:\n"
|
||||
+ " " + registrar + "-eap\n"
|
||||
+ "Creating registrar:\n"
|
||||
+ " " + registrar + "-5 (access to TLD " + registrar + "-eap)";
|
||||
+ " " + registrar + "-5 (access to TLD " + registrar + "-eap)\n"
|
||||
+ "Giving contact access to this registrar:\n"
|
||||
+ " " + email;
|
||||
} else {
|
||||
return "Creating TLDs:\n"
|
||||
+ " " + registrar + "-sunrise\n"
|
||||
|
@ -239,7 +292,9 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
+ " " + registrar + "-2 (access to TLD " + registrar + "-landrush)\n"
|
||||
+ " " + registrar + "-3 (access to TLD " + registrar + "-ga)\n"
|
||||
+ " " + registrar + "-4 (access to TLD " + registrar + "-ga)\n"
|
||||
+ " " + registrar + "-5 (access to TLD " + registrar + "-eap)";
|
||||
+ " " + registrar + "-5 (access to TLD " + registrar + "-eap)\n"
|
||||
+ "Giving contact access to these registrars:\n"
|
||||
+ " " + email;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,6 +352,7 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo
|
|||
|
||||
for (List<String> r : registrars) {
|
||||
createRegistrar(r.get(0), r.get(1), r.get(2));
|
||||
createRegistrarContact(r.get(0));
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue