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
This commit is contained in:
mcilwain 2018-05-25 13:51:50 -07:00 committed by jianglai
parent 674a914afc
commit 92190f8699
9 changed files with 18 additions and 206 deletions

View file

@ -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 {

View file

@ -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<String> mainParameters;
@Override
void initEppToolCommand() {
Multimap<String, String> domainNameMap = validateAndGroupDomainNamesByTld(mainParameters);
for (Collection<String> values : domainNameMap.asMap().values()) {
setSoyTemplate(DomainCheckFeeSoyInfo.getInstance(), DomainCheckFeeSoyInfo.DOMAINCHECKFEE);
addSoyRecord(clientId, new SoyMapData("domainNames", values));
}
}
}

View file

@ -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)

View file

@ -29,6 +29,17 @@
{/for}
</domain:check>
</check>
<extension>
<fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
{for $d in $domainNames}
<fee:domain>
<fee:name>{$d}</fee:name>
<fee:command>create</fee:command>
<fee:period unit="y">1</fee:period>
</fee:domain>
{/for}
</fee:check>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>

View file

@ -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<string>}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
{for $d in $domainNames}
<domain:name>{$d}</domain:name>
{/for}
</domain:check>
</check>
<extension>
<fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
{for $d in $domainNames}
<fee:domain>
<fee:name>{$d}</fee:name>
<fee:command>create</fee:command>
<fee:period unit="y">1</fee:period>
</fee:domain>
{/for}
</fee:check>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>
{/template}

View file

@ -25,7 +25,7 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
@Test
public void testSuccess() throws Exception {
runCommand("--client=NewRegistrar", "example.tld");
eppVerifier.expectDryRun().verifySent("domain_check.xml");
eppVerifier.expectDryRun().verifySent("domain_check_fee.xml");
}
@Test
@ -33,8 +33,8 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
runCommand("--client=NewRegistrar", "example.tld", "example.tld2");
eppVerifier
.expectDryRun()
.verifySent("domain_check.xml")
.verifySent("domain_check_second_tld.xml");
.verifySent("domain_check_fee.xml")
.verifySent("domain_check_fee_second_tld.xml");
}
@Test
@ -44,7 +44,7 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
"example.tld",
"example2.tld",
"example3.tld");
eppVerifier.expectDryRun().verifySent("domain_check_multiple.xml");
eppVerifier.expectDryRun().verifySent("domain_check_fee_multiple.xml");
}
@Test
@ -57,8 +57,8 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
"example.tld2");
eppVerifier
.expectDryRun()
.verifySent("domain_check_multiple.xml")
.verifySent("domain_check_second_tld.xml");
.verifySent("domain_check_fee_multiple.xml")
.verifySent("domain_check_fee_second_tld.xml");
}
@Test

View file

@ -1,80 +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 static google.registry.testing.JUnitBackports.assertThrows;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
/** Unit tests for {@link CheckDomainFeeCommand}. */
public class CheckDomainFeeCommandTest extends EppToolCommandTestCase<CheckDomainFeeCommand> {
@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"));
}
}

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:name>example2.tld</domain:name>
<domain:name>example3.tld</domain:name>
</domain:check>
</check>
<clTRID>RegistryTool</clTRID>
</command>
</epp>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld2</domain:name>
</domain:check>
</check>
<clTRID>RegistryTool</clTRID>
</command>
</epp>