Add tool commands to modify TTLs on a TLD (#1985)

* Add tool commands to modify TTLs on a TLD

* Small changes

* Add an example to the parameter description
This commit is contained in:
sarahcaseybot 2023-04-10 14:43:56 -04:00 committed by GitHub
parent d02b617e0f
commit e18dba472b
4 changed files with 54 additions and 4 deletions

View file

@ -785,13 +785,13 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial
return this; return this;
} }
public Builder setDnsNsAtl(Duration dnsNsAtl) { public Builder setDnsNsTtl(Duration dnsNsTtl) {
getInstance().dnsNsTtl = dnsNsAtl; getInstance().dnsNsTtl = dnsNsTtl;
return this; return this;
} }
public Builder setDnsDsAtl(Duration dnsDsAtl) { public Builder setDnsDsTtl(Duration dnsDsTtl) {
getInstance().dnsDsTtl = dnsDsAtl; getInstance().dnsDsTtl = dnsDsTtl;
return this; return this;
} }

View file

@ -237,6 +237,24 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
) )
Integer numDnsPublishShards; Integer numDnsPublishShards;
@Nullable
@Parameter(
names = {"--dns_a_plus_aaaa_ttl"},
description = "The time to live for DNS A and AAAA records (Ex: PT240S)")
Duration dnsAPlusAaaaTtl;
@Nullable
@Parameter(
names = {"--dns_ns_ttl"},
description = "The time to live for DNS NS records (Ex: PT240S)")
Duration dnsNsTtl;
@Nullable
@Parameter(
names = {"--dns_ds_ttl"},
description = "The time to live for DNS DS records (Ex: PT240S)")
Duration dnsDsTtl;
@Nullable @Nullable
@Parameter( @Parameter(
names = "--default_tokens", names = "--default_tokens",
@ -364,6 +382,9 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
Optional.ofNullable(lordnUsername).ifPresent(u -> builder.setLordnUsername(u.orElse(null))); Optional.ofNullable(lordnUsername).ifPresent(u -> builder.setLordnUsername(u.orElse(null)));
Optional.ofNullable(claimsPeriodEnd).ifPresent(builder::setClaimsPeriodEnd); Optional.ofNullable(claimsPeriodEnd).ifPresent(builder::setClaimsPeriodEnd);
Optional.ofNullable(numDnsPublishShards).ifPresent(builder::setNumDnsPublishLocks); Optional.ofNullable(numDnsPublishShards).ifPresent(builder::setNumDnsPublishLocks);
Optional.ofNullable(dnsAPlusAaaaTtl).ifPresent(builder::setDnsAPlusAaaaTtl);
Optional.ofNullable(dnsNsTtl).ifPresent(builder::setDnsNsTtl);
Optional.ofNullable(dnsDsTtl).ifPresent(builder::setDnsDsTtl);
if (premiumListName != null) { if (premiumListName != null) {
if (premiumListName.isPresent()) { if (premiumListName.isPresent()) {

View file

@ -76,6 +76,22 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
.isEqualTo(Registry.DEFAULT_REGISTRY_LOCK_OR_UNLOCK_BILLING_COST); .isEqualTo(Registry.DEFAULT_REGISTRY_LOCK_OR_UNLOCK_BILLING_COST);
} }
@Test
void testSuccess_ttls() throws Exception {
runCommandForced(
"xn--q9jyb4c",
"--roid_suffix=Q9JYB4C",
"--dns_writers=FooDnsWriter",
"--dns_a_plus_aaaa_ttl=PT300S",
"--dns_ds_ttl=PT240S",
"--dns_ns_ttl=PT180S");
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry).isNotNull();
assertThat(registry.getDnsAPlusAaaaTtl()).isEqualTo(standardMinutes(5));
assertThat(registry.getDnsDsTtl()).isEqualTo(standardMinutes(4));
assertThat(registry.getDnsNsTtl()).isEqualTo(standardMinutes(3));
}
@Test @Test
void testFailure_multipleArguments() { void testFailure_multipleArguments() {
IllegalArgumentException thrown = IllegalArgumentException thrown =

View file

@ -1095,6 +1095,19 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist"); assertThat(thrown).hasMessageThat().contains("The premium list 'phonies' doesn't exist");
} }
@Test
void testSuccess_setTtls() throws Exception {
runCommandForced(
"--dns_a_plus_aaaa_ttl=PT300S",
"--dns_ds_ttl=PT240S",
"--dns_ns_ttl=PT180S",
"xn--q9jyb4c");
Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry.getDnsAPlusAaaaTtl()).isEqualTo(standardMinutes(5));
assertThat(registry.getDnsDsTtl()).isEqualTo(standardMinutes(4));
assertThat(registry.getDnsNsTtl()).isEqualTo(standardMinutes(3));
}
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception { private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c"); runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
} }