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");
}
}