When resolving a transfer to SERVER_CANCELLED (on delete) still pass in a time

Currently we pass in null. However, from the spec:

<domain:acDate> 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
This commit is contained in:
cgoldfeder 2016-11-16 12:22:42 -08:00 committed by Ben McIlwain
parent a343648b34
commit 438eeb5e38
5 changed files with 12 additions and 9 deletions

View file

@ -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<R, B> & BuilderWithTransferData<B>> B resolvePendingTransfer(
R resource, TransferStatus transferStatus, @Nullable DateTime now) {
R resource, TransferStatus transferStatus, DateTime now) {
return ((B) resource.asBuilder())
.removeStatusValue(StatusValue.PENDING_TRANSFER)
.setTransferData(

View file

@ -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();

View file

@ -122,7 +122,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
HistoryEntry historyEntry = buildHistoryEntry(existingDomain, now);
Builder builder =
ResourceFlowUtils.<DomainResource, DomainResource.Builder>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.

View file

@ -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)));

View file

@ -537,6 +537,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
assertThat(domain.getTransferData().getServerApproveBillingEvent()).isNull();
assertThat(domain.getTransferData().getServerApproveAutorenewEvent()).isNull();
assertThat(domain.getTransferData().getServerApproveAutorenewPollMessage()).isNull();
assertThat(domain.getTransferData().getPendingTransferExpirationTime())
.isEqualTo(clock.nowUtc());
assertThat(ofy().load().key(oldTransferData.getServerApproveBillingEvent()).now()).isNull();
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewEvent()).now()).isNull();
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewPollMessage()).now())