diff --git a/java/google/registry/model/registry/Registry.java b/java/google/registry/model/registry/Registry.java index 927d4313d..1ecf46c09 100644 --- a/java/google/registry/model/registry/Registry.java +++ b/java/google/registry/model/registry/Registry.java @@ -327,13 +327,18 @@ public class Registry extends ImmutableObject implements Buildable { */ boolean domainCreateRestricted; - /** The length of the add grace period for this TLD. */ + /** + * The length of the add grace period for this TLD. + * + *

Domain deletes are free and effective immediately so long as they take place within this + * amount of time following creation. + */ Duration addGracePeriodLength = DEFAULT_ADD_GRACE_PERIOD; - /** The length of the add grace period for this TLD. */ + /** The length of the anchor tenant add grace period for this TLD. */ Duration anchorTenantAddGracePeriodLength = DEFAULT_ANCHOR_TENANT_ADD_GRACE_PERIOD; - /** The length of the sunrush add grace period for this TLD. */ + /** The length of the add grace period during sunrush for this TLD. */ Duration sunrushAddGracePeriodLength = DEFAULT_SUNRUSH_ADD_GRACE_PERIOD; /** The length of the auto renew grace period for this TLD. */ diff --git a/java/google/registry/tools/CreateOrUpdateTldCommand.java b/java/google/registry/tools/CreateOrUpdateTldCommand.java index 93c31fee6..1cbe8907e 100644 --- a/java/google/registry/tools/CreateOrUpdateTldCommand.java +++ b/java/google/registry/tools/CreateOrUpdateTldCommand.java @@ -73,25 +73,31 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { @Nullable @Parameter( names = "--add_grace_period", - description = "Length of the add grace period") + description = "Length of the add grace period (in ISO 8601 duration format)") Duration addGracePeriod; + @Nullable + @Parameter( + names = "--sunrush_add_grace_period", + description = "Length of the add grace period during sunrush (in ISO 8601 duration format)") + Duration sunrushAddGracePeriod; + @Nullable @Parameter( names = "--redemption_grace_period", - description = "Length of the redemption grace period") + description = "Length of the redemption grace period (in ISO 8601 duration format)") Duration redemptionGracePeriod; @Nullable @Parameter( names = "--pending_delete_length", - description = "Length of the pending delete period") + description = "Length of the pending delete period (in ISO 8601 duration format)") Duration pendingDeleteLength; @Nullable @Parameter( names = "--automatic_transfer_length", - description = "Length of the automatic transfer period") + description = "Length of the automatic transfer period (in ISO 8601 duration format)") private Duration automaticTransferLength; @Nullable @@ -321,61 +327,23 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { builder.setEapFeeSchedule(eapFeeSchedule); } - if (addGracePeriod != null) { - builder.setAddGracePeriodLength(addGracePeriod); - } - - if (redemptionGracePeriod != null) { - builder.setRedemptionGracePeriodLength(redemptionGracePeriod); - } - - if (pendingDeleteLength != null) { - builder.setPendingDeleteLength(pendingDeleteLength); - } - - if (automaticTransferLength != null) { - builder.setAutomaticTransferLength(automaticTransferLength); - } - - if (driveFolderId != null) { - builder.setDriveFolderId(driveFolderId.orElse(null)); - } - - if (createBillingCost != null) { - builder.setCreateBillingCost(createBillingCost); - } - - if (restoreBillingCost != null) { - builder.setRestoreBillingCost(restoreBillingCost); - } - - if (roidSuffix != null) { - builder.setRoidSuffix(roidSuffix); - } - - if (serverStatusChangeCost != null) { - builder.setServerStatusChangeBillingCost(serverStatusChangeCost); - } - - if (tldType != null) { - builder.setTldType(tldType); - } - - if (premiumPriceAckRequired != null) { - builder.setPremiumPriceAckRequired(premiumPriceAckRequired); - } - - if (lordnUsername != null) { - builder.setLordnUsername(lordnUsername.orElse(null)); - } - - if (claimsPeriodEnd != null) { - builder.setClaimsPeriodEnd(claimsPeriodEnd); - } - - if (domainCreateRestricted != null) { - builder.setDomainCreateRestricted(domainCreateRestricted); - } + Optional.ofNullable(addGracePeriod).ifPresent(builder::setAddGracePeriodLength); + Optional.ofNullable(sunrushAddGracePeriod).ifPresent(builder::setSunrushAddGracePeriodLength); + Optional.ofNullable(redemptionGracePeriod).ifPresent(builder::setRedemptionGracePeriodLength); + Optional.ofNullable(pendingDeleteLength).ifPresent(builder::setPendingDeleteLength); + Optional.ofNullable(automaticTransferLength).ifPresent(builder::setAutomaticTransferLength); + Optional.ofNullable(driveFolderId).ifPresent(id -> builder.setDriveFolderId(id.orElse(null))); + Optional.ofNullable(createBillingCost).ifPresent(builder::setCreateBillingCost); + Optional.ofNullable(restoreBillingCost).ifPresent(builder::setRestoreBillingCost); + Optional.ofNullable(roidSuffix).ifPresent(builder::setRoidSuffix); + Optional.ofNullable(serverStatusChangeCost) + .ifPresent(builder::setServerStatusChangeBillingCost); + Optional.ofNullable(tldType).ifPresent(builder::setTldType); + Optional.ofNullable(premiumPriceAckRequired).ifPresent(builder::setPremiumPriceAckRequired); + Optional.ofNullable(lordnUsername).ifPresent(u -> builder.setLordnUsername(u.orElse(null))); + Optional.ofNullable(claimsPeriodEnd).ifPresent(builder::setClaimsPeriodEnd); + Optional.ofNullable(domainCreateRestricted).ifPresent(builder::setDomainCreateRestricted); + Optional.ofNullable(lrpPeriod).ifPresent(p -> builder.setLrpPeriod(p.orElse(null))); if (premiumListName != null) { if (premiumListName.isPresent()) { @@ -399,10 +367,6 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { builder.setDnsWriters(dnsWritersSet); } - if (lrpPeriod != null) { - builder.setLrpPeriod(lrpPeriod.orElse(null)); - } - ImmutableSet newReservedListNames = getReservedLists(oldRegistry); checkReservedListValidityForTld(tld, newReservedListNames); builder.setReservedListsByName(newReservedListNames); diff --git a/javatests/google/registry/tools/CreateTldCommandTest.java b/javatests/google/registry/tools/CreateTldCommandTest.java index 60f8c1c76..74d2d8c7d 100644 --- a/javatests/google/registry/tools/CreateTldCommandTest.java +++ b/javatests/google/registry/tools/CreateTldCommandTest.java @@ -20,10 +20,12 @@ import static google.registry.model.registry.label.ReservedListTest.GET_NAME_FUN import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistReservedList; +import static google.registry.testing.JUnitBackports.expectThrows; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; import static org.joda.time.DateTimeZone.UTC; +import static org.joda.time.Duration.standardDays; import static org.joda.time.Duration.standardMinutes; import com.beust.jcommander.ParameterException; @@ -141,6 +143,17 @@ public class CreateTldCommandTest extends CommandTestCase { assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } + @Test + public void testSuccess_sunrushAddGracePeriodFlag() throws Exception { + runCommandForced( + "--sunrush_add_grace_period=P13D", + "--roid_suffix=Q9JYB4C", + "--dns_writers=VoidDnsWriter", + "xn--q9jyb4c"); + assertThat(Registry.get("xn--q9jyb4c").getSunrushAddGracePeriodLength()) + .isEqualTo(standardDays(13)); + } + @Test public void testSuccess_roidSuffixWorks() throws Exception { runCommandForced("--roid_suffix=RSUFFIX", "--dns_writers=VoidDnsWriter", "tld"); @@ -296,6 +309,19 @@ public class CreateTldCommandTest extends CommandTestCase { "xn--q9jyb4c"); } + @Test + public void testFailure_invalidSunrushAddGracePeriod() throws Exception { + Exception e = expectThrows( + IllegalArgumentException.class, + () -> + runCommandForced( + "--sunrush_add_grace_period=5d", + "--roid_suffix=Q9JYB4C", + "--dns_writers=VoidDnsWriter", + "xn--q9jyb4c")); + assertThat(e).hasMessageThat().isEqualTo("Invalid format: \"5d\""); + } + @Test public void testFailure_invalidRedemptionGracePeriod() throws Exception { thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\""); diff --git a/javatests/google/registry/tools/UpdateTldCommandTest.java b/javatests/google/registry/tools/UpdateTldCommandTest.java index fef3f8780..bdeff02b1 100644 --- a/javatests/google/registry/tools/UpdateTldCommandTest.java +++ b/javatests/google/registry/tools/UpdateTldCommandTest.java @@ -26,6 +26,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; import static org.joda.time.DateTimeZone.UTC; +import static org.joda.time.Duration.standardDays; import static org.joda.time.Duration.standardMinutes; import com.beust.jcommander.ParameterException; @@ -147,19 +148,22 @@ public class UpdateTldCommandTest extends CommandTestCase { public void testSuccess_addGracePeriodFlag() throws Exception { assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()) .isNotEqualTo(standardMinutes(5)); - runCommandForced("--add_grace_period=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } + @Test + public void testSuccess_sunrushAddGracePeriodFlag() throws Exception { + runCommandForced("--sunrush_add_grace_period=P13D", "xn--q9jyb4c"); + assertThat(Registry.get("xn--q9jyb4c").getSunrushAddGracePeriodLength()) + .isEqualTo(standardDays(13)); + } + @Test public void testSuccess_redemptionGracePeriodFlag() throws Exception { assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isNotEqualTo(standardMinutes(5)); - runCommandForced("--redemption_grace_period=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isEqualTo(standardMinutes(5)); } @@ -168,16 +172,13 @@ public class UpdateTldCommandTest extends CommandTestCase { public void testSuccess_pendingDeleteLengthFlag() throws Exception { assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()) .isNotEqualTo(standardMinutes(5)); - runCommandForced("--pending_delete_length=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); } @Test public void testSuccess_dnsWriter() throws Exception { assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter"); - runCommandForced("--dns_writers=FooDnsWriter", "xn--q9jyb4c"); assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("FooDnsWriter"); }