Allow usage of allocation tokens in nomulus create_domain (#1756)

Useful when doing internal registrations like get.boo
This commit is contained in:
gbrodman 2022-08-24 13:18:53 -04:00 committed by GitHub
parent c118af0d6a
commit 3c0805def5
4 changed files with 55 additions and 2 deletions

View file

@ -46,6 +46,11 @@ final class CreateDomainCommand extends CreateOrUpdateDomainCommand
description = "Force the creation of premium domains.") description = "Force the creation of premium domains.")
private boolean forcePremiums; private boolean forcePremiums;
@Parameter(
names = "--allocation_token",
description = "Allocation token to use when creating the domain(s)")
private String allocationToken;
@Inject @Inject
@Named("base64StringGenerator") @Named("base64StringGenerator")
StringGenerator passwordGenerator; StringGenerator passwordGenerator;
@ -92,7 +97,8 @@ final class CreateDomainCommand extends CreateOrUpdateDomainCommand
"currency", currency, "currency", currency,
"price", cost, "price", cost,
"dsRecords", DsRecord.convertToSoy(dsRecords), "dsRecords", DsRecord.convertToSoy(dsRecords),
"reason", reason); "reason", reason,
"allocationToken", allocationToken);
if (requestedByRegistrar != null) { if (requestedByRegistrar != null) {
soyMapData.put("requestedByRegistrar", requestedByRegistrar.toString()); soyMapData.put("requestedByRegistrar", requestedByRegistrar.toString());
} }

View file

@ -29,6 +29,7 @@
{@param dsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>} {@param dsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>}
{@param? reason: string} {@param? reason: string}
{@param? requestedByRegistrar: string} {@param? requestedByRegistrar: string}
{@param? allocationToken: string}
<?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">
@ -56,7 +57,7 @@
</domain:authInfo> </domain:authInfo>
</domain:create> </domain:create>
</create> </create>
{if length($dsRecords) > 0 or $price != null or $reason or $requestedByRegistrar} {if length($dsRecords) > 0 or $price != null or $reason or $requestedByRegistrar or $allocationToken}
<extension> <extension>
{if $price != null} {if $price != null}
<fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.12"> <fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.12">
@ -86,6 +87,13 @@
{/if} {/if}
</metadata:metadata> </metadata:metadata>
{/if} {/if}
{if $allocationToken}
<allocationToken:allocationToken
xmlns:allocationToken=
"urn:ietf:params:xml:ns:allocationToken-1.0">
{$allocationToken}
</allocationToken:allocationToken>
{/if}
</extension> </extension>
{/if} {/if}
<clTRID>RegistryTool</clTRID> <clTRID>RegistryTool</clTRID>

View file

@ -179,6 +179,19 @@ class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomainCommand
eppVerifier.verifySent("domain_create_metadata.xml"); eppVerifier.verifySent("domain_create_metadata.xml");
} }
@Test
void testSuccess_allocationToken() throws Exception {
createTld("tld");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--allocation_token=abc123",
"example.tld");
eppVerifier.verifySent("domain_create_token.xml");
}
@Test @Test
void testFailure_duplicateDomains() { void testFailure_duplicateDomains() {
IllegalArgumentException thrown = IllegalArgumentException thrown =

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:period unit="y">1</domain:period>
<domain:registrant>crr-admin</domain:registrant>
<domain:contact type="admin">crr-admin</domain:contact>
<domain:contact type="tech">crr-tech</domain:contact>
<domain:authInfo>
<domain:pw>abcdefghijklmnop</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<allocationToken:allocationToken
xmlns:allocationToken=
"urn:ietf:params:xml:ns:allocationToken-1.0">
abc123
</allocationToken:allocationToken>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>