Remove GtechTool (#242)

It is burdensome to have to maintain two sets of tools, one of which
contains a strict subset of functionalities of the other. All admins
should use the same tool and their ability to administer should be
restricted by the IAM roles they have, not the tools they use.
This commit is contained in:
Lai Jiang 2019-08-26 17:15:48 -04:00 committed by GitHub
parent c645fe6766
commit f72c6c3c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1 additions and 201 deletions

View file

@ -1,32 +0,0 @@
// Copyright 2017 The Nomulus 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;
/** 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 {
@Override
void assertAllowedEnvironment() {
checkArgument(
RegistryEnvironment.get() == RegistryEnvironment.SANDBOX,
"This command can only be run in the sandbox environment");
}
}

View file

@ -1,83 +0,0 @@
// Copyright 2017 The Nomulus 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.annotations.VisibleForTesting;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** Command line interface with a subset of commands that are safe for tech support to run. */
public final class GtechTool {
/** Names of commands from {@link RegistryTool#COMMAND_MAP} to include in GtechTool. */
@VisibleForTesting
static final ImmutableSet<String> COMMAND_SET = ImmutableSet.of(
"canonicalize_labels",
"check_domain",
"check_domain_claims",
"convert_idn",
"count_domains",
"create_anchor_tenant",
"create_contact",
"create_domain",
"create_host",
"create_registrar",
"create_registrar_groups",
"create_sandbox_tld",
"delete_domain",
"generate_dns_report",
"get_allocation_token",
"get_claims_list",
"get_contact",
"get_domain",
"get_history_entries",
"get_host",
"get_registrar",
"get_routing_map",
"get_schema",
"get_schema_tree",
"get_tld",
"hash_certificate",
"list_registrars",
"list_tlds",
"lock_domain",
"login",
"logout",
"registrar_contact",
"setup_ote",
"uniform_rapid_suspension",
"unlock_domain",
"unrenew_domain",
"update_domain",
"update_registrar",
"update_sandbox_tld",
"update_server_locks",
"validate_login_credentials",
"verify_ote",
"whois_query");
@VisibleForTesting
static final ImmutableMap<String, Class<? extends Command>> COMMAND_MAP =
ImmutableMap.copyOf(Maps.filterKeys(RegistryTool.COMMAND_MAP, Predicates.in(COMMAND_SET)));
public static void main(String[] args) throws Exception {
RegistryToolEnvironment.parseFromArgs(args).setup();
try (RegistryCli cli = new RegistryCli("gtech_tool", COMMAND_MAP)) {
cli.run(args);
}
}
}

View file

@ -44,8 +44,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
final class RegistryCli implements AutoCloseable, CommandRunner { final class RegistryCli implements AutoCloseable, CommandRunner {
// The environment parameter is parsed twice: once here, and once with {@link // The environment parameter is parsed twice: once here, and once with {@link
// RegistryToolEnvironment#parseFromArgs} in the {@link RegistryTool#main} or {@link // RegistryToolEnvironment#parseFromArgs} in the {@link RegistryTool#main} function.
// GtechTool#main} functions.
// //
// The flag names must be in sync between the two, and also - this is ugly and we should feel bad. // The flag names must be in sync between the two, and also - this is ugly and we should feel bad.
@Parameter( @Parameter(

View file

@ -44,7 +44,6 @@ public final class RegistryTool {
.put("create_registrar", CreateRegistrarCommand.class) .put("create_registrar", CreateRegistrarCommand.class)
.put("create_registrar_groups", CreateRegistrarGroupsCommand.class) .put("create_registrar_groups", CreateRegistrarGroupsCommand.class)
.put("create_reserved_list", CreateReservedListCommand.class) .put("create_reserved_list", CreateReservedListCommand.class)
.put("create_sandbox_tld", CreateSandboxTldCommand.class)
.put("create_tld", CreateTldCommand.class) .put("create_tld", CreateTldCommand.class)
.put("curl", CurlCommand.class) .put("curl", CurlCommand.class)
.put("delete_allocation_tokens", DeleteAllocationTokensCommand.class) .put("delete_allocation_tokens", DeleteAllocationTokensCommand.class)
@ -114,7 +113,6 @@ public final class RegistryTool {
.put("update_premium_list", UpdatePremiumListCommand.class) .put("update_premium_list", UpdatePremiumListCommand.class)
.put("update_registrar", UpdateRegistrarCommand.class) .put("update_registrar", UpdateRegistrarCommand.class)
.put("update_reserved_list", UpdateReservedListCommand.class) .put("update_reserved_list", UpdateReservedListCommand.class)
.put("update_sandbox_tld", UpdateSandboxTldCommand.class)
.put("update_server_locks", UpdateServerLocksCommand.class) .put("update_server_locks", UpdateServerLocksCommand.class)
.put("update_tld", UpdateTldCommand.class) .put("update_tld", UpdateTldCommand.class)
.put("upload_claims_list", UploadClaimsListCommand.class) .put("upload_claims_list", UploadClaimsListCommand.class)

View file

@ -1,32 +0,0 @@
// Copyright 2017 The Nomulus 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;
/** 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 {
@Override
void assertAllowedEnvironment() {
checkArgument(
RegistryEnvironment.get() == RegistryEnvironment.SANDBOX,
"This command can only be run in the sandbox environment");
}
}

View file

@ -1,50 +0,0 @@
// Copyright 2017 The Nomulus 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.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.Sets;
import google.registry.testing.SystemPropertyRule;
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 SystemPropertyRule systemPropertyRule = new SystemPropertyRule();
@Before
public void init() {
RegistryToolEnvironment.UNITTEST.setup(systemPropertyRule);
}
@Test
public void test_commandMap_namesAreInAlphabeticalOrder() {
assertThat(GtechTool.COMMAND_MAP.keySet()).isInStrictOrder();
}
@Test
public void test_commandSet_namesAreSubsetOfRegistryToolCommands() {
assertWithMessage("commands in GtechTool.COMMAND_SET but not in RegistryTool.COMMAND_MAP")
.that(Sets.difference(GtechTool.COMMAND_SET, RegistryTool.COMMAND_MAP.keySet()))
.isEmpty();
}
}