mirror of
https://github.com/google/nomulus.git
synced 2025-05-31 17:54:08 +02:00
Flatten the domain transfer flows
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133906420
This commit is contained in:
parent
2d46c7c27c
commit
1b34f1e326
19 changed files with 848 additions and 351 deletions
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||
|
@ -22,15 +23,18 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
|
||||
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
import google.registry.flows.ResourceTransferQueryFlow.NoTransferHistoryToQueryException;
|
||||
import google.registry.flows.ResourceTransferQueryFlow.NotAuthorizedToViewTransferException;
|
||||
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
|
||||
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
|
||||
import google.registry.flows.exceptions.ResourceToQueryDoesNotExistException;
|
||||
import google.registry.model.contact.ContactAuthInfo;
|
||||
import google.registry.model.domain.DomainAuthInfo;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -45,14 +49,16 @@ public class DomainTransferQueryFlowTest
|
|||
setupDomainWithPendingTransfer();
|
||||
}
|
||||
|
||||
private void doSuccessfulTest(String commandFilename, String expectedXmlFilename)
|
||||
throws Exception {
|
||||
private void doSuccessfulTest(
|
||||
String commandFilename,
|
||||
String expectedXmlFilename,
|
||||
DateTime newExpirationTime) throws Exception {
|
||||
setEppInput(commandFilename);
|
||||
// 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);
|
||||
runFlowAssertResponse(readFile(expectedXmlFilename));
|
||||
EppOutput output = runFlowAssertResponse(readFile(expectedXmlFilename));
|
||||
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(
|
||||
HistoryEntry.Type.DOMAIN_CREATE,
|
||||
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
|
||||
|
@ -61,10 +67,11 @@ public class DomainTransferQueryFlowTest
|
|||
getGainingClientAutorenewEvent(),
|
||||
getLosingClientAutorenewEvent());
|
||||
// Look in the future and make sure the poll messages for implicit ack are there.
|
||||
assertThat(getPollMessages("NewRegistrar", clock.nowUtc().plusYears(1)))
|
||||
.hasSize(1);
|
||||
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusYears(1)))
|
||||
.hasSize(1);
|
||||
assertThat(getPollMessages("NewRegistrar", clock.nowUtc().plusYears(1))).hasSize(1);
|
||||
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusYears(1))).hasSize(1);
|
||||
DomainTransferResponse response =
|
||||
((DomainTransferResponse) output.getResponse().getResponseData().get(0));
|
||||
assertThat(response.getExtendedRegistrationExpirationTime()).isEqualTo(newExpirationTime);
|
||||
}
|
||||
|
||||
private void doFailingTest(String commandFilename) throws Exception {
|
||||
|
@ -78,61 +85,95 @@ public class DomainTransferQueryFlowTest
|
|||
|
||||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_sponsoringClient() throws Exception {
|
||||
setClientIdForFlow("TheRegistrar");
|
||||
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_domainAuthInfo() throws Exception {
|
||||
setClientIdForFlow("ClientZ");
|
||||
doSuccessfulTest("domain_transfer_query_domain_authinfo.xml",
|
||||
"domain_transfer_query_response.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query_domain_authinfo.xml",
|
||||
"domain_transfer_query_response.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_contactAuthInfo() throws Exception {
|
||||
setClientIdForFlow("ClientZ");
|
||||
doSuccessfulTest("domain_transfer_query_contact_authinfo.xml",
|
||||
"domain_transfer_query_response.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query_contact_authinfo.xml",
|
||||
"domain_transfer_query_response.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_clientApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_approved.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_approved.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_clientRejected() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_rejected.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_rejected.xml",
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_clientCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_cancelled.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_client_cancelled.xml",
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_serverApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_approved.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_approved.xml",
|
||||
domain.getRegistrationExpirationTime().plusYears(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_serverCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_cancelled.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_cancelled.xml",
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_tenYears() throws Exception {
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setTransferData(domain.getTransferData().asBuilder()
|
||||
.setExtendedRegistrationYears(10)
|
||||
.build())
|
||||
.build());
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_10_years.xml",
|
||||
extendRegistrationWithCap(clock.nowUtc(), domain.getRegistrationExpirationTime(), 10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -140,8 +181,10 @@ public class DomainTransferQueryFlowTest
|
|||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
domain = persistResource(
|
||||
domain.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build());
|
||||
doSuccessfulTest("domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_cancelled.xml");
|
||||
doSuccessfulTest(
|
||||
"domain_transfer_query.xml",
|
||||
"domain_transfer_query_response_server_cancelled.xml",
|
||||
null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue