mirror of
https://github.com/google/nomulus
synced 2026-02-09 14:30:33 +00:00
Allow command to enqueue poll messages for multiple registrars (#1446)
* Allow command to enqueue poll messages for multiple registrars
This commit is contained in:
@@ -344,7 +344,7 @@ public class SyncRegistrarsSheetTest {
|
||||
ImmutableMap<String, String> row = getOnlyElement(getOnlyElement(rowsCaptor.getAllValues()));
|
||||
assertThat(row).containsEntry("clientIdentifier", "SomeRegistrar");
|
||||
assertThat(row).containsEntry("registrarName", "Some Registrar");
|
||||
assertThat(row).containsEntry("state", "");
|
||||
assertThat(row).containsEntry("state", "ACTIVE");
|
||||
assertThat(row).containsEntry("ianaIdentifier", "8");
|
||||
assertThat(row).containsEntry("billingIdentifier", "");
|
||||
assertThat(row).containsEntry("primaryContacts", "");
|
||||
|
||||
@@ -96,6 +96,7 @@ import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.pricing.StaticPremiumListPricingEngine;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.Registrar.State;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.reporting.HistoryEntryDao;
|
||||
@@ -758,6 +759,7 @@ public class DatabaseHelper {
|
||||
.setRegistrarId(registrarId)
|
||||
.setRegistrarName(registrarName)
|
||||
.setType(type)
|
||||
.setState(State.ACTIVE)
|
||||
.setIanaIdentifier(ianaIdentifier)
|
||||
.setLocalizedAddress(
|
||||
new RegistrarAddress.Builder()
|
||||
|
||||
@@ -20,6 +20,7 @@ import static google.registry.testing.DatabaseHelper.assertPollMessages;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -47,6 +48,8 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
createTld("tld");
|
||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
||||
domain = persistActiveDomain("example.tld");
|
||||
persistNewRegistrar("AdminRegistrar");
|
||||
command.registryAdminClientId = "AdminRegistrar";
|
||||
fakeClock.advanceOneMilli();
|
||||
}
|
||||
|
||||
@@ -59,11 +62,11 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
.that(synthetic)
|
||||
.bySuperuser(true)
|
||||
.and()
|
||||
.hasMetadataReason("Manual enqueueing of poll message")
|
||||
.hasMetadataReason("Manual enqueueing of poll message: This domain is bad")
|
||||
.and()
|
||||
.hasNoXml()
|
||||
.and()
|
||||
.hasRegistrarId("TheRegistrar")
|
||||
.hasRegistrarId("AdminRegistrar")
|
||||
.and()
|
||||
.hasModificationTime(fakeClock.nowUtc())
|
||||
.and()
|
||||
@@ -79,24 +82,35 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_specifyClientId() throws Exception {
|
||||
void testSuccess_specifyClientIds() throws Exception {
|
||||
persistNewRegistrar("foobaz");
|
||||
runCommandForced(
|
||||
"--domain=example.tld", "--message=This domain needs work", "--client=NewRegistrar");
|
||||
"--domain=example.tld",
|
||||
"--message=This domain needs work",
|
||||
"--clients=TheRegistrar,NewRegistrar,foobaz");
|
||||
|
||||
HistoryEntry synthetic = getOnlyHistoryEntryOfType(domain, SYNTHETIC);
|
||||
assertAboutHistoryEntries()
|
||||
.that(synthetic)
|
||||
.bySuperuser(true)
|
||||
.and()
|
||||
.hasMetadataReason("Manual enqueueing of poll message")
|
||||
.hasMetadataReason("Manual enqueueing of poll message: This domain needs work")
|
||||
.and()
|
||||
.hasNoXml()
|
||||
.and()
|
||||
.hasRegistrarId("NewRegistrar")
|
||||
.hasRegistrarId("AdminRegistrar")
|
||||
.and()
|
||||
.hasModificationTime(fakeClock.nowUtc())
|
||||
.and()
|
||||
.hasMetadataRequestedByRegistrar(false);
|
||||
assertPollMessages(
|
||||
"TheRegistrar",
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setParent(synthetic)
|
||||
.setMsg("This domain needs work")
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
assertPollMessages(
|
||||
"NewRegistrar",
|
||||
new PollMessage.OneTime.Builder()
|
||||
@@ -105,6 +119,59 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
.setRegistrarId("NewRegistrar")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
assertPollMessages(
|
||||
"foobaz",
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setParent(synthetic)
|
||||
.setMsg("This domain needs work")
|
||||
.setRegistrarId("foobaz")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSuccess_sendToAllRegistrars() throws Exception {
|
||||
persistNewRegistrar("foobaz");
|
||||
runCommandForced("--domain=example.tld", "--message=This domain needs work", "--all=true");
|
||||
|
||||
HistoryEntry synthetic = getOnlyHistoryEntryOfType(domain, SYNTHETIC);
|
||||
assertAboutHistoryEntries()
|
||||
.that(synthetic)
|
||||
.bySuperuser(true)
|
||||
.and()
|
||||
.hasMetadataReason("Manual enqueueing of poll message: This domain needs work")
|
||||
.and()
|
||||
.hasNoXml()
|
||||
.and()
|
||||
.hasRegistrarId("AdminRegistrar")
|
||||
.and()
|
||||
.hasModificationTime(fakeClock.nowUtc())
|
||||
.and()
|
||||
.hasMetadataRequestedByRegistrar(false);
|
||||
assertPollMessages(
|
||||
"TheRegistrar",
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setParent(synthetic)
|
||||
.setMsg("This domain needs work")
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
assertPollMessages(
|
||||
"NewRegistrar",
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setParent(synthetic)
|
||||
.setMsg("This domain needs work")
|
||||
.setRegistrarId("NewRegistrar")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
assertPollMessages(
|
||||
"foobaz",
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setParent(synthetic)
|
||||
.setMsg("This domain needs work")
|
||||
.setRegistrarId("foobaz")
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
@@ -131,4 +198,18 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
|
||||
assertThrows(ParameterException.class, () -> runCommandForced("--domain=example.tld"));
|
||||
assertThat(thrown).hasMessageThat().contains("The following option is required: -m, --message");
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testCantSpecifyClientIdsAndAll() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--domain=example.tld",
|
||||
"--message=Domain is ended",
|
||||
"--all=true",
|
||||
"--clients=TheRegistrar"));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Cannot specify both --all and --clients");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user