Add reason/registrar request options when creating/updating domains (#1202)

* Add reason/registrar_request options when creating/updating domains
This commit is contained in:
Ben McIlwain 2021-06-11 10:50:32 -04:00 committed by GitHub
parent a7210a26b4
commit a0b6437f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 125 additions and 7 deletions

View file

@ -80,8 +80,7 @@ final class CreateDomainCommand extends CreateOrUpdateDomainCommand
} }
setSoyTemplate(DomainCreateSoyInfo.getInstance(), DomainCreateSoyInfo.DOMAINCREATE); setSoyTemplate(DomainCreateSoyInfo.getInstance(), DomainCreateSoyInfo.DOMAINCREATE);
addSoyRecord( SoyMapData soyMapData =
clientId,
new SoyMapData( new SoyMapData(
"domain", domain, "domain", domain,
"period", period, "period", period,
@ -92,7 +91,12 @@ final class CreateDomainCommand extends CreateOrUpdateDomainCommand
"password", password, "password", password,
"currency", currency, "currency", currency,
"price", cost, "price", cost,
"dsRecords", DsRecord.convertToSoy(dsRecords))); "dsRecords", DsRecord.convertToSoy(dsRecords),
"reason", reason);
if (requestedByRegistrar != null) {
soyMapData.put("requestedByRegistrar", requestedByRegistrar.toString());
}
addSoyRecord(clientId, soyMapData);
} }
} }
} }

View file

@ -78,6 +78,17 @@ abstract class CreateOrUpdateDomainCommand extends MutatingEppToolCommand {
converter = DsRecord.Converter.class) converter = DsRecord.Converter.class)
List<DsRecord> dsRecords = new ArrayList<>(); List<DsRecord> dsRecords = new ArrayList<>();
@Parameter(
names = {"--reason"},
description = "Reason for the change.")
String reason;
@Parameter(
names = {"--registrar_request"},
description = "Whether the change was requested by a registrar.",
arity = 1)
Boolean requestedByRegistrar;
Set<String> domains; Set<String> domains;
@Override @Override

View file

@ -315,10 +315,14 @@ final class UpdateDomainCommand extends CreateOrUpdateDomainCommand {
"secdns", secDns, "secdns", secDns,
"addDsRecords", DsRecord.convertToSoy(addDsRecords), "addDsRecords", DsRecord.convertToSoy(addDsRecords),
"removeDsRecords", DsRecord.convertToSoy(removeDsRecords), "removeDsRecords", DsRecord.convertToSoy(removeDsRecords),
"removeAllDsRecords", clearDsRecords); "removeAllDsRecords", clearDsRecords,
"reason", reason);
if (autorenews != null) { if (autorenews != null) {
soyMapData.put("autorenews", autorenews.toString()); soyMapData.put("autorenews", autorenews.toString());
} }
if (requestedByRegistrar != null) {
soyMapData.put("requestedByRegistrar", requestedByRegistrar.toString());
}
addSoyRecord(clientId, soyMapData); addSoyRecord(clientId, soyMapData);
} }

View file

@ -27,6 +27,8 @@
{@param? currency: string} {@param? currency: string}
{@param? price: string} {@param? price: string}
{@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? requestedByRegistrar: 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">
@ -54,7 +56,7 @@
</domain:authInfo> </domain:authInfo>
</domain:create> </domain:create>
</create> </create>
{if length($dsRecords) > 0 or $price != null} {if length($dsRecords) > 0 or $price != null or $reason or $requestedByRegistrar}
<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">
@ -74,6 +76,16 @@
{/for} {/for}
</secDNS:create> </secDNS:create>
{/if} {/if}
{if $reason or $requestedByRegistrar}
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
{if $reason}
<metadata:reason>{$reason}</metadata:reason>
{/if}
{if $requestedByRegistrar}
<metadata:requestedByRegistrar>{$requestedByRegistrar}</metadata:requestedByRegistrar>
{/if}
</metadata:metadata>
{/if}
</extension> </extension>
{/if} {/if}
<clTRID>RegistryTool</clTRID> <clTRID>RegistryTool</clTRID>

View file

@ -36,6 +36,8 @@
{@param removeDsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>} {@param removeDsRecords: list<[keyTag:int, alg:int, digestType:int, digest:string]>}
{@param removeAllDsRecords: bool} {@param removeAllDsRecords: bool}
{@param? autorenews: string} {@param? autorenews: string}
{@param? reason: string}
{@param? requestedByRegistrar: 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">
@ -97,7 +99,7 @@
{/if} {/if}
</domain:update> </domain:update>
</update> </update>
{if $secdns or $autorenews} {if $secdns or $autorenews or $reason or $requestedByRegistrar}
<extension> <extension>
{if $secdns} {if $secdns}
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"> <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
@ -137,6 +139,16 @@
<superuser:autorenews>{$autorenews}</superuser:autorenews> <superuser:autorenews>{$autorenews}</superuser:autorenews>
</superuser:domainUpdate> </superuser:domainUpdate>
{/if} {/if}
{if $reason or $requestedByRegistrar}
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
{if $reason}
<metadata:reason>{$reason}</metadata:reason>
{/if}
{if $requestedByRegistrar}
<metadata:requestedByRegistrar>{$requestedByRegistrar}</metadata:requestedByRegistrar>
{/if}
</metadata:metadata>
{/if}
</extension> </extension>
{/if} {/if}
<clTRID>RegistryTool</clTRID> <clTRID>RegistryTool</clTRID>

View file

@ -162,6 +162,20 @@ class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomainCommand
+ "sending total cost for 1 year(s) of USD 877.00."); + "sending total cost for 1 year(s) of USD 877.00.");
} }
@Test
void testSuccess_reasonAndRegistrarRequest() throws Exception {
createTld("tld");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--reason=\"Creating test domain\"",
"--registrar_request=false",
"example.tld");
eppVerifier.verifySent("domain_create_metadata.xml");
}
@Test @Test
void testFailure_duplicateDomains() { void testFailure_duplicateDomains() {
IllegalArgumentException thrown = IllegalArgumentException thrown =
@ -175,7 +189,7 @@ class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomainCommand
"--techs=crr-tech", "--techs=crr-tech",
"example.tld", "example.tld",
"example.tld")); "example.tld"));
assertThat(thrown).hasMessageThat().contains("Duplicate arguments found: \'example.tld\'"); assertThat(thrown).hasMessageThat().contains("Duplicate arguments found: 'example.tld'");
} }
@Test @Test

View file

@ -197,6 +197,18 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
eppVerifier.verifySent("domain_update_change.xml"); eppVerifier.verifySent("domain_update_change.xml");
} }
@TestOfyAndSql
void testSuccess_change_reasonAndRegistrarRequest() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--password=2fooBAR",
"--reason=\"Testing domain update\"",
"--registrar_request=false",
"example.tld");
eppVerifier.verifySent("domain_update_change_metadata.xml");
}
@TestOfyAndSql @TestOfyAndSql
void testSuccess_setNameservers() throws Exception { void testSuccess_setNameservers() throws Exception {
HostResource host1 = persistActiveHost("ns1.zdns.google"); HostResource host1 = persistActiveHost("ns1.zdns.google");

View file

@ -0,0 +1,25 @@
<?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>
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
<metadata:reason>Creating test domain</metadata:reason>
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
</metadata:metadata>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:chg>
<domain:registrant>crr-admin</domain:registrant>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
<extension>
<metadata:metadata xmlns:metadata="urn:google:params:xml:ns:metadata-1.0">
<metadata:reason>Testing domain update</metadata:reason>
<metadata:requestedByRegistrar>false</metadata:requestedByRegistrar>
</metadata:metadata>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>