diff --git a/docs/registry-tool.md b/docs/registry-tool.md index 52998f9e1..79000e376 100644 --- a/docs/registry-tool.md +++ b/docs/registry-tool.md @@ -31,16 +31,6 @@ registry_tool without specifying a command name, e.g.: Note that the documentation for the commands comes from JCommander, which parses metadata contained within the code to yield documentation. -## Tech support commands - -There are actually two separate tools, `gtech_tool`, which is a collection of -lower impact commands intended to be used by tech support personnel, and -`registry_tool`, which is a superset of `gtech_tool` that contains additional -commands that are potentially more destructive and can change more aspects of -the system. A full list of `gtech_tool` commands can be found in -`GtechTool.java`, and the additional commands that only `registry_tool` has -access to are in `RegistryTool.java`. - ## Local and server-side commands There are two broad ways that commands are implemented: some that send requests diff --git a/java/google/registry/tools/BUILD b/java/google/registry/tools/BUILD index 039989252..fda18cd79 100644 --- a/java/google/registry/tools/BUILD +++ b/java/google/registry/tools/BUILD @@ -96,13 +96,3 @@ java_binary( ], ) -java_binary( - name = "gtech_tool", - create_executable = 1, - main_class = "google.registry.tools.GtechTool", - runtime_deps = [ - ":tools", - "//third_party/java/appengine:appengine-api-link", - "//third_party/java/appengine:appengine-remote-api-link", - ], -) diff --git a/java/google/registry/tools/CreateSandboxTldCommand.java b/java/google/registry/tools/CreateSandboxTldCommand.java deleted file mode 100644 index 877e291c5..000000000 --- a/java/google/registry/tools/CreateSandboxTldCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.tools; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.beust.jcommander.Parameters; -import google.registry.config.RegistryEnvironment; -import google.registry.tools.Command.GtechCommand; - -/** Command to create a TLD in sandbox, separated out for Gtech use. */ -@Parameters(separators = " =", commandDescription = "Create new sandbox TLD(s)") -final class CreateSandboxTldCommand extends CreateTldCommand implements GtechCommand { - - @Override - void assertAllowedEnvironment() { - checkArgument( - RegistryEnvironment.get() == RegistryEnvironment.SANDBOX, - "This command can only be run in the sandbox environment"); - } -} diff --git a/java/google/registry/tools/GtechTool.java b/java/google/registry/tools/GtechTool.java deleted file mode 100644 index c6b912450..000000000 --- a/java/google/registry/tools/GtechTool.java +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.tools; - -import com.google.common.collect.ImmutableMap; -import google.registry.tools.Command.GtechCommand; - -/** Command line interface with a subset of commands that are safe for tech support to run. */ -public final class GtechTool { - - /** - * Commands that exist in both {@link GtechTool} and {@link RegistryTool}. - * - *

