From 92190f8699febbb9671a4532c799ae951cc80d9b Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 25 May 2018 13:51:50 -0700 Subject: [PATCH] Merge the check_domain_fee nomulus command into check_domain I'm tired of running check_domain only to then realize I needed to run check_domain_fee instead because the domain ended up being premium. We require the use of the fee extension to register domains on all of our TLDs anyway so we might as well always be sending the fee extension when checking domains too. There's no additional harm in sending along the fee extension (it only sends back additional information that is often useful), so just make that the default and remove the extra unnecessary command. Note that check_domain_claims can't be merged in too because it fundamentally works differently. It doesn't query the availability of domain names for registration, just whether they're trademarked. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198097326 --- .../registry/tools/CheckDomainCommand.java | 2 +- .../registry/tools/CheckDomainFeeCommand.java | 48 ----------- java/google/registry/tools/RegistryTool.java | 1 - .../google/registry/tools/soy/DomainCheck.soy | 11 +++ .../registry/tools/soy/DomainCheckFee.soy | 46 ----------- .../tools/CheckDomainCommandTest.java | 12 +-- .../tools/CheckDomainFeeCommandTest.java | 80 ------------------- .../server/testdata/domain_check_multiple.xml | 13 --- .../testdata/domain_check_second_tld.xml | 11 --- 9 files changed, 18 insertions(+), 206 deletions(-) delete mode 100644 java/google/registry/tools/CheckDomainFeeCommand.java delete mode 100644 java/google/registry/tools/soy/DomainCheckFee.soy delete mode 100644 javatests/google/registry/tools/CheckDomainFeeCommandTest.java delete mode 100644 javatests/google/registry/tools/server/testdata/domain_check_multiple.xml delete mode 100644 javatests/google/registry/tools/server/testdata/domain_check_second_tld.xml diff --git a/java/google/registry/tools/CheckDomainCommand.java b/java/google/registry/tools/CheckDomainCommand.java index 9f5baf02f..d8377698f 100644 --- a/java/google/registry/tools/CheckDomainCommand.java +++ b/java/google/registry/tools/CheckDomainCommand.java @@ -22,7 +22,7 @@ import google.registry.tools.soy.DomainCheckSoyInfo; import java.util.Collection; import java.util.List; -/** A command to execute a domain check epp command. */ +/** A command to execute a domain check EPP command (including cost of a 1 year create). */ @Parameters(separators = " =", commandDescription = "Check domain availability") final class CheckDomainCommand extends NonMutatingEppToolCommand { diff --git a/java/google/registry/tools/CheckDomainFeeCommand.java b/java/google/registry/tools/CheckDomainFeeCommand.java deleted file mode 100644 index 743122732..000000000 --- a/java/google/registry/tools/CheckDomainFeeCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2018 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.beust.jcommander.Parameter; -import com.beust.jcommander.Parameters; -import com.google.common.collect.Multimap; -import com.google.template.soy.data.SoyMapData; -import google.registry.tools.soy.DomainCheckFeeSoyInfo; -import java.util.Collection; -import java.util.List; - -/** A command to execute a domain check fees epp command. */ -@Parameters(separators = " =", commandDescription = "Check domain fees (for a 1-year create)") -final class CheckDomainFeeCommand extends NonMutatingEppToolCommand { - - @Parameter( - names = {"-c", "--client"}, - description = "Client identifier of the registrar to execute the command as", - required = true) - String clientId; - - @Parameter( - description = "Domain(s) to check.", - required = true) - List mainParameters; - - @Override - void initEppToolCommand() { - Multimap domainNameMap = validateAndGroupDomainNamesByTld(mainParameters); - for (Collection values : domainNameMap.asMap().values()) { - setSoyTemplate(DomainCheckFeeSoyInfo.getInstance(), DomainCheckFeeSoyInfo.DOMAINCHECKFEE); - addSoyRecord(clientId, new SoyMapData("domainNames", values)); - } - } -} diff --git a/java/google/registry/tools/RegistryTool.java b/java/google/registry/tools/RegistryTool.java index 5f9c24cae..eee918d55 100644 --- a/java/google/registry/tools/RegistryTool.java +++ b/java/google/registry/tools/RegistryTool.java @@ -33,7 +33,6 @@ public final class RegistryTool { .put("canonicalize_labels", CanonicalizeLabelsCommand.class) .put("check_domain", CheckDomainCommand.class) .put("check_domain_claims", CheckDomainClaimsCommand.class) - .put("check_domain_fee", CheckDomainFeeCommand.class) .put("check_snapshot", CheckSnapshotCommand.class) .put("convert_idn", ConvertIdnCommand.class) .put("count_domains", CountDomainsCommand.class) diff --git a/java/google/registry/tools/soy/DomainCheck.soy b/java/google/registry/tools/soy/DomainCheck.soy index 3520cf549..35dfa8c36 100644 --- a/java/google/registry/tools/soy/DomainCheck.soy +++ b/java/google/registry/tools/soy/DomainCheck.soy @@ -29,6 +29,17 @@ {/for} + + + {for $d in $domainNames} + + {$d} + create + 1 + + {/for} + + RegistryTool diff --git a/java/google/registry/tools/soy/DomainCheckFee.soy b/java/google/registry/tools/soy/DomainCheckFee.soy deleted file mode 100644 index 06e0eb636..000000000 --- a/java/google/registry/tools/soy/DomainCheckFee.soy +++ /dev/null @@ -1,46 +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. - -{namespace domain.registry.tools} - -/** - * Domain check fee request - */ -{template .domaincheckfee stricthtml="false"} -{@param domainNames: list} - - - - - - {for $d in $domainNames} - {$d} - {/for} - - - - - {for $d in $domainNames} - - {$d} - create - 1 - - {/for} - - - RegistryTool - - -{/template} diff --git a/javatests/google/registry/tools/CheckDomainCommandTest.java b/javatests/google/registry/tools/CheckDomainCommandTest.java index f0095edb7..a10d09de4 100644 --- a/javatests/google/registry/tools/CheckDomainCommandTest.java +++ b/javatests/google/registry/tools/CheckDomainCommandTest.java @@ -25,7 +25,7 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase { - - @Test - public void testSuccess() throws Exception { - runCommand("--client=NewRegistrar", "example.tld"); - eppVerifier.expectDryRun().verifySent("domain_check_fee.xml"); - } - - @Test - public void testSuccess_multipleTlds() throws Exception { - runCommand("--client=NewRegistrar", "example.tld", "example.tld2"); - eppVerifier - .expectDryRun() - .verifySent("domain_check_fee.xml") - .verifySent("domain_check_fee_second_tld.xml"); - } - - @Test - public void testSuccess_multipleDomains() throws Exception { - runCommand( - "--client=NewRegistrar", - "example.tld", - "example2.tld", - "example3.tld"); - eppVerifier.expectDryRun().verifySent("domain_check_fee_multiple.xml"); - } - - @Test - public void testSuccess_multipleDomainsAndTlds() throws Exception { - runCommand( - "--client=NewRegistrar", - "example.tld", - "example2.tld", - "example3.tld", - "example.tld2"); - eppVerifier - .expectDryRun() - .verifySent("domain_check_fee_multiple.xml") - .verifySent("domain_check_fee_second_tld.xml"); - } - - @Test - public void testFailure_missingClientId() throws Exception { - assertThrows(ParameterException.class, () -> runCommand("example.tld")); - } - - @Test - public void testFailure_NoMainParameter() throws Exception { - assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar")); - } - - @Test - public void testFailure_unknownFlag() throws Exception { - assertThrows( - ParameterException.class, - () -> runCommand("--client=NewRegistrar", "--unrecognized=foo", "example.tld")); - } -} diff --git a/javatests/google/registry/tools/server/testdata/domain_check_multiple.xml b/javatests/google/registry/tools/server/testdata/domain_check_multiple.xml deleted file mode 100644 index 667e2de8d..000000000 --- a/javatests/google/registry/tools/server/testdata/domain_check_multiple.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - example.tld - example2.tld - example3.tld - - - RegistryTool - - diff --git a/javatests/google/registry/tools/server/testdata/domain_check_second_tld.xml b/javatests/google/registry/tools/server/testdata/domain_check_second_tld.xml deleted file mode 100644 index 974b4d261..000000000 --- a/javatests/google/registry/tools/server/testdata/domain_check_second_tld.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - example.tld2 - - - RegistryTool - -