Update conditions when domain update flow triggers dns publish task (#1811)

Addressing b/246375161
This commit is contained in:
Pavlo Tkach
2022-10-12 10:25:33 -04:00
committed by GitHub
parent 1ab077d267
commit 7b9c16ca3e
3 changed files with 92 additions and 10 deletions
@@ -47,6 +47,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -496,13 +497,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
expectedDsData.stream()
.map(ds -> ds.cloneWithDomainRepoId(resource.getRepoId()))
.collect(toImmutableSet()));
// TODO: REENABLE AFTER PROPER FIX FOR DNS PUBLISHING TASKS IS FOUND
// if (dnsTaskEnqueued) {
// assertDnsTasksEnqueued("example.tld");
// } else {
// assertNoDnsTasksEnqueued();
// }
if (dnsTaskEnqueued) {
assertDnsTasksEnqueued("example.tld");
} else {
assertNoDnsTasksEnqueued();
}
}
@Test
@@ -1747,4 +1746,51 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
assertAboutDomains().that(reloadResourceByForeignKey()).hasNoAutorenewEndTime();
}
@Test
void testAddDnsPublishStatus_enqueueDnsTask() throws Exception {
setEppInput(
"domain_update_status_change.xml",
ImmutableMap.of("STATUS_ADD", "clientHold", "STATUS_REM", "clientTransferProhibited"));
persistReferencedEntities();
persistResource(
persistDomain()
.asBuilder()
.setDomainName("example.tld")
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_TRANSFER_PROHIBITED))
.build());
runFlowAsSuperuser();
assertDnsTasksEnqueued("example.tld");
}
@Test
void testRemoveEveryDnsPublishStatus_enqueueDnsTask() throws Exception {
setEppInput(
"domain_update_status_change.xml",
ImmutableMap.of("STATUS_REM", "serverHold", "STATUS_ADD", "clientTransferProhibited"));
persistReferencedEntities();
persistResource(
persistDomain()
.asBuilder()
.setDomainName("example.tld")
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_HOLD))
.build());
runFlowAsSuperuser();
assertDnsTasksEnqueued("example.tld");
}
@Test
void testChangeSomeOrNoChangeDnsPublishStatus_doNotEnqueueDnsTask() throws Exception {
setEppInput(
"domain_update_status_change.xml",
ImmutableMap.of("STATUS_ADD", "clientUpdateProhibited", "STATUS_REM", "pendingDelete"));
persistReferencedEntities();
persistResource(
persistDomain()
.asBuilder()
.setDomainName("example.tld")
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE, StatusValue.SERVER_HOLD))
.build());
runFlowAsSuperuser();
assertNoDnsTasksEnqueued();
}
}
@@ -0,0 +1,17 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:add>
<domain:status s="%STATUS_ADD%"/>
</domain:add>
<domain:rem>
<domain:status s="%STATUS_REM%"/>
</domain:rem>
</domain:update>
</update>
<clTRID>ABC-12345</clTRID>
</command>
</epp>