Note: If changing the command-line name of any commands below, remember to resolve - * any invocations in scripts (e.g. PDT, ICANN reporting). - */ - static final ImmutableMap> COMMAND_MAP = - new ImmutableMap.Builder>() - .put("auction_status", AuctionStatusCommand.class) - .put("canonicalize_labels", CanonicalizeLabelsCommand.class) - .put("convert_idn", ConvertIdnCommand.class) - .put("create_anchor_tenant", CreateAnchorTenantCommand.class) - .put("create_contact", CreateContactCommand.class) - .put("create_credit", CreateCreditCommand.class) - .put("create_credit_balance", CreateCreditBalanceCommand.class) - .put("create_domain", CreateDomainCommand.class) - .put("create_host", CreateHostCommand.class) - .put("create_lrp_tokens", CreateLrpTokensCommand.class) - .put("create_registrar", CreateRegistrarCommand.class) - .put("create_registrar_groups", CreateRegistrarGroupsCommand.class) - .put("create_sandbox_tld", CreateSandboxTldCommand.class) - .put("delete_domain", DeleteDomainCommand.class) - .put("domain_application_info", DomainApplicationInfoCommand.class) - .put("domain_check", DomainCheckCommand.class) - .put("domain_check_claims", DomainCheckClaimsCommand.class) - .put("domain_check_fee", DomainCheckFeeCommand.class) - .put("generate_applications_report", GenerateApplicationsReportCommand.class) - .put("generate_auction_data", GenerateAuctionDataCommand.class) - .put("generate_dns_report", GenerateDnsReportCommand.class) - .put("get_application", GetApplicationCommand.class) - .put("get_application_ids", GetApplicationIdsCommand.class) - .put("get_applied_labels", GetAppliedLabelsCommand.class) - .put("get_contact", GetContactCommand.class) - .put("get_domain", GetDomainCommand.class) - .put("get_history_entries", GetHistoryEntriesCommand.class) - .put("get_host", GetHostCommand.class) - .put("get_lrp_token", GetLrpTokenCommand.class) - .put("get_registrar", GetRegistrarCommand.class) - .put("get_schema", GetSchemaCommand.class) - .put("get_schema_tree", GetSchemaTreeCommand.class) - .put("get_tld", GetTldCommand.class) - .put("hash_certificate", HashCertificateCommand.class) - .put("list_credits", ListCreditsCommand.class) - .put("list_registrars", ListRegistrarsCommand.class) - .put("list_tlds", ListTldsCommand.class) - .put("publish_detail_report", PublishDetailReportCommand.class) - .put("registrar_activity_report", RegistrarActivityReportCommand.class) - .put("registrar_contact", RegistrarContactCommand.class) - .put("setup_ote", SetupOteCommand.class) - .put("uniform_rapid_suspension", UniformRapidSuspensionCommand.class) - .put("update_registrar", UpdateRegistrarCommand.class) - .put("update_sandbox_tld", UpdateSandboxTldCommand.class) - .put("update_server_locks", UpdateServerLocksCommand.class) - .put("validate_login_credentials", ValidateLoginCredentialsCommand.class) - .put("verify_ote", VerifyOteCommand.class) - .put("whois_query", WhoisQueryCommand.class) - .build(); - - public static void main(String[] args) throws Exception { - RegistryToolEnvironment.parseFromArgs(args).setup(); - new RegistryCli().run("gtech_tool", args, COMMAND_MAP); - } -} diff --git a/java/google/registry/tools/RegistryTool.java b/java/google/registry/tools/RegistryTool.java index 15e1a79dc..2e90df5be 100644 --- a/java/google/registry/tools/RegistryTool.java +++ b/java/google/registry/tools/RegistryTool.java @@ -14,9 +14,7 @@ package google.registry.tools; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSortedMap; import google.registry.tools.javascrap.LoadAndResaveCommand; import google.registry.tools.javascrap.RemoveIpAddressCommand; @@ -29,51 +27,95 @@ public final class RegistryTool { *

Note: If changing the command-line name of any commands below, remember to resolve * any invocations in scripts (e.g. PDT, ICANN reporting). */ - @VisibleForTesting - static final ImmutableMap> COMMAND_MAP = - ImmutableSortedMap.>naturalOrder() - .putAll(GtechTool.COMMAND_MAP) + public static final ImmutableMap> COMMAND_MAP = + new ImmutableMap.Builder>() .put("allocate_domain", AllocateDomainCommand.class) + .put("auction_status", AuctionStatusCommand.class) + .put("canonicalize_labels", CanonicalizeLabelsCommand.class) .put("check_snapshot", CheckSnapshotCommand.class) + .put("convert_idn", ConvertIdnCommand.class) + .put("create_anchor_tenant", CreateAnchorTenantCommand.class) .put("create_auction_credits", CreateAuctionCreditsCommand.class) + .put("create_contact", CreateContactCommand.class) + .put("create_credit", CreateCreditCommand.class) + .put("create_credit_balance", CreateCreditBalanceCommand.class) + .put("create_domain", CreateDomainCommand.class) + .put("create_host", CreateHostCommand.class) + .put("create_lrp_tokens", CreateLrpTokensCommand.class) .put("create_premium_list", CreatePremiumListCommand.class) + .put("create_registrar", CreateRegistrarCommand.class) + .put("create_registrar_groups", CreateRegistrarGroupsCommand.class) .put("create_reserved_list", CreateReservedListCommand.class) .put("create_tld", CreateTldCommand.class) .put("delete_credit", DeleteCreditCommand.class) + .put("delete_domain", DeleteDomainCommand.class) .put("delete_entity", DeleteEntityCommand.class) .put("delete_epp_resource", DeleteEppResourceCommand.class) .put("delete_premium_list", DeletePremiumListCommand.class) .put("delete_reserved_list", DeleteReservedListCommand.class) + .put("domain_application_info", DomainApplicationInfoCommand.class) + .put("domain_check", DomainCheckCommand.class) + .put("domain_check_claims", DomainCheckClaimsCommand.class) + .put("domain_check_fee", DomainCheckFeeCommand.class) .put("encrypt_escrow_deposit", EncryptEscrowDepositCommand.class) .put("execute_epp", ExecuteEppCommand.class) + .put("generate_applications_report", GenerateApplicationsReportCommand.class) + .put("generate_auction_data", GenerateAuctionDataCommand.class) + .put("generate_dns_report", GenerateDnsReportCommand.class) .put("generate_escrow_deposit", GenerateEscrowDepositCommand.class) .put("generate_lordn", GenerateLordnCommand.class) .put("generate_zone_files", GenerateZoneFilesCommand.class) + .put("get_application", GetApplicationCommand.class) + .put("get_application_ids", GetApplicationIdsCommand.class) + .put("get_applied_labels", GetAppliedLabelsCommand.class) .put("get_claims_list", GetClaimsListCommand.class) + .put("get_contact", GetContactCommand.class) + .put("get_domain", GetDomainCommand.class) + .put("get_history_entries", GetHistoryEntriesCommand.class) + .put("get_host", GetHostCommand.class) + .put("get_lrp_token", GetLrpTokenCommand.class) + .put("get_registrar", GetRegistrarCommand.class) .put("get_resource_by_key", GetResourceByKeyCommand.class) + .put("get_schema", GetSchemaCommand.class) + .put("get_schema_tree", GetSchemaTreeCommand.class) + .put("get_tld", GetTldCommand.class) .put("ghostryde", GhostrydeCommand.class) + .put("hash_certificate", HashCertificateCommand.class) + .put("list_credits", ListCreditsCommand.class) .put("list_cursors", ListCursorsCommand.class) .put("list_domains", ListDomainsCommand.class) .put("list_hosts", ListHostsCommand.class) .put("list_premium_lists", ListPremiumListsCommand.class) + .put("list_registrars", ListRegistrarsCommand.class) .put("list_reserved_lists", ListReservedListsCommand.class) + .put("list_tlds", ListTldsCommand.class) .put("load_and_resave", LoadAndResaveCommand.class) .put("load_snapshot", LoadSnapshotCommand.class) .put("make_billing_tables", MakeBillingTablesCommand.class) .put("pending_escrow", PendingEscrowCommand.class) + .put("publish_detail_report", PublishDetailReportCommand.class) + .put("registrar_activity_report", RegistrarActivityReportCommand.class) + .put("registrar_contact", RegistrarContactCommand.class) .put("remove_ip_address", RemoveIpAddressCommand.class) .put("resave_environment_entities", ResaveEnvironmentEntitiesCommand.class) .put("send_escrow_report_to_icann", SendEscrowReportToIcannCommand.class) + .put("setup_ote", SetupOteCommand.class) + .put("uniform_rapid_suspension", UniformRapidSuspensionCommand.class) .put("update_application_status", UpdateApplicationStatusCommand.class) .put("update_claims_notice", UpdateClaimsNoticeCommand.class) .put("update_credits", UpdateCreditsCommand.class) .put("update_cursors", UpdateCursorsCommand.class) .put("update_premium_list", UpdatePremiumListCommand.class) + .put("update_registrar", UpdateRegistrarCommand.class) .put("update_reserved_list", UpdateReservedListCommand.class) + .put("update_server_locks", UpdateServerLocksCommand.class) .put("update_smd", UpdateSmdCommand.class) .put("update_tld", UpdateTldCommand.class) .put("upload_claims_list", UploadClaimsListCommand.class) .put("validate_escrow_deposit", ValidateEscrowDepositCommand.class) + .put("validate_login_credentials", ValidateLoginCredentialsCommand.class) + .put("verify_ote", VerifyOteCommand.class) + .put("whois_query", WhoisQueryCommand.class) .build(); public static void main(String[] args) throws Exception { diff --git a/java/google/registry/tools/UniformRapidSuspensionCommand.java b/java/google/registry/tools/UniformRapidSuspensionCommand.java index d7e193e79..93d6ffd36 100644 --- a/java/google/registry/tools/UniformRapidSuspensionCommand.java +++ b/java/google/registry/tools/UniformRapidSuspensionCommand.java @@ -181,7 +181,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand impleme if (undo) { return ""; } - StringBuilder undoBuilder = new StringBuilder("UNDO COMMAND:\n\ngtech_tool -e ") + StringBuilder undoBuilder = new StringBuilder("UNDO COMMAND:\n\n)") + .append("registry_tool -e ") .append(RegistryToolEnvironment.get()) .append(" uniform_rapid_suspension --undo --domain_name ") .append(domainName); diff --git a/java/google/registry/tools/UpdateSandboxTldCommand.java b/java/google/registry/tools/UpdateSandboxTldCommand.java deleted file mode 100644 index e6f83f809..000000000 --- a/java/google/registry/tools/UpdateSandboxTldCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.tools; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.beust.jcommander.Parameters; -import google.registry.config.RegistryEnvironment; -import google.registry.tools.Command.GtechCommand; - -/** Command to update a TLD in sandbox, separated out for Gtech use. */ -@Parameters(separators = " =", commandDescription = "Update new sandbox TLD(s)") -final class UpdateSandboxTldCommand extends UpdateTldCommand implements GtechCommand { - - @Override - void assertAllowedEnvironment() { - checkArgument( - RegistryEnvironment.get() == RegistryEnvironment.SANDBOX, - "This command can only be run in the sandbox environment"); - } -} diff --git a/javatests/google/registry/tools/GtechToolTest.java b/javatests/google/registry/tools/GtechToolTest.java deleted file mode 100644 index 1c926f8d9..000000000 --- a/javatests/google/registry/tools/GtechToolTest.java +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2016 The Domain Registry Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.tools; - -import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE; -import static com.google.common.base.CaseFormat.UPPER_CAMEL; -import static com.google.common.reflect.Reflection.getPackageName; -import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth.assertWithMessage; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import com.google.common.reflect.ClassPath; -import com.google.common.reflect.ClassPath.ClassInfo; -import com.google.common.truth.Expect; -import google.registry.tools.Command.GtechCommand; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.util.Map; -import java.util.Set; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Unit tests for {@link GtechTool}. */ -@RunWith(JUnit4.class) -public class GtechToolTest { - - @Rule - public final Expect expect = Expect.create(); - - @Before - public void init() { - RegistryToolEnvironment.UNITTEST.setup(); - } - - @Test - public void test_commandMap_namesAreInAlphabeticalOrder() throws Exception { - assertThat(GtechTool.COMMAND_MAP.keySet()).isStrictlyOrdered(); - } - - @Test - public void testThatAllCommandsAreInCliOptions() throws Exception { - Set> commandMapClasses = - ImmutableSet.copyOf(GtechTool.COMMAND_MAP.values()); - Set> commandsWithoutCliInvokers = - Sets.difference(getAllCommandClasses(), commandMapClasses); - String errorMsg = - "These Command classes are missing from GtechTool.COMMAND_MAP: " - + Joiner.on(", ").join(commandsWithoutCliInvokers); - assertWithMessage(errorMsg).that(commandsWithoutCliInvokers).isEmpty(); - } - - @Test - public void testThatCommandNamesAreDerivedFromClassNames() throws Exception { - for (Map.Entry> commandEntry : - GtechTool.COMMAND_MAP.entrySet()) { - String className = commandEntry.getValue().getSimpleName(); - expect.that(commandEntry.getKey()) - // JCommander names should match the class name, up to "Command" and case formatting. - .isEqualTo(UPPER_CAMEL.to(LOWER_UNDERSCORE, className.replaceFirst("Command$", ""))); - } - } - - /** - * Gets the set of all non-abstract classes implementing the {@link GtechCommand} interface - * (abstract class and interface subtypes of Command aren't expected to have cli commands). Note - * that this also filters out HelpCommand, which has special handling in {@link RegistryCli} and - * isn't in the command map. - * - * @throws IOException if reading the classpath resources fails. - */ - @SuppressWarnings("unchecked") - private ImmutableSet> getAllCommandClasses() throws IOException { - ImmutableSet.Builder> builder = new ImmutableSet.Builder<>(); - for (ClassInfo classInfo : ClassPath - .from(getClass().getClassLoader()) - .getTopLevelClasses(getPackageName(getClass()))) { - Class clazz = classInfo.load(); - if (GtechCommand.class.isAssignableFrom(clazz) - && !Modifier.isAbstract(clazz.getModifiers()) - && !Modifier.isInterface(clazz.getModifiers()) - && !clazz.equals(HelpCommand.class)) { - builder.add((Class) clazz); - } - } - return builder.build(); - } -}