Add otherClientId to HistoryEntry

This CL adds an otherClientId field to be populated on domain transfers with client ID of the other end of the transaction (losing registrar for requests and cancels, gaining registrar for approves and rejects). This will be used for reporting in compliance with specification 3 of the ICANN registry agreement.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143775945
This commit is contained in:
Ben Kelsey 2017-01-06 08:17:24 -08:00 committed by Ben McIlwain
parent 25a8bbe890
commit 44972b916a
11 changed files with 49 additions and 3 deletions

View file

@ -102,13 +102,14 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
verifyResourceOwnership(clientId, existingDomain); verifyResourceOwnership(clientId, existingDomain);
String tld = existingDomain.getTld(); String tld = existingDomain.getTld();
checkAllowedAccessToTld(clientId, tld); checkAllowedAccessToTld(clientId, tld);
TransferData transferData = existingDomain.getTransferData();
String gainingClientId = transferData.getGainingClientId();
HistoryEntry historyEntry = historyBuilder HistoryEntry historyEntry = historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE)
.setModificationTime(now) .setModificationTime(now)
.setOtherClientId(gainingClientId)
.setParent(Key.create(existingDomain)) .setParent(Key.create(existingDomain))
.build(); .build();
TransferData transferData = existingDomain.getTransferData();
String gainingClientId = transferData.getGainingClientId();
int extraYears = transferData.getExtendedRegistrationYears(); int extraYears = transferData.getExtendedRegistrationYears();
// Bill for the transfer. // Bill for the transfer.
BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder() BillingEvent.OneTime billingEvent = new BillingEvent.OneTime.Builder()

View file

@ -87,6 +87,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
checkAllowedAccessToTld(clientId, existingDomain.getTld()); checkAllowedAccessToTld(clientId, existingDomain.getTld());
HistoryEntry historyEntry = historyBuilder HistoryEntry historyEntry = historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL)
.setOtherClientId(existingDomain.getTransferData().getLosingClientId())
.setModificationTime(now) .setModificationTime(now)
.setParent(Key.create(existingDomain)) .setParent(Key.create(existingDomain))
.build(); .build();

View file

@ -82,6 +82,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
HistoryEntry historyEntry = historyBuilder HistoryEntry historyEntry = historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REJECT) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REJECT)
.setModificationTime(now) .setModificationTime(now)
.setOtherClientId(existingDomain.getTransferData().getGainingClientId())
.setParent(Key.create(existingDomain)) .setParent(Key.create(existingDomain))
.build(); .build();
verifyOptionalAuthInfo(authInfo, existingDomain); verifyOptionalAuthInfo(authInfo, existingDomain);

View file

@ -211,6 +211,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
private HistoryEntry buildHistory(Period period, DomainResource existingResource, DateTime now) { private HistoryEntry buildHistory(Period period, DomainResource existingResource, DateTime now) {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST)
.setOtherClientId(existingResource.getCurrentSponsorClientId())
.setPeriod(period) .setPeriod(period)
.setModificationTime(now) .setModificationTime(now)
.setParent(Key.create(existingResource)) .setParent(Key.create(existingResource))

View file

@ -103,6 +103,15 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
@Index @Index
String clientId; String clientId;
/**
* For transfers, the id of the other registrar.
*
* <p>For requests and cancels, the other registrar is the losing party (because the registrar
* sending the EPP transfer command is the gaining party). For approves and rejects, the other
* registrar is the gaining party.
*/
String otherClientId;
/** Transaction id that made this change. */ /** Transaction id that made this change. */
Trid trid; Trid trid;
@ -139,6 +148,10 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
return clientId; return clientId;
} }
public String getOtherClientId() {
return otherClientId;
}
public Trid getTrid() { public Trid getTrid() {
return trid; return trid;
} }
@ -203,6 +216,11 @@ public class HistoryEntry extends ImmutableObject implements Buildable {
return this; return this;
} }
public Builder setOtherClientId(String otherClientId) {
getInstance().otherClientId = otherClientId;
return this;
}
public Builder setTrid(Trid trid) { public Builder setTrid(Trid trid) {
getInstance().trid = trid; getInstance().trid = trid;
return this; return this;

View file

@ -26,6 +26,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains; import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.HostResourceSubject.assertAboutHosts; import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
@ -155,6 +156,8 @@ public class DomainTransferApproveFlowTest
HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE); HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
final HistoryEntry historyEntryTransferApproved = final HistoryEntry historyEntryTransferApproved =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE); getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
assertAboutHistoryEntries().that(historyEntryTransferApproved)
.hasOtherClientId("NewRegistrar");
assertTransferApproved(domain); assertTransferApproved(domain);
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime); assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()) assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())

View file

@ -22,6 +22,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains; import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -117,6 +118,10 @@ public class DomainTransferCancelFlowTest
HistoryEntry.Type.DOMAIN_CREATE, HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST,
HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL); HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL);
final HistoryEntry historyEntryTransferCancel =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL);
assertAboutHistoryEntries().that(historyEntryTransferCancel).hasClientId("NewRegistrar")
.and().hasOtherClientId("TheRegistrar");
// The only billing event left should be the original autorenew event, now reopened. // The only billing event left should be the original autorenew event, now reopened.
assertBillingEvents( assertBillingEvents(
getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build()); getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build());

View file

@ -17,10 +17,12 @@ package google.registry.flows.domain;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.deleteResource;
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatastoreHelper.getOnlyPollMessage; import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains; import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
@ -90,6 +92,11 @@ public class DomainTransferRejectFlowTest
HistoryEntry.Type.DOMAIN_CREATE, HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST,
HistoryEntry.Type.DOMAIN_TRANSFER_REJECT); HistoryEntry.Type.DOMAIN_TRANSFER_REJECT);
final HistoryEntry historyEntryTransferRejected =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REJECT);
assertAboutHistoryEntries()
.that(historyEntryTransferRejected)
.hasOtherClientId("NewRegistrar");
// The only billing event left should be the original autorenew event, now reopened. // The only billing event left should be the original autorenew event, now reopened.
assertBillingEvents( assertBillingEvents(
getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build()); getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build());

View file

@ -190,7 +190,11 @@ public class DomainTransferRequestFlowTest
.hasOneHistoryEntryEachOfTypes( .hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE, HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST); HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
assertAboutHistoryEntries().that(historyEntryTransferRequest).hasPeriodYears(registrationYears); assertAboutHistoryEntries()
.that(historyEntryTransferRequest)
.hasPeriodYears(registrationYears)
.and()
.hasOtherClientId("TheRegistrar");
assertAboutHosts().that(subordinateHost).hasNoHistoryEntries(); assertAboutHosts().that(subordinateHost).hasNoHistoryEntries();
assertThat(getPollMessages("TheRegistrar", clock.nowUtc())).hasSize(1); assertThat(getPollMessages("TheRegistrar", clock.nowUtc())).hasSize(1);

View file

@ -43,6 +43,7 @@ public class HistoryEntryTest extends EntityTestCase {
.setXmlBytes("<xml></xml>".getBytes(UTF_8)) .setXmlBytes("<xml></xml>".getBytes(UTF_8))
.setModificationTime(clock.nowUtc()) .setModificationTime(clock.nowUtc())
.setClientId("foo") .setClientId("foo")
.setOtherClientId("otherClient")
.setTrid(Trid.create("ABC-123")) .setTrid(Trid.create("ABC-123"))
.setBySuperuser(false) .setBySuperuser(false)
.setReason("reason") .setReason("reason")

View file

@ -59,6 +59,10 @@ public class HistoryEntrySubject extends Subject<HistoryEntrySubject, HistoryEnt
return hasValue(clientId, actual().getClientId(), "has client ID"); return hasValue(clientId, actual().getClientId(), "has client ID");
} }
public And<HistoryEntrySubject> hasOtherClientId(String otherClientId) {
return hasValue(otherClientId, actual().getOtherClientId(), "has other client ID");
}
public And<HistoryEntrySubject> hasPeriod() { public And<HistoryEntrySubject> hasPeriod() {
if (actual().getPeriod() == null) { if (actual().getPeriod() == null) {
fail("has a period"); fail("has a period");