1
0
mirror of https://github.com/google/nomulus synced 2026-07-06 00:04:50 +00:00

Validate non-empty tlds in refresh DNS action (#3114)

Add validation to RefreshDnsForAllDomainsAction to ensure the tlds parameter is not empty when invoked. Previously, invoking the action without specifying tlds would result in a no-op that logged an empty list and exited without error. This change makes missing tlds an explicit error, throwing an IllegalArgumentException so users running the command via nomulus curl receive clear feedback that the parameter is required.
This commit is contained in:
Ben McIlwain
2026-06-30 12:34:15 -04:00
committed by GitHub
parent d6f1f5894b
commit 4aeba6e3f7
2 changed files with 16 additions and 0 deletions
@@ -105,6 +105,7 @@ public class RefreshDnsForAllDomainsAction implements Runnable {
@Override
public void run() {
checkArgument(!tlds.isEmpty(), "Must specify TLDs to refresh");
assertTldsExist(tlds);
checkArgument(batchSize > 0, "Must specify a positive number for batch size");
logger.atInfo().log("Enqueueing DNS refresh tasks for TLDs %s.", tlds);
@@ -24,6 +24,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.util.DateTimeUtils.minusYears;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -151,4 +152,18 @@ public class RefreshDnsForAllDomainsActionTest {
action.run();
assertDnsRequestsWithRequestTime(clock.now(), 11);
}
@Test
void test_runAction_emptyTlds_throwsException() {
action =
new RefreshDnsForAllDomainsAction(
response,
ImmutableSet.of(),
Optional.of(10),
Optional.empty(),
Optional.empty(),
new Random());
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, action::run);
assertThat(thrown).hasMessageThat().isEqualTo("Must specify TLDs to refresh");
}
}