1
0
mirror of https://github.com/google/nomulus synced 2026-05-02 05:45:59 +00:00

Add a new MutatingFlow interface and make most flows use TransactionalFlow (#2129)

The old semantics for TransactionalFlow meant "anything that needs to mutate the
database", but then FlowRunner was not creating transactions for
non-transactional flows even though nearly every flow needs a transaction (as
nearly every flow needs to hit the database for some purpose).  So now
TransactionalFlow simply means "any flow that needs the database", and
MutatingFlow means "a flow that mutates the database". In the future we will
have FlowRunner use a read-only transaction for TransactionalFlow and then a
normal writes-allowed transaction for MutatingFlow. That is a TODO.

This also fixes up some transact() calls inside caches to be reTransact(), as we
rightly can't move the transaction outside them as from some callsites we
legitimately do not know whether a transaction will be needed at all (depending
on whether said data is already in memory). And it removes the replicaTm() calls
which weren't actually doing anything as they were always nested inside of normal
tm()s, thus causing confusion.
This commit is contained in:
Ben McIlwain
2023-08-28 17:04:41 -04:00
committed by GitHub
parent e6f9b1c7e6
commit 57592d787c
68 changed files with 218 additions and 211 deletions

View File

@@ -145,14 +145,14 @@ public abstract class FlowTestCase<F extends Flow> {
sessionMetadata.setRegistrarId(registrarId);
}
public void assertTransactionalFlow(boolean isTransactional) throws Exception {
public void assertMutatingFlow(boolean isMutating) throws Exception {
Class<? extends Flow> flowClass = FlowPicker.getFlowClass(eppLoader.getEpp());
if (isTransactional) {
assertThat(flowClass).isAssignableTo(TransactionalFlow.class);
if (isMutating) {
assertThat(flowClass).isAssignableTo(MutatingFlow.class);
} else {
// There's no "isNotAssignableTo" in Truth.
assertWithMessage(flowClass.getSimpleName() + " implements TransactionalFlow")
.that(TransactionalFlow.class.isAssignableFrom(flowClass))
assertWithMessage(flowClass.getSimpleName() + " implements MutatingFlow")
.that(MutatingFlow.class.isAssignableFrom(flowClass))
.isFalse();
}
}

View File

@@ -30,7 +30,7 @@ public abstract class ResourceCheckFlowTestCase<F extends Flow, R extends EppRes
extends ResourceFlowTestCase<F, R> {
protected void doCheckTest(CheckData.Check... expected) throws Exception {
assertTransactionalFlow(false);
assertMutatingFlow(false);
assertThat(((CheckData) runFlow().getResponse().getResponseData().get(0)).getChecks())
.containsExactlyElementsIn(expected);
assertNoHistory(); // Checks don't create a history event.

View File

@@ -44,7 +44,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
}
private void doSuccessfulTest() throws Exception {
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("contact_create_response.xml"));
// Check that the contact was created and persisted with a history entry.
Contact contact = reloadResourceByForeignKey();

View File

@@ -78,7 +78,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
void testSuccess() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("contact_delete_response.xml"));
assertSqlDeleteSuccess();
}
@@ -94,7 +94,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
clock.nowUtc())
.getTransferData();
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("contact_delete_response.xml"));
assertSqlDeleteSuccess(Type.CONTACT_DELETE, Type.CONTACT_TRANSFER_REQUEST);
Contact softDeletedContact = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
@@ -130,7 +130,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
setEppInput("contact_delete_no_cltrid.xml");
persistActiveContact(getUniqueIdFromCommand());
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("contact_delete_response_no_cltrid.xml"));
assertSqlDeleteSuccess();
}

View File

