mirror of
https://github.com/google/nomulus.git
synced 2025-07-07 11:43:24 +02:00
Send an immediate poll message for superuser domain deletes (#1096)
* Send an immediate poll message for superuser domain deletes This poll message is in addition to the normal poll message that is sent when the domain's deletion is effective (typically 35 days later). It's needed because, in the event of a superuser deletion, the owning registrar won't otherwise necessarily know it's happening. Note that, in the case of a --immediate superuser deletion, the normal poll message is already being sent immediately, so this additional poll message is not necessary.
This commit is contained in:
parent
aac952d6a3
commit
844b5ab713
3 changed files with 61 additions and 15 deletions
|
@ -59,6 +59,7 @@ import static org.joda.time.Duration.standardDays;
|
|||
import static org.joda.time.Duration.standardSeconds;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
@ -87,6 +88,7 @@ import google.registry.model.eppcommon.StatusValue;
|
|||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.poll.PendingActionNotificationResponse;
|
||||
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldType;
|
||||
|
@ -328,12 +330,12 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
dryRunFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
|
||||
}
|
||||
|
||||
private void doImmediateDeleteTest(GracePeriodStatus gracePeriodStatus, String responseFilename)
|
||||
throws Exception {
|
||||
doImmediateDeleteTest(gracePeriodStatus, responseFilename, ImmutableMap.of());
|
||||
private void doAddGracePeriodDeleteTest(
|
||||
GracePeriodStatus gracePeriodStatus, String responseFilename) throws Exception {
|
||||
doAddGracePeriodDeleteTest(gracePeriodStatus, responseFilename, ImmutableMap.of());
|
||||
}
|
||||
|
||||
private void doImmediateDeleteTest(
|
||||
private void doAddGracePeriodDeleteTest(
|
||||
GracePeriodStatus gracePeriodStatus,
|
||||
String responseFilename,
|
||||
Map<String, String> substitutions)
|
||||
|
@ -355,7 +357,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
graceBillingEvent, getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE));
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
// There should be no poll messages. The previous autorenew poll message should now be deleted.
|
||||
assertThat(getPollMessages("TheRegistrar", A_MONTH_FROM_NOW)).isEmpty();
|
||||
assertThat(getPollMessages("TheRegistrar")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -385,25 +387,25 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
@Test
|
||||
void testSuccess_addGracePeriodResultsInImmediateDelete() throws Exception {
|
||||
sessionMetadata.setServiceExtensionUris(ImmutableSet.of());
|
||||
doImmediateDeleteTest(GracePeriodStatus.ADD, "generic_success_response.xml");
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "generic_success_response.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v06() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_11.getUri());
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_06_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v11() throws Exception {
|
||||
removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
|
||||
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_11_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_addGracePeriodCredit_v12() throws Exception {
|
||||
doImmediateDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
|
||||
doAddGracePeriodDeleteTest(GracePeriodStatus.ADD, "domain_delete_response_fee.xml", FEE_12_MAP);
|
||||
}
|
||||
|
||||
private void doSuccessfulTest_noAddGracePeriod(String responseFilename) throws Exception {
|
||||
|
@ -838,6 +840,30 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(
|
||||
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
|
||||
|
||||
HistoryEntry deleteHistoryEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
|
||||
assertPollMessages(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setClientId("TheRegistrar")
|
||||
.setParent(deleteHistoryEntry)
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setMsg(
|
||||
"Domain example.tld was deleted by registry administrator with final deletion"
|
||||
+ " effective: 2000-07-11T22:00:00.013Z")
|
||||
.build(),
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setClientId("TheRegistrar")
|
||||
.setParent(deleteHistoryEntry)
|
||||
.setEventTime(DateTime.parse("2000-07-11T22:00:00.013Z"))
|
||||
.setMsg("Deleted by registry administrator.")
|
||||
.setResponseData(
|
||||
ImmutableList.of(
|
||||
DomainPendingActionNotificationResponse.create(
|
||||
"example.tld",
|
||||
true,
|
||||
deleteHistoryEntry.getTrid(),
|
||||
DateTime.parse("2000-07-11T22:00:00.013Z"))))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1201,6 +1227,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
|
||||
@Test
|
||||
void testSuccess_immediateDelete_withSuperuserAndMetadataExtension() throws Exception {
|
||||
sessionMetadata.setClientId("NewRegistrar");
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput(
|
||||
"domain_delete_superuser_and_metadata_extension.xml",
|
||||
|
|
|
@ -43,6 +43,7 @@ import static google.registry.util.CollectionUtils.difference;
|
|||
import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX_REGEX;
|
||||
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
|
@ -919,15 +920,12 @@ public class DatabaseHelper {
|
|||
.collect(toImmutableList()));
|
||||
}
|
||||
|
||||
public static ImmutableList<PollMessage> getPollMessages(String clientId, DateTime now) {
|
||||
public static ImmutableList<PollMessage> getPollMessages(String clientId, DateTime beforeOrAt) {
|
||||
return transactIfJpaTm(
|
||||
() ->
|
||||
tm().loadAllOf(PollMessage.class).stream()
|
||||
.filter(pollMessage -> pollMessage.getClientId().equals(clientId))
|
||||
.filter(
|
||||
pollMessage ->
|
||||
pollMessage.getEventTime().isEqual(now)
|
||||
|| pollMessage.getEventTime().isBefore(now))
|
||||
.filter(pollMessage -> isBeforeOrAt(pollMessage.getEventTime(), beforeOrAt))
|
||||
.collect(toImmutableList()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue