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:
@@ -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);
|
||||
|
||||
+15
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user