@@ -109,7 +109,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
void testSuccess() throws Exception {
persistContact(true);
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
loadFile("contact_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
@@ -123,7 +123,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
createTld("foobar");
persistResource(DatabaseHelper.newDomain("example.foobar", persistContact(true)));
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
loadFile("contact_info_response_linked.xml"),
// We use a different roid scheme than the samples so ignore it.
@@ -137,7 +137,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
setEppInput("contact_info_no_authinfo.xml");
persistContact(true);
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
loadFile("contact_info_response.xml"),
// We use a different roid scheme than the samples so ignore it.
@@ -151,7 +151,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
setRegistrarIdForFlow("NewRegistrar");
persistContact(true);
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
ResourceNotOwnedException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -162,7 +162,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
setEppInput("contact_info_no_authinfo.xml");
persistContact(true);
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
@@ -178,7 +178,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact>
setRegistrarIdForFlow("NewRegistrar");
persistContact(true);
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
CommitMode.LIVE,
UserPrivileges.SUPERUSER,

View File

@@ -69,7 +69,7 @@ class ContactTransferApproveFlowTest
// Setup done; run the test.
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have succeeded. Verify correct fields were set.
@@ -120,7 +120,7 @@ class ContactTransferApproveFlowTest
private void doFailingTest(String commandFilename) throws Exception {
setEppInput(commandFilename);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -63,7 +63,7 @@ class ContactTransferCancelFlowTest
// Setup done; run the test.
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been cancelled. Verify correct fields were set.
@@ -104,7 +104,7 @@ class ContactTransferCancelFlowTest
private void doFailingTest(String commandFilename) throws Exception {
this.setEppInput(commandFilename);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -53,7 +53,7 @@ class ContactTransferQueryFlowTest
setEppInput(commandFilename);
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile(expectedXmlFilename));
assertAboutContacts().that(reloadResourceByForeignKey(clock.nowUtc().minusDays(1)))
.hasOneHistoryEntryEachOfTypes(HistoryEntry.Type.CONTACT_TRANSFER_REQUEST);
@@ -64,7 +64,7 @@ class ContactTransferQueryFlowTest
setEppInput(commandFilename);
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlow();
}

View File

@@ -67,7 +67,7 @@ class ContactTransferRejectFlowTest
// Setup done; run the test.
contact = reloadResourceByForeignKey();
TransferData originalTransferData = contact.getTransferData();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have failed. Verify correct fields were set.
@@ -119,7 +119,7 @@ class ContactTransferRejectFlowTest
private void doFailingTest(String commandFilename) throws Exception {
setEppInput(commandFilename);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -78,7 +78,7 @@ class ContactTransferRequestFlowTest
DateTime afterTransfer = clock.nowUtc().plus(getContactAutomaticTransferLength());
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have been requested. Verify correct fields were set.
@@ -140,7 +140,7 @@ class ContactTransferRequestFlowTest
private void doFailingTest(String commandFilename) throws Exception {
setEppInput(commandFilename);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -53,7 +53,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
private void doSuccessfulTest() throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
Contact contact = reloadResourceByForeignKey();
// Check that the contact was updated. This value came from the xml.

View File

@@ -58,7 +58,7 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaims
}
protected void doSuccessfulTest(String expectedXmlFilename) throws Exception {
assertTransactionalFlow(false);
assertMutatingFlow(false);
assertNoHistory(); // Checks don't create a history event.
assertNoBillingEvents(); // Checks are always free.
runFlowAssertResponse(loadFile(expectedXmlFilename));
@@ -152,7 +152,7 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaims
ImmutableMap.of("example2", "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001"));
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
assertNoHistory(); // Checks don't create a history event.
assertNoBillingEvents(); // Checks are always free.
runFlowAssertResponse(

View File

@@ -428,7 +428,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
UserPrivileges userPrivileges,
Map<String, String> substitutions)
throws Exception {
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(
CommitMode.LIVE, userPrivileges, loadFile(responseXmlFile, substitutions));
assertSuccessfulCreate(domainTld, ImmutableSet.of());
@@ -613,7 +613,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
createTld("foo.tld");
setEppInput("domain_create_with_tld.xml", ImmutableMap.of("TLD", "foo.tld"));
persistContactsAndHosts("foo.tld");
assertTransactionalFlow(true);
assertMutatingFlow(true);
String expectedResponseXml =
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.foo.tld"));
runFlowAssertResponse(CommitMode.LIVE, UserPrivileges.NORMAL, expectedResponseXml);

View File

@@ -152,7 +152,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
}
private void createReferencedEntities(DateTime expirationTime) throws Exception {
@@ -217,7 +217,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
}
private void assertAutorenewClosedAndCancellationCreatedFor(

View File

@@ -177,7 +177,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
ImmutableMap<String, String> substitutions,
boolean expectHistoryAndBilling)
throws Exception {
assertTransactionalFlow(false);
assertMutatingFlow(false);
String expected =
loadFile(expectedXmlFilename, updateSubstitutions(substitutions, "ROID", "2FF-TLD"));
if (inactive) {

View File

@@ -250,7 +250,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
RenewalPriceBehavior renewalPriceBehavior,
@Nullable Money renewalPrice)
throws Exception {
assertTransactionalFlow(true);
assertMutatingFlow(true);
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
runFlowAssertResponse(

View File

@@ -163,7 +163,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime expirationTime = clock.nowUtc().plusYears(5).plusDays(45);
persistPendingDeleteDomain(expirationTime);
assertTransactionalFlow(true);
assertMutatingFlow(true);
// Double check that we see a poll message in the future for when the delete happens.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
@@ -231,7 +231,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
DateTime expirationTime = clock.nowUtc().minusDays(20);
DateTime newExpirationTime = expirationTime.plusYears(1);
persistPendingDeleteDomain(expirationTime);
assertTransactionalFlow(true);
assertMutatingFlow(true);
// Double check that we see a poll message in the future for when the delete happens.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
runFlowAssertResponse(loadFile("generic_success_response.xml"));

View File

@@ -200,7 +200,7 @@ class DomainTransferApproveFlowTest
assertThat(getPollMessages(domain, "TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
// Setup done; run the test.
DomainTransferData originalTransferData = domain.getTransferData();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
// Transfer should have succeeded. Verify correct fields were set.
domain = reloadResourceByForeignKey();
@@ -364,7 +364,7 @@ class DomainTransferApproveFlowTest
private void doFailingTest(String commandFilename) throws Exception {
setEppLoader(commandFilename);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -116,7 +116,7 @@ class DomainTransferCancelFlowTest
clock.advanceOneMilli();
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
DateTime originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
DomainTransferData originalTransferData = domain.getTransferData();
@@ -190,7 +190,7 @@ class DomainTransferCancelFlowTest
// Replace the ROID in the xml file with the one generated in our test.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -55,7 +55,7 @@ class DomainTransferQueryFlowTest
// Replace the ROID in the xml file with the one generated in our test.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile(expectedXmlFilename));
assertAboutDomains()
.that(domain)
@@ -76,7 +76,7 @@ class DomainTransferQueryFlowTest
// Replace the ROID in the xml file with the one generated in our test.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlow();
}

View File

@@ -89,7 +89,7 @@ class DomainTransferRejectFlowTest
assertThat(getPollMessages("NewRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
DateTime originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
TransferData originalTransferData = domain.getTransferData();
@@ -152,7 +152,7 @@ class DomainTransferRejectFlowTest
// Replace the ROID in the xml file with the one generated in our test.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow();
}

View File

@@ -483,7 +483,7 @@ class DomainTransferRequestFlowTest
Tld registry = Tld.get(domain.getTld());
DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength());
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename, substitutions));
// Transfer should have been requested.
domain = reloadResourceByForeignKey();
@@ -583,7 +583,7 @@ class DomainTransferRequestFlowTest
// the transfer timeline 3 days later by adjusting the implicit transfer time here.
DateTime implicitTransferTime = clock.nowUtc().plus(expectedAutomaticTransferLength);
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile(expectedXmlFilename, substitutions));
@@ -634,7 +634,7 @@ class DomainTransferRequestFlowTest
// Replace the ROID in the xml file with the one generated in our test.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
// Setup done; run the test.
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlow(CommitMode.LIVE, userPrivileges);
}
@@ -1741,7 +1741,7 @@ class DomainTransferRequestFlowTest
"domain_transfer_request_wildcard.xml",
ImmutableMap.of("YEARS", "1", "DOMAIN", "--invalid", "EXDATE", "2002-09-08T22:00:00.0Z"));
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
assertTransactionalFlow(true);
assertMutatingFlow(true);
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class,

View File

@@ -203,7 +203,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private void doSuccessfulTest(String expectedXmlFilename) throws Exception {
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
Domain domain = reloadResourceByForeignKey();
// Check that the domain was updated. These values came from the xml.
@@ -341,7 +341,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setRegistrant(contacts.get(3).getContactKey())
.build());
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
Domain domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_UPDATE);
@@ -407,7 +407,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.createVKey()))
.build());
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(addedHost.createVKey());
@@ -490,7 +490,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.asBuilder()
.setDsData(originalDsData)
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
Domain resource = reloadResourceByForeignKey();

View File

@@ -81,7 +81,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
private void doSuccessfulTest() throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("host_create_response.xml"));
Host host = reloadResourceByForeignKey();
// Check that the host was created and persisted with a history entry.

View File

@@ -77,7 +77,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Host> {
void testSuccess() throws Exception {
persistActiveHost("ns1.example.tld");
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("host_delete_response.xml"));
assertSqlDeleteSuccess();
}
@@ -87,7 +87,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Host> {
setEppInput("host_delete_no_cltrid.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld"));
persistActiveHost("ns1.example.tld");
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("host_delete_response_no_cltrid.xml"));
assertSqlDeleteSuccess();
}

View File

@@ -82,7 +82,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, Host> {
@Test
void testSuccess() throws Exception {
persistHost();
assertTransactionalFlow(false);
assertMutatingFlow(false);
// Check that the persisted host info was returned.
runFlowAssertResponse(
loadFile("host_info_response.xml"),
@@ -100,7 +100,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, Host> {
.asBuilder()
.addNameserver(persistHost().createVKey())
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
// Check that the persisted host info was returned.
runFlowAssertResponse(
loadFile("host_info_response_linked.xml"),
@@ -131,7 +131,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, Host> {
.build());
// we shouldn't have two active hosts with the same hostname
deleteResource(firstHost);
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
loadFile("host_info_response_superordinate_clientid.xml"),
// We use a different roid scheme than the samples so ignore it.

View File

@@ -160,7 +160,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
private Host doSuccessfulTest(boolean isSuperuser) throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(
CommitMode.LIVE,
isSuperuser ? UserPrivileges.SUPERUSER : UserPrivileges.NORMAL,

View File

@@ -96,7 +96,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setMsg("Some poll message.")
.setHistoryEntry(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@@ -111,14 +111,14 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setMsg("Some poll message.")
.setHistoryEntry(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(MessageDoesNotExistException.class, this::runFlow);
}
@Test
void testSuccess_messageOnContact() throws Exception {
persistOneTimePollMessage(MESSAGE_ID);
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@@ -126,7 +126,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
void testSuccess_recentActiveAutorenew() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "3-2010"));
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), END_OF_TIME);
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@@ -139,7 +139,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
for (int i = 1; i < 4; i++) {
persistOneTimePollMessage(MESSAGE_ID + i);
}
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(
loadFile("poll_ack_response.xml", ImmutableMap.of("MSGID", "3-2009", "COUNT", "4")));
}
@@ -148,7 +148,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
void testSuccess_oldInactiveAutorenew() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "3-2010"));
persistAutorenewPollMessage(clock.nowUtc().minusMonths(6), clock.nowUtc());
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));
}
@@ -158,14 +158,14 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
for (int i = 0; i < 5; i++) {
persistOneTimePollMessage(MESSAGE_ID + i);
}
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(
loadFile("poll_ack_response.xml", ImmutableMap.of("MSGID", "3-2011", "COUNT", "4")));
}
@Test
void testFailure_noSuchMessage() throws Exception {
assertTransactionalFlow(true);
assertMutatingFlow(true);
Exception e = assertThrows(MessageDoesNotExistException.class, this::runFlow);
assertThat(e).hasMessageThat().contains(String.format("(%d-2011)", MESSAGE_ID));
}
@@ -173,14 +173,14 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
@Test
void testFailure_invalidId_tooFewComponents() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1"));
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow);
}
@Test
void testFailure_invalidId_tooManyComponents() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "2-2-1999-2007"));
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow);
}
@@ -195,21 +195,21 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setMsg("Some poll message.")
.setHistoryEntry(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow);
}
@Test
void testFailure_invalidId_stringInsteadOfNumeric() throws Exception {
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "ABC-12345"));
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(InvalidMessageIdException.class, this::runFlow);
}
@Test
void testFailure_missingId() throws Exception {
setEppInput("poll_ack_missing_id.xml");
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(MissingMessageIdException.class, this::runFlow);
}
@@ -223,7 +223,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setMsg("Some poll message.")
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
assertThrows(NotAuthorizedToAckMessageException.class, this::runFlow);
}
@@ -237,7 +237,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
.setMsg("Some poll message.")
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(true);
assertMutatingFlow(true);
Exception e = assertThrows(MessageDoesNotExistException.class, this::runFlow);
assertThat(e).hasMessageThat().contains(String.format("(%d-2011)", MESSAGE_ID));
}

View File

@@ -87,7 +87,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
@Test
void testSuccess_domainTransferApproved() throws Exception {
persistPendingTransferPollMessage();
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_domain_transfer.xml"));
}
@@ -95,7 +95,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
void testSuccess_clTridNotSpecified() throws Exception {
setEppInput("poll_no_cltrid.xml");
persistPendingTransferPollMessage();
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_domain_transfer_no_cltrid.xml"));
}
@@ -120,7 +120,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.build()))
.setHistoryEntry(createHistoryEntryForEppResource(contact))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_contact_transfer.xml"));
}
@@ -140,7 +140,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
clock.nowUtc())))
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_domain_pending_notification.xml"));
}
@@ -164,7 +164,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
clock.nowUtc())))
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_message_domain_pending_action_immediate_delete.xml"));
}
@@ -178,7 +178,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setTargetId("test.example")
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_autorenew.xml"));
}
@@ -221,7 +221,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setTargetId("target.example")
.setHistoryEntry(createHistoryEntryForEppResource(domain))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_empty.xml"));
}
@@ -244,7 +244,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setHistoryEntry(historyEntry)
.setEventTime(clock.nowUtc().minusDays(1))
.build());
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_contact_delete.xml"));
}
@@ -268,14 +268,14 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
.setEventTime(clock.nowUtc().minusDays(1))
.build());
clock.advanceOneMilli();
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(loadFile("poll_response_host_delete.xml"));
}
@Test
void testFailure_messageIdProvided() throws Exception {
setEppInput("poll_with_id.xml");
assertTransactionalFlow(false);
assertMutatingFlow(false);
EppException thrown = assertThrows(UnexpectedMessageIdException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View File

@@ -30,7 +30,7 @@ class HelloFlowTest extends FlowTestCase<HelloFlow> {
@Test
void testHello() throws Exception {
setEppInput("hello.xml");
assertTransactionalFlow(false);
assertMutatingFlow(false);
runFlowAssertResponse(
loadFile(
"greeting.xml", ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis()))));

View File

@@ -62,7 +62,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
// Also called in subclasses.
void doSuccessfulTest(String xmlFilename) throws Exception {
setEppInput(xmlFilename);
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
}
@@ -81,7 +81,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
@Test
void testSuccess_setsIsLoginResponse() throws Exception {
setEppInput("login_valid.xml");
assertTransactionalFlow(true);
assertMutatingFlow(true);
EppOutput output = runFlow();
assertThat(output.getResponse().isLoginResponse()).isTrue();
}
@@ -125,7 +125,7 @@ public abstract class LoginFlowTestCase extends FlowTestCase<LoginFlow> {
assertThat(registrar.verifyPassword("randomstring")).isFalse();
setEppInput("login_set_new_password.xml", ImmutableMap.of("NEWPW", "ANewPassword"));
assertTransactionalFlow(true);
assertMutatingFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
Registrar newRegistrar = loadRegistrar("NewRegistrar");

View File

@@ -38,7 +38,7 @@ class LogoutFlowTest extends FlowTestCase<LogoutFlow> {
@Test
void testSuccess() throws Exception {
assertTransactionalFlow(false);
assertMutatingFlow(false);
// All flow tests are implicitly logged in, so logout should work.
runFlowAssertResponse(loadFile("logout_response.xml"));
}