mirror of
https://github.com/google/nomulus.git
synced 2025-07-09 12:43:24 +02:00
Allow a --token option when checking a domain (#556)
* Allow a --token option when checking a domain
This commit is contained in:
parent
dfeed63c40
commit
6990d6058f
4 changed files with 49 additions and 1 deletions
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
|
|
||||||
import com.beust.jcommander.Parameter;
|
import com.beust.jcommander.Parameter;
|
||||||
import com.beust.jcommander.Parameters;
|
import com.beust.jcommander.Parameters;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
@ -39,6 +41,11 @@ final class CheckDomainCommand extends NonMutatingEppToolCommand {
|
||||||
required = true)
|
required = true)
|
||||||
private List<String> mainParameters;
|
private List<String> mainParameters;
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
names = {"-t", "--token"},
|
||||||
|
description = "Allocation token to use in the command, if desired")
|
||||||
|
private String allocationToken;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Config("registryAdminClientId")
|
@Config("registryAdminClientId")
|
||||||
String registryAdminClientId;
|
String registryAdminClientId;
|
||||||
|
@ -53,7 +60,11 @@ final class CheckDomainCommand extends NonMutatingEppToolCommand {
|
||||||
Multimap<String, String> domainNameMap = validateAndGroupDomainNamesByTld(mainParameters);
|
Multimap<String, String> domainNameMap = validateAndGroupDomainNamesByTld(mainParameters);
|
||||||
for (Collection<String> values : domainNameMap.asMap().values()) {
|
for (Collection<String> values : domainNameMap.asMap().values()) {
|
||||||
setSoyTemplate(DomainCheckSoyInfo.getInstance(), DomainCheckSoyInfo.DOMAINCHECK);
|
setSoyTemplate(DomainCheckSoyInfo.getInstance(), DomainCheckSoyInfo.DOMAINCHECK);
|
||||||
addSoyRecord(clientId, new SoyMapData("domainNames", values));
|
SoyMapData soyMapData = new SoyMapData("domainNames", values);
|
||||||
|
if (!isNullOrEmpty(allocationToken)) {
|
||||||
|
soyMapData.put("allocationToken", allocationToken);
|
||||||
|
}
|
||||||
|
addSoyRecord(clientId, soyMapData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
{template .domaincheck stricthtml="false"}
|
{template .domaincheck stricthtml="false"}
|
||||||
{@param domainNames: list<string>}
|
{@param domainNames: list<string>}
|
||||||
|
{@param? allocationToken: string|null}
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
<command>
|
<command>
|
||||||
|
@ -39,6 +40,12 @@
|
||||||
</fee:domain>
|
</fee:domain>
|
||||||
{/for}
|
{/for}
|
||||||
</fee:check>
|
</fee:check>
|
||||||
|
{if isNonnull($allocationToken)}
|
||||||
|
<allocationToken:allocationToken
|
||||||
|
xmlns:allocationToken="urn:ietf:params:xml:ns:allocationToken-1.0">
|
||||||
|
{$allocationToken}
|
||||||
|
</allocationToken:allocationToken>
|
||||||
|
{/if}
|
||||||
</extension>
|
</extension>
|
||||||
<clTRID>RegistryTool</clTRID>
|
<clTRID>RegistryTool</clTRID>
|
||||||
</command>
|
</command>
|
||||||
|
|
|
@ -76,6 +76,12 @@ public class CheckDomainCommandTest extends EppToolCommandTestCase<CheckDomainCo
|
||||||
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_fee.xml");
|
eppVerifier.expectDryRun().expectClientId("adminreg").verifySent("domain_check_fee.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_allocationToken_reserved() throws Exception {
|
||||||
|
runCommand("--client=NewRegistrar", "--token=abc123", "example.tld");
|
||||||
|
eppVerifier.expectDryRun().verifySent("domain_check_fee_allocationtoken.xml");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailure_NoMainParameter() {
|
public void testFailure_NoMainParameter() {
|
||||||
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
assertThrows(ParameterException.class, () -> runCommand("--client=NewRegistrar"));
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?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:check>
|
||||||
|
</check>
|
||||||
|
<extension>
|
||||||
|
<fee:check xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
|
||||||
|
<fee:domain>
|
||||||
|
<fee:name>example.tld</fee:name>
|
||||||
|
<fee:command>create</fee:command>
|
||||||
|
<fee:period unit="y">1</fee:period>
|
||||||
|
</fee:domain>
|
||||||
|
</fee:check>
|
||||||
|
<allocationToken:allocationToken
|
||||||
|
xmlns:allocationToken="urn:ietf:params:xml:ns:allocationToken-1.0">
|
||||||
|
abc123
|
||||||
|
</allocationToken:allocationToken>
|
||||||
|
</extension>
|
||||||
|
<clTRID>RegistryTool</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue