From 438eeb5e38ebca60bb6bb21839b62b8921e3cd82 Mon Sep 17 00:00:00 2001 From: cgoldfeder Date: Wed, 16 Nov 2016 12:22:42 -0800 Subject: [PATCH] When resolving a transfer to SERVER_CANCELLED (on delete) still pass in a time Currently we pass in null. However, from the spec: element that contains the date and time of a required or completed response. For a PENDING request, the value identifies the date and time by which a response is required before an automated response action will be taken by the server. For all other status types, the value identifies the date and time when the request was completed." - https://tools.ietf.org/html/rfc5731#page-16, section 3.1.3 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=139363370 --- java/google/registry/flows/ResourceFlowUtils.java | 9 +++------ .../flows/async/DeleteContactsAndHostsAction.java | 2 +- java/google/registry/flows/domain/DomainDeleteFlow.java | 2 +- .../flows/async/DeleteContactsAndHostsActionTest.java | 6 +++++- .../registry/flows/domain/DomainDeleteFlowTest.java | 2 ++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/java/google/registry/flows/ResourceFlowUtils.java b/java/google/registry/flows/ResourceFlowUtils.java index ca3caaf23..8e4ea0020 100644 --- a/java/google/registry/flows/ResourceFlowUtils.java +++ b/java/google/registry/flows/ResourceFlowUtils.java @@ -14,6 +14,7 @@ package google.registry.flows; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.tryFind; import static com.google.common.collect.Sets.intersection; @@ -67,7 +68,6 @@ import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferStatus; import java.util.List; import java.util.Set; -import javax.annotation.Nullable; import org.joda.time.DateTime; /** Static utility functions for resource flows. */ @@ -221,7 +221,7 @@ public final class ResourceFlowUtils { .setServerApproveAutorenewEvent(null) .setServerApproveAutorenewPollMessage(null) .setTransferStatus(transferStatus) - .setPendingTransferExpirationTime(now) + .setPendingTransferExpirationTime(checkNotNull(now)) .build(); } @@ -232,15 +232,12 @@ public final class ResourceFlowUtils { * {@link TransferStatus}, clears all the server-approve fields on the {@link TransferData} * including the extended registration years field, and sets the expiration time of the last * pending transfer to now. - * - * @param now the time that the transfer was resolved, or null if the transfer was never actually - * resolved but the resource was deleted while it was still pending. */ @SuppressWarnings("unchecked") public static < R extends EppResource & ResourceWithTransferData, B extends EppResource.Builder & BuilderWithTransferData> B resolvePendingTransfer( - R resource, TransferStatus transferStatus, @Nullable DateTime now) { + R resource, TransferStatus transferStatus, DateTime now) { return ((B) resource.asBuilder()) .removeStatusValue(StatusValue.PENDING_TRANSFER) .setTransferData( diff --git a/java/google/registry/flows/async/DeleteContactsAndHostsAction.java b/java/google/registry/flows/async/DeleteContactsAndHostsAction.java index d3cd2dc15..6b8f11c5d 100644 --- a/java/google/registry/flows/async/DeleteContactsAndHostsAction.java +++ b/java/google/registry/flows/async/DeleteContactsAndHostsAction.java @@ -319,7 +319,7 @@ public class DeleteContactsAndHostsAction implements Runnable { ContactResource contact = (ContactResource) resource; resourceToSaveBuilder = contact.asBuilder() .setTransferData(createResolvedTransferData( - contact.getTransferData(), TransferStatus.SERVER_CANCELLED, null)) + contact.getTransferData(), TransferStatus.SERVER_CANCELLED, now)) .wipeOut(); } else { resourceToSaveBuilder = resource.asBuilder(); diff --git a/java/google/registry/flows/domain/DomainDeleteFlow.java b/java/google/registry/flows/domain/DomainDeleteFlow.java index 055aa4cdb..ce3b3491d 100644 --- a/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -122,7 +122,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now); Builder builder = ResourceFlowUtils.resolvePendingTransfer( - existingDomain, TransferStatus.SERVER_CANCELLED, null); + existingDomain, TransferStatus.SERVER_CANCELLED, now); builder.setDeletionTime(now).setStatusValues(null); // If the domain is in the Add Grace Period, we delete it immediately, which is already // reflected in the builder we just prepared. Otherwise we give it a PENDING_DELETE status. diff --git a/javatests/google/registry/flows/async/DeleteContactsAndHostsActionTest.java b/javatests/google/registry/flows/async/DeleteContactsAndHostsActionTest.java index 38ad07efa..445f3ba55 100644 --- a/javatests/google/registry/flows/async/DeleteContactsAndHostsActionTest.java +++ b/javatests/google/registry/flows/async/DeleteContactsAndHostsActionTest.java @@ -210,9 +210,13 @@ public class DeleteContactsAndHostsActionTest // Check that the contact is deleted as of now. assertThat(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())).isNull(); // Check that it's still there (it wasn't deleted yesterday) and that it has history. + ContactResource softDeletedContact = + loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc().minusDays(1)); assertAboutContacts() - .that(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc().minusDays(1))) + .that(softDeletedContact) .hasOneHistoryEntryEachOfTypes(CONTACT_TRANSFER_REQUEST, CONTACT_DELETE); + assertThat(softDeletedContact.getTransferData().getPendingTransferExpirationTime()) + .isEqualTo(softDeletedContact.getDeletionTime()); assertNoBillingEvents(); PollMessage deletePollMessage = Iterables.getOnlyElement(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))); diff --git a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java index 98696e918..4d456f643 100644 --- a/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -537,6 +537,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase