From 403c7ad2754fccbf26866c9af4ece068b8509096 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Fri, 26 Jun 2026 15:04:09 -0400 Subject: [PATCH] Add test enforcing host references in redemption domains (#3109) Domains in the redemption grace period can still be restored, so hosts referencing them cannot be deleted. Fortunately this is already the case. This just adds a test. --- .../flows/host/HostDeleteFlowTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java b/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java index 19c95a846..bb00d9a96 100644 --- a/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java @@ -27,6 +27,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HostSubject.assertAboutHosts; import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; @@ -42,6 +43,8 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException; import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException; import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException; import google.registry.model.domain.Domain; +import google.registry.model.domain.GracePeriod; +import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry.Type; @@ -311,6 +314,30 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { assertAboutEppExceptions().that(thrown).marshalsToXml(); } + @Test + void testFailure_failfastWhenLinkedToDomainInRedemption() throws Exception { + createTld("tld"); + Host host = persistActiveHost("ns1.example.tld"); + Domain domain = persistResource(DatabaseHelper.newDomain("example.tld")); + persistResource( + domain + .asBuilder() + .setNameservers(ImmutableSet.of(host.createVKey())) + .setDeletionTime(plusDays(clock.now(), 35)) + .addGracePeriod( + GracePeriod.create( + GracePeriodStatus.REDEMPTION, + domain.getRepoId(), + plusDays(clock.now(), 1), + "TheRegistrar", + null)) + .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) + .build()); + + EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); + } + @Test void testFailure_nonLowerCaseHostname() { setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));