Scope down TransferData to only ContactResource and DomainResource

HostResource and DomainApplication are not transferable, (or at
least, not directly in the case of hosts) and have no need for
the TransferData field. In a flat-flow world, we can push it down
to where it's actually used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139201423
This commit is contained in:
cgoldfeder 2016-11-15 08:03:25 -08:00 committed by Ben McIlwain
parent 0234795240
commit 84009eaccb
24 changed files with 309 additions and 240 deletions

View file

@ -43,7 +43,6 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.model.EppResource;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Cancellation;
import google.registry.model.billing.BillingEvent.Cancellation.Builder;
@ -98,8 +97,8 @@ public class DomainTransferApproveFlowTest
clock.advanceOneMilli();
}
private void assertTransferApproved(EppResource resource) {
assertAboutEppResources().that(resource)
private void assertTransferApproved(DomainResource domain) {
assertAboutDomains().that(domain)
.hasTransferStatus(TransferStatus.CLIENT_APPROVED).and()
.hasCurrentSponsorClientId("NewRegistrar").and()
.hasLastTransferTime(clock.nowUtc()).and()
@ -107,6 +106,13 @@ public class DomainTransferApproveFlowTest
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER);
}
private void assertTransferApproved(HostResource host) {
assertAboutEppResources().that(host)
.hasCurrentSponsorClientId("NewRegistrar").and()
.hasLastTransferTime(clock.nowUtc()).and()
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER);
}
private void setEppLoader(String commandFilename) {
setEppInput(commandFilename);
// Replace the ROID in the xml file with the one generated in our test.

View file

@ -112,9 +112,7 @@ public class DomainTransferCancelFlowTest
assertAboutDomains().that(domain)
.hasRegistrationExpirationTime(originalExpirationTime).and()
.hasLastTransferTimeNotEqualTo(clock.nowUtc());
assertTransferFailed(
reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()),
TransferStatus.CLIENT_CANCELLED);
assertTransferFailed(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST,

View file

@ -23,6 +23,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDomainWithPendingTransfer;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@ -210,19 +211,25 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.build();
}
protected void assertTransferFailed(EppResource resource, TransferStatus status) {
assertAboutEppResources().that(resource)
protected void assertTransferFailed(DomainResource domain, TransferStatus status) {
assertAboutDomains().that(domain)
.hasTransferStatus(status).and()
.hasPendingTransferExpirationTime(clock.nowUtc()).and()
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER).and()
.hasCurrentSponsorClientId("TheRegistrar");
TransferData transferData = resource.getTransferData();
TransferData transferData = domain.getTransferData();
assertThat(transferData.getServerApproveBillingEvent()).isNull();
assertThat(transferData.getServerApproveAutorenewEvent()).isNull();
assertThat(transferData.getServerApproveAutorenewPollMessage()).isNull();
assertThat(transferData.getServerApproveEntities()).isEmpty();
}
protected void assertTransferFailed(HostResource resource) {
assertAboutEppResources().that(resource)
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER).and()
.hasCurrentSponsorClientId("TheRegistrar");
}
/** Adds a .tld domain that has a pending transfer on it from TheRegistrar to NewRegistrar. */
protected void setupDomainWithPendingTransfer() throws Exception {
setupDomainWithPendingTransfer("tld");

View file

@ -82,9 +82,7 @@ public class DomainTransferRejectFlowTest
// Transfer should have been rejected. Verify correct fields were set.
domain = reloadResourceByForeignKey();
assertTransferFailed(domain, TransferStatus.CLIENT_REJECTED);
assertTransferFailed(
reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()),
TransferStatus.CLIENT_REJECTED);
assertTransferFailed(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
assertAboutDomains().that(domain)
.hasRegistrationExpirationTime(originalExpirationTime).and()
.hasLastTransferTimeNotEqualTo(clock.nowUtc()).and()

View file

@ -53,7 +53,6 @@ import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.model.EppResource;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Cancellation.Builder;
import google.registry.model.billing.BillingEvent.Flag;
@ -67,6 +66,7 @@ import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerS
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.poll.PendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.registrar.Registrar;
@ -102,8 +102,8 @@ public class DomainTransferRequestFlowTest
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
}
private void assertTransferRequested(EppResource resource) throws Exception {
assertAboutEppResources().that(resource)
private void assertTransferRequested(DomainResource domain) throws Exception {
assertAboutDomains().that(domain)
.hasTransferStatus(TransferStatus.PENDING).and()
.hasTransferGainingClientId("NewRegistrar").and()
.hasTransferLosingClientId("TheRegistrar").and()
@ -114,9 +114,15 @@ public class DomainTransferRequestFlowTest
.hasStatusValue(StatusValue.PENDING_TRANSFER);
}
private void assertTransferApproved(EppResource resource) {
private void assertTransferRequested(HostResource host) throws Exception {
assertAboutEppResources().that(host)
.hasCurrentSponsorClientId("TheRegistrar").and()
.hasStatusValue(StatusValue.PENDING_TRANSFER);
}
private void assertTransferApproved(DomainResource domain) {
DateTime afterAutoAck = clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength());
assertAboutEppResources().that(resource)
assertAboutDomains().that(domain)
.hasTransferStatus(TransferStatus.SERVER_APPROVED).and()
.hasCurrentSponsorClientId("NewRegistrar").and()
.hasLastTransferTime(afterAutoAck).and()
@ -124,6 +130,14 @@ public class DomainTransferRequestFlowTest
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER);
}
private void assertTransferApproved(HostResource host) {
DateTime afterAutoAck = clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength());
assertAboutEppResources().that(host)
.hasCurrentSponsorClientId("NewRegistrar").and()
.hasLastTransferTime(afterAutoAck).and()
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER);
}
/**
* Runs a successful test. The extraExpectedBillingEvents parameter consists of cancellation
* billing event builders that have had all of their attributes set except for the parent history