Add premium support to nomulus create_domain command

Premium prices are automatically detected and set, with an informational
message displayed to the user prior to executing the command.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199223541
This commit is contained in:
mcilwain 2018-06-04 17:43:17 -07:00 committed by Ben McIlwain
parent 61f6e666b1
commit 7c0b8cab0b
8 changed files with 165 additions and 18 deletions

View file

@ -15,6 +15,7 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.beust.jcommander.ParameterException;
@ -60,6 +61,7 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
@Test
public void testSuccess_multipleDomains() throws Exception {
createTld("abc");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
@ -72,6 +74,43 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
.verifySent("domain_create_minimal_abc.xml");
}
@Test
public void testSuccess_premiumDomain() throws Exception {
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--period=3",
"--force_premiums",
"parajiumu.tld");
eppVerifier.verifySent("domain_create_parajiumu_3yrs.xml");
assertInStdout(
"parajiumu.tld is premium at JPY 96083 per year; "
+ "sending total cost for 3 year(s) of JPY 288249.");
}
@Test
public void testSuccess_multipleDomainsWithPremium() throws Exception {
createTld("abc");
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"--force_premiums",
"example.tld",
"palladium.tld",
"example.abc");
eppVerifier
.verifySent("domain_create_minimal.xml")
.verifySent("domain_create_palladium.xml")
.verifySent("domain_create_minimal_abc.xml");
assertInStdout(
"palladium.tld is premium at USD 877.00 per year; "
+ "sending total cost for 1 year(s) of USD 877.00.");
}
@Test
public void testFailure_duplicateDomains() throws Exception {
IllegalArgumentException thrown =
@ -288,4 +327,21 @@ public class CreateDomainCommandTest extends EppToolCommandTestCase<CreateDomain
"example.tld"));
assertThat(thrown).hasMessageThat().contains("length 5");
}
@Test
public void testFailure_cantForceCreatePremiumDomain_withoutForcePremiums() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() ->
runCommandForced(
"--client=NewRegistrar",
"--registrant=crr-admin",
"--admins=crr-admin",
"--techs=crr-tech",
"gold.tld"));
assertThat(thrown)
.hasMessageThat()
.isEqualTo("Forced creates on premium domain(s) require --force_premiums");
}
}

View file

@ -5,6 +5,7 @@
<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>

View file

@ -5,6 +5,7 @@
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.abc</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>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<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>palladium.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>
<fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.12">
<fee:currency>USD</fee:currency>
<fee:fee>877.00</fee:fee>
</fee:create>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<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>parajiumu.tld</domain:name>
<domain:period unit="y">3</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>
<fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.12">
<fee:currency>JPY</fee:currency>
<fee:fee>288249</fee:fee>
</fee:create>
</extension>
<clTRID>RegistryTool</clTRID>
</command>
</epp>