mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Fix RDE import pending transfer handling
Mostly based on the original PR, but with some tweaking by nfelt@, in particular to add some support for autorenew grace period subsumption. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=169922894
This commit is contained in:
parent
2814561e92
commit
3ad21e3834
7 changed files with 495 additions and 89 deletions
|
@ -18,6 +18,7 @@ import static google.registry.flows.domain.DomainTransferUtils.createLosingTrans
|
|||
import static google.registry.flows.domain.DomainTransferUtils.createPendingTransferData;
|
||||
import static google.registry.flows.domain.DomainTransferUtils.createTransferServerApproveEntities;
|
||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_MAP_SHARDS;
|
||||
import static google.registry.model.domain.DomainResource.extendRegistrationWithCap;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
|
||||
import static google.registry.rde.imports.RdeImportUtils.createAutoRenewBillingEventForDomainImport;
|
||||
|
@ -44,6 +45,7 @@ import google.registry.model.billing.BillingEvent;
|
|||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.Period.Unit;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
|
@ -60,6 +62,7 @@ import google.registry.xjc.rdedomain.XjcRdeDomain;
|
|||
import google.registry.xjc.rdedomain.XjcRdeDomainElement;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* A mapreduce that imports domains from an escrow file.
|
||||
|
@ -171,69 +174,118 @@ public class RdeDomainImportAction implements Runnable {
|
|||
getContext().incrementCounter("domain imports attempted");
|
||||
|
||||
logger.infofmt("Saving domain %s", xjcDomain.getName());
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry);
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
|
||||
DomainResource domain = XjcToDomainResourceConverter.convertDomain(
|
||||
xjcDomain, autorenewBillingEvent, autorenewPollMessage);
|
||||
getDnsQueue().addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
// Keep a list of "extra objects" that need to be saved along with the domain
|
||||
// and add to it if necessary.
|
||||
ImmutableSet<Object> extraEntitiesToSave =
|
||||
getImportUtils().createIndexesForEppResource(domain);
|
||||
// Create speculative server approval entities for pending transfers
|
||||
if (domain.getTransferData().getTransferStatus() == TransferStatus.PENDING) {
|
||||
TransferData transferData = domain.getTransferData();
|
||||
checkArgumentNotNull(transferData,
|
||||
"Domain %s is in pending transfer but has no transfer data",
|
||||
domain.getFullyQualifiedDomainName());
|
||||
Money transferCost = getDomainRenewCost(
|
||||
domain.getFullyQualifiedDomainName(),
|
||||
transferData.getPendingTransferExpirationTime(),
|
||||
1);
|
||||
// Create speculative entities in anticipation of an automatic server approval.
|
||||
ImmutableSet<TransferServerApproveEntity> serverApproveEntities =
|
||||
createTransferServerApproveEntities(
|
||||
transferData.getPendingTransferExpirationTime(),
|
||||
domain.getRegistrationExpirationTime().plusYears(1),
|
||||
historyEntry,
|
||||
domain,
|
||||
historyEntry.getTrid(),
|
||||
transferData.getGainingClientId(),
|
||||
Optional.of(transferCost),
|
||||
transferData.getTransferRequestTime());
|
||||
transferData =
|
||||
createPendingTransferData(
|
||||
transferData.asBuilder(),
|
||||
serverApproveEntities,
|
||||
Period.create(1, Unit.YEARS));
|
||||
// Create a poll message to notify the losing registrar that a transfer was requested.
|
||||
PollMessage requestPollMessage = createLosingTransferPollMessage(domain.getRepoId(),
|
||||
transferData, transferData.getPendingTransferExpirationTime(), historyEntry)
|
||||
.asBuilder().setEventTime(transferData.getTransferRequestTime()).build();
|
||||
domain = domain.asBuilder().setTransferData(transferData).build();
|
||||
autorenewBillingEvent = autorenewBillingEvent.asBuilder()
|
||||
.setRecurrenceEndTime(transferData.getPendingTransferExpirationTime()).build();
|
||||
autorenewPollMessage = autorenewPollMessage.asBuilder()
|
||||
.setAutorenewEndTime(transferData.getPendingTransferExpirationTime()).build();
|
||||
extraEntitiesToSave = new ImmutableSet.Builder<>()
|
||||
.add(requestPollMessage)
|
||||
.addAll(extraEntitiesToSave)
|
||||
.addAll(serverApproveEntities).build();
|
||||
} // End pending transfer check
|
||||
ofy().save()
|
||||
.entities(new ImmutableSet.Builder<>()
|
||||
.add(domain, historyEntry, autorenewBillingEvent, autorenewPollMessage)
|
||||
.addAll(extraEntitiesToSave)
|
||||
.build())
|
||||
.now();
|
||||
}
|
||||
});
|
||||
ofy()
|
||||
.transact(
|
||||
new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry);
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
|
||||
DomainResource domain =
|
||||
XjcToDomainResourceConverter.convertDomain(
|
||||
xjcDomain, autorenewBillingEvent, autorenewPollMessage);
|
||||
getDnsQueue().addDomainRefreshTask(domain.getFullyQualifiedDomainName());
|
||||
// Keep a list of "extra objects" that need to be saved along with the domain
|
||||
// and add to it if necessary.
|
||||
ImmutableSet<Object> extraEntitiesToSave =
|
||||
getImportUtils().createIndexesForEppResource(domain);
|
||||
// Create speculative server approval entities for pending transfers
|
||||
if (domain.getTransferData().getTransferStatus() == TransferStatus.PENDING) {
|
||||
TransferData transferData = domain.getTransferData();
|
||||
checkArgumentNotNull(
|
||||
transferData,
|
||||
"Domain %s is in pending transfer but has no transfer data",
|
||||
domain.getFullyQualifiedDomainName());
|
||||
Money transferCost =
|
||||
getDomainRenewCost(
|
||||
domain.getFullyQualifiedDomainName(),
|
||||
transferData.getPendingTransferExpirationTime(),
|
||||
1);
|
||||
DateTime automaticTransferTime =
|
||||
transferData.getPendingTransferExpirationTime();
|
||||
// If the transfer will occur within the autorenew grace period, it should
|
||||
// subsume the autorenew, so we don't add the normal extra year. See the
|
||||
// original logic in DomainTransferRequestFlow (which is very similar) for
|
||||
// more information. That said, note that here we stop 1 millisecond before
|
||||
// the actual transfer time to avoid hitting the transfer-handling part of
|
||||
// cloneProjectedAtTime(), since unlike in the DomainTransferRequestFlow case,
|
||||
// this domain already has a pending transfer.
|
||||
DomainResource domainAtTransferTime =
|
||||
domain.cloneProjectedAtTime(automaticTransferTime.minusMillis(1));
|
||||
boolean inAutorenewGraceAtTransfer =
|
||||
!domainAtTransferTime
|
||||
.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW)
|
||||
.isEmpty();
|
||||
int extraYears = inAutorenewGraceAtTransfer ? 0 : 1;
|
||||
// Construct the capped new expiration time.
|
||||
DateTime serverApproveNewExpirationTime =
|
||||
extendRegistrationWithCap(
|
||||
automaticTransferTime,
|
||||
domainAtTransferTime.getRegistrationExpirationTime(),
|
||||
extraYears);
|
||||
// Create speculative entities in anticipation of an automatic server
|
||||
// approval.
|
||||
ImmutableSet<TransferServerApproveEntity> serverApproveEntities =
|
||||
createTransferServerApproveEntities(
|
||||
automaticTransferTime,
|
||||
serverApproveNewExpirationTime,
|
||||
historyEntry,
|
||||
domain,
|
||||
historyEntry.getTrid(),
|
||||
transferData.getGainingClientId(),
|
||||
Optional.of(transferCost),
|
||||
transferData.getTransferRequestTime());
|
||||
transferData =
|
||||
createPendingTransferData(
|
||||
transferData.asBuilder(),
|
||||
serverApproveEntities,
|
||||
Period.create(1, Unit.YEARS));
|
||||
// Create a poll message to notify the losing registrar that a transfer was
|
||||
// requested.
|
||||
PollMessage requestPollMessage =
|
||||
createLosingTransferPollMessage(
|
||||
domain.getRepoId(),
|
||||
transferData,
|
||||
serverApproveNewExpirationTime,
|
||||
historyEntry)
|
||||
.asBuilder()
|
||||
.setEventTime(transferData.getTransferRequestTime())
|
||||
.build();
|
||||
domain = domain.asBuilder().setTransferData(transferData).build();
|
||||
autorenewBillingEvent =
|
||||
autorenewBillingEvent
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(transferData.getPendingTransferExpirationTime())
|
||||
.build();
|
||||
autorenewPollMessage =
|
||||
autorenewPollMessage
|
||||
.asBuilder()
|
||||
.setAutorenewEndTime(transferData.getPendingTransferExpirationTime())
|
||||
.build();
|
||||
extraEntitiesToSave =
|
||||
new ImmutableSet.Builder<>()
|
||||
.add(requestPollMessage)
|
||||
.addAll(extraEntitiesToSave)
|
||||
.addAll(serverApproveEntities)
|
||||
.build();
|
||||
} // End pending transfer check
|
||||
ofy()
|
||||
.save()
|
||||
.entities(
|
||||
new ImmutableSet.Builder<>()
|
||||
.add(
|
||||
domain,
|
||||
historyEntry,
|
||||
autorenewBillingEvent,
|
||||
autorenewPollMessage)
|
||||
.addAll(extraEntitiesToSave)
|
||||
.build())
|
||||
.now();
|
||||
}
|
||||
});
|
||||
// Record the number of domains imported
|
||||
getContext().incrementCounter("domains saved");
|
||||
logger.infofmt("Domain %s was imported successfully", xjcDomain.getName());
|
||||
|
|
|
@ -16,12 +16,12 @@ package google.registry.rde.imports;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.appengine.tools.cloudstorage.GcsFilename;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -61,7 +61,6 @@ import java.util.UUID;
|
|||
import javax.inject.Inject;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Utility functions for escrow file import.
|
||||
|
@ -89,14 +88,9 @@ public class RdeImportUtils {
|
|||
public <T extends EppResource & ForeignKeyedEppResource> ImmutableSet<Object>
|
||||
createIndexesForEppResource(T resource) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<T> resourceClass = (Class<T>) resource.getClass();
|
||||
Object existing = ofy.load().key(Key.create(resource)).now();
|
||||
if (existing != null) {
|
||||
// This will roll back the transaction and prevent duplicate history entries from being saved.
|
||||
throw new ResourceExistsException();
|
||||
}
|
||||
ForeignKeyIndex<T> existingForeignKeyIndex =
|
||||
ForeignKeyIndex.load(resourceClass, resource.getForeignKey(), START_OF_TIME);
|
||||
ForeignKeyIndex.load(
|
||||
(Class<T>) resource.getClass(), resource.getForeignKey(), START_OF_TIME);
|
||||
// ForeignKeyIndex should never have existed, since existing resource was not found.
|
||||
checkState(
|
||||
existingForeignKeyIndex == null,
|
||||
|
@ -111,20 +105,27 @@ public class RdeImportUtils {
|
|||
/**
|
||||
* Imports a resource from an escrow file.
|
||||
*
|
||||
* <p>The host will only be imported if it has not been previously imported.
|
||||
* <p>The resource will only be imported if it has not been previously imported.
|
||||
*
|
||||
* <p>If the host is imported, {@link ForeignKeyIndex} and {@link EppResourceIndex} are also
|
||||
* <p>If the resource is imported, {@link ForeignKeyIndex} and {@link EppResourceIndex} are also
|
||||
* created.
|
||||
*/
|
||||
public <T extends EppResource & ForeignKeyedEppResource> void
|
||||
importEppResource(final T resource) {
|
||||
Object existing = ofy.load().key(Key.create(resource)).now();
|
||||
if (existing != null) {
|
||||
// This will roll back the transaction and prevent duplicate history entries from being saved.
|
||||
throw new ResourceExistsException();
|
||||
}
|
||||
ofy.save().entities(new ImmutableSet.Builder<>()
|
||||
.add(resource)
|
||||
.addAll(createIndexesForEppResource(resource))
|
||||
.build());
|
||||
logger.infofmt(
|
||||
"Imported %s resource - ROID=%s, id=%s",
|
||||
resource.getClass().getCanonicalName(), resource.getRepoId(), resource.getForeignKey());
|
||||
resource.getClass().getSimpleName(),
|
||||
resource.getRepoId(),
|
||||
resource.getForeignKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,7 +222,7 @@ public class RdeImportUtils {
|
|||
.setType(HistoryEntry.Type.RDE_IMPORT)
|
||||
.setClientId(domain.getClID())
|
||||
.setTrid(generateTridForImport())
|
||||
.setModificationTime(DateTime.now(UTC))
|
||||
.setModificationTime(ofy().getTransactionTime())
|
||||
.setXmlBytes(getObjectXml(element))
|
||||
.setBySuperuser(true)
|
||||
.setReason("RDE Import")
|
||||
|
|
|
@ -46,6 +46,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
|
|||
import google.registry.model.eppcommon.Trid;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.testing.FakeResponse;
|
||||
|
@ -70,6 +71,8 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
private static final ByteSource DEPOSIT_1_DOMAIN = RdeImportsTestData.get("deposit_1_domain.xml");
|
||||
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER =
|
||||
RdeImportsTestData.get("deposit_1_domain_pending_transfer.xml");
|
||||
private static final ByteSource DEPOSIT_1_DOMAIN_PENDING_TRANSFER_REG_CAP =
|
||||
RdeImportsTestData.get("deposit_1_domain_pending_transfer_registration_cap.xml");
|
||||
private static final String IMPORT_BUCKET_NAME = "import-bucket";
|
||||
private static final String IMPORT_FILE_NAME = "escrow-file.xml";
|
||||
|
||||
|
@ -191,7 +194,7 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
|
||||
// Domain should be assigned to RegistrarY after server approval
|
||||
DomainResource afterApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime.plus(Seconds.ONE));
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime);
|
||||
assertThat(afterApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarY");
|
||||
assertThat(loadAutorenewBillingEventForDomain(afterApproval).getClientId())
|
||||
.isEqualTo("RegistrarY");
|
||||
|
@ -213,6 +216,48 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
afterApproval, "RegistrarY", DateTime.parse("2016-04-03T22:00:00.0Z"), END_OF_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapreducePendingTransferRegistrationCap() throws Exception {
|
||||
DateTime serverApprovalTime = DateTime.parse("2015-02-03T22:00:00.0Z");
|
||||
pushToGcs(DEPOSIT_1_DOMAIN_PENDING_TRANSFER_REG_CAP);
|
||||
runMapreduce();
|
||||
List<DomainResource> domains = ofy().load().type(DomainResource.class).list();
|
||||
assertThat(domains).hasSize(1);
|
||||
checkDomain(domains.get(0));
|
||||
|
||||
// Domain should be assigned to RegistrarX before server approval
|
||||
DomainResource beforeApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime.minus(Seconds.ONE));
|
||||
assertThat(beforeApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarX");
|
||||
assertThat(loadAutorenewBillingEventForDomain(beforeApproval).getClientId())
|
||||
.isEqualTo("RegistrarX");
|
||||
assertThat(loadAutorenewPollMessageForDomain(beforeApproval).getClientId())
|
||||
.isEqualTo("RegistrarX");
|
||||
// Current expiration is 2024-04-03T22:00:00.0Z
|
||||
assertThat(beforeApproval.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2024-04-03T22:00:00.0Z"));
|
||||
|
||||
// Domain should be assigned to RegistrarY after server approval
|
||||
DomainResource afterApproval =
|
||||
domains.get(0).cloneProjectedAtTime(serverApprovalTime);
|
||||
assertThat(afterApproval.getCurrentSponsorClientId()).isEqualTo("RegistrarY");
|
||||
// New expiration should be capped at 10 years from server approval time, which is 2025-02-03,
|
||||
// instead of 2025-04-03 which would be the current expiration plus a full year.
|
||||
assertThat(afterApproval.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2025-02-03T22:00:00.0Z"));
|
||||
|
||||
// Same checks for the autorenew billing event and poll message.
|
||||
checkAutorenewBillingEvent(
|
||||
afterApproval, "RegistrarY", DateTime.parse("2025-02-03T22:00:00.0Z"), END_OF_TIME);
|
||||
checkAutorenewPollMessage(
|
||||
afterApproval, "RegistrarY", DateTime.parse("2025-02-03T22:00:00.0Z"), END_OF_TIME);
|
||||
|
||||
// Check expiration time in losing registrar's poll message responseData.
|
||||
checkTransferRequestPollMessage(domains.get(0), "RegistrarX",
|
||||
DateTime.parse("2015-01-29T22:00:00.0Z"),
|
||||
DateTime.parse("2025-02-03T22:00:00.0Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapreducePendingTransferEvents() throws Exception {
|
||||
pushToGcs(DEPOSIT_1_DOMAIN_PENDING_TRANSFER);
|
||||
|
@ -220,11 +265,18 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
List<DomainResource> domains = ofy().load().type(DomainResource.class).list();
|
||||
assertThat(domains).hasSize(1);
|
||||
checkDomain(domains.get(0));
|
||||
checkTransferRequestPollMessage(domains.get(0), "RegistrarX",
|
||||
DateTime.parse("2015-01-03T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(domains.get(0), "RegistrarX",
|
||||
checkTransferRequestPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarX",
|
||||
DateTime.parse("2015-01-03T22:00:00.0Z"),
|
||||
DateTime.parse("2016-04-03T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarX",
|
||||
DateTime.parse("2015-01-08T22:00:00.0Z"));
|
||||
checkTransferServerApprovalPollMessage(domains.get(0), "RegistrarY",
|
||||
checkTransferServerApprovalPollMessage(
|
||||
domains.get(0),
|
||||
"RegistrarY",
|
||||
DateTime.parse("2015-01-08T22:00:00.0Z"));
|
||||
// Billing event is set to the end of the transfer grace period, 5 days after server approval
|
||||
checkTransferBillingEvent(domains.get(0), DateTime.parse("2015-01-13T22:00:00.0Z"));
|
||||
|
@ -244,11 +296,17 @@ public class RdeDomainImportActionTest extends MapreduceTestCase<RdeDomainImport
|
|||
|
||||
/** Verifies the existence of a transfer request poll message */
|
||||
private static void checkTransferRequestPollMessage(
|
||||
DomainResource domain, String clientId, DateTime expectedAt) {
|
||||
DomainResource domain, String clientId, DateTime expectedAt, DateTime expectedExpiration) {
|
||||
for (PollMessage message : getPollMessages(domain)) {
|
||||
if (TransferStatus.PENDING.getMessage().equals(message.getMsg())
|
||||
&& clientId.equals(message.getClientId())
|
||||
&& expectedAt.equals(message.getEventTime())) {
|
||||
assertThat(message.getResponseData()).hasSize(1);
|
||||
DomainTransferResponse responseData =
|
||||
(DomainTransferResponse) message.getResponseData().get(0);
|
||||
// make sure expiration is set correctly
|
||||
assertThat(responseData.getExtendedRegistrationExpirationTime())
|
||||
.isEqualTo(expectedExpiration);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import google.registry.model.eppcommon.StatusValue;
|
|||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
|
@ -232,6 +233,15 @@ public class XjcToDomainResourceConverterTest {
|
|||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.TRANSFER);
|
||||
assertThat(gracePeriod.getClientId()).isEqualTo("RegistrarX");
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(xjcDomain.getUpDate().plusDays(5));
|
||||
TransferData transferData = domain.getTransferData();
|
||||
assertThat(transferData).isNotEqualTo(TransferData.EMPTY);
|
||||
assertThat(transferData.getTransferStatus()).isEqualTo(TransferStatus.CLIENT_APPROVED);
|
||||
assertThat(transferData.getLosingClientId()).isEqualTo("RegistrarY");
|
||||
assertThat(transferData.getTransferRequestTime())
|
||||
.isEqualTo(DateTime.parse("2014-10-08T16:23:21.897803Z"));
|
||||
assertThat(transferData.getGainingClientId()).isEqualTo("RegistrarX");
|
||||
assertThat(transferData.getPendingTransferExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2014-10-09T08:25:43.305554Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -388,18 +398,29 @@ public class XjcToDomainResourceConverterTest {
|
|||
.isEqualTo(DateTime.parse("2015-01-08T22:00:00.0Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertDomainResourcePendingTransferRegistrationCap() throws Exception {
|
||||
persistActiveContact("jd1234");
|
||||
persistActiveContact("sh8013");
|
||||
final XjcRdeDomain xjcDomain =
|
||||
loadDomainFromRdeXml("domain_fragment_pending_transfer_registration_cap.xml");
|
||||
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
|
||||
assertThat(domain.getTransferData()).isNotNull();
|
||||
// This test will be imcomplete until b/36405140 is fixed to store exDate on TransferData, since
|
||||
// without that there's no way to actually test the capping of the projected registration here.
|
||||
}
|
||||
|
||||
private static DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) {
|
||||
final HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
|
||||
final BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry);
|
||||
final PollMessage.Autorenew autorenewPollMessage =
|
||||
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
|
||||
return ofy()
|
||||
.transact(
|
||||
new Work<DomainResource>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public DomainResource run() {
|
||||
HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutoRenewBillingEventForDomainImport(xjcDomain, historyEntry);
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
createAutoRenewPollMessageForDomainImport(xjcDomain, historyEntry);
|
||||
ofy().save().entities(historyEntry, autorenewBillingEvent, autorenewPollMessage);
|
||||
return XjcToDomainResourceConverter.convertDomain(
|
||||
xjcDomain, autorenewBillingEvent, autorenewPollMessage);
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rde:deposit type="FULL" id="20101017001" prevId="20101010001"
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
|
||||
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
|
||||
xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"
|
||||
xmlns:rde="urn:ietf:params:xml:ns:rde-1.0"
|
||||
xmlns:rdeHeader="urn:ietf:params:xml:ns:rdeHeader-1.0"
|
||||
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0"
|
||||
xmlns:rdeHost="urn:ietf:params:xml:ns:rdeHost-1.0"
|
||||
xmlns:rdeContact="urn:ietf:params:xml:ns:rdeContact-1.0"
|
||||
xmlns:rdeRegistrar="urn:ietf:params:xml:ns:rdeRegistrar-1.0"
|
||||
xmlns:rdeIDN="urn:ietf:params:xml:ns:rdeIDN-1.0"
|
||||
xmlns:rdeNNDN="urn:ietf:params:xml:ns:rdeNNDN-1.0"
|
||||
xmlns:rdeEppParams="urn:ietf:params:xml:ns:rdeEppParams-1.0"
|
||||
xmlns:rdePolicy="urn:ietf:params:xml:ns:rdePolicy-1.0"
|
||||
xmlns:epp="urn:ietf:params:xml:ns:epp-1.0">
|
||||
|
||||
<rde:watermark>2010-10-17T00:00:00Z</rde:watermark>
|
||||
<rde:rdeMenu>
|
||||
<rde:version>1.0</rde:version>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeHeader-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeContact-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeHost-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeDomain-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeRegistrar-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeIDN-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeNNDN-1.0</rde:objURI>
|
||||
<rde:objURI>urn:ietf:params:xml:ns:rdeEppParams-1.0</rde:objURI>
|
||||
</rde:rdeMenu>
|
||||
|
||||
<!-- Contents -->
|
||||
<rde:contents>
|
||||
<!-- Header -->
|
||||
<rdeHeader:header>
|
||||
<rdeHeader:tld>test</rdeHeader:tld>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeDomain-1.0">2
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeHost-1.0">1
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeContact-1.0">1
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeRegistrar-1.0">1
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeIDN-1.0">1
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeNNDN-1.0">1
|
||||
</rdeHeader:count>
|
||||
<rdeHeader:count
|
||||
uri="urn:ietf:params:xml:ns:rdeEppParams-1.0">1
|
||||
</rdeHeader:count>
|
||||
</rdeHeader:header>
|
||||
|
||||
<!-- Domain: example1.test -->
|
||||
<rdeDom:domain>
|
||||
<rdeDom:name>example1.test</rdeDom:name>
|
||||
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
|
||||
<rdeDom:status s="ok"/>
|
||||
<rdeDom:registrant>jd1234</rdeDom:registrant>
|
||||
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
|
||||
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
|
||||
<rdeDom:clID>RegistrarX</rdeDom:clID>
|
||||
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
|
||||
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
|
||||
<rdeDom:exDate>2024-04-03T22:00:00.0Z</rdeDom:exDate>
|
||||
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
|
||||
<rdeDom:upDate>2015-01-29T22:00:00.0Z</rdeDom:upDate>
|
||||
<rdeDom:trnData>
|
||||
<rdeDom:trStatus>pending</rdeDom:trStatus>
|
||||
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
|
||||
<rdeDom:reDate>2015-01-29T22:00:00.0Z</rdeDom:reDate>
|
||||
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
|
||||
<rdeDom:acDate>2015-02-03T22:00:00.0Z</rdeDom:acDate>
|
||||
<rdeDom:exDate>2025-02-03T22:00:00.0Z</rdeDom:exDate>
|
||||
</rdeDom:trnData>
|
||||
</rdeDom:domain>
|
||||
|
||||
<!-- Host: ns1.example.com -->
|
||||
<rdeHost:host>
|
||||
<rdeHost:name>ns1.example.com</rdeHost:name>
|
||||
<rdeHost:roid>Hns1_example_com-TEST</rdeHost:roid>
|
||||
<rdeHost:status s="ok"/>
|
||||
<rdeHost:status s="linked"/>
|
||||
<rdeHost:addr ip="v4">192.0.2.2</rdeHost:addr>
|
||||
<rdeHost:addr ip="v4">192.0.2.29</rdeHost:addr>
|
||||
<rdeHost:addr ip="v6">1080:0:0:0:8:800:200C:417A
|
||||
</rdeHost:addr>
|
||||
<rdeHost:clID>RegistrarX</rdeHost:clID>
|
||||
<rdeHost:crRr>RegistrarX</rdeHost:crRr>
|
||||
<rdeHost:crDate>1999-05-08T12:10:00.0Z</rdeHost:crDate>
|
||||
<rdeHost:upRr>RegistrarX</rdeHost:upRr>
|
||||
<rdeHost:upDate>2009-10-03T09:34:00.0Z</rdeHost:upDate>
|
||||
</rdeHost:host>
|
||||
|
||||
<!-- Host: ns1.example1.test -->
|
||||
<rdeHost:host>
|
||||
<rdeHost:name>ns1.example1.test</rdeHost:name>
|
||||
<rdeHost:roid>Hns1_example1_test-TEST</rdeHost:roid>
|
||||
<rdeHost:status s="ok"/>
|
||||
<rdeHost:status s="linked"/>
|
||||
<rdeHost:addr ip="v4">192.0.2.2</rdeHost:addr>
|
||||
<rdeHost:addr ip="v4">192.0.2.29</rdeHost:addr>
|
||||
<rdeHost:addr ip="v6">1080:0:0:0:8:800:200C:417A
|
||||
</rdeHost:addr>
|
||||
<rdeHost:clID>RegistrarX</rdeHost:clID>
|
||||
<rdeHost:crRr>RegistrarX</rdeHost:crRr>
|
||||
<rdeHost:crDate>1999-05-08T12:10:00.0Z</rdeHost:crDate>
|
||||
<rdeHost:upRr>RegistrarX</rdeHost:upRr>
|
||||
<rdeHost:upDate>2009-10-03T09:34:00.0Z</rdeHost:upDate>
|
||||
</rdeHost:host>
|
||||
|
||||
<!-- Contact: sh8013 -->
|
||||
<rdeContact:contact>
|
||||
<rdeContact:id>sh8013</rdeContact:id>
|
||||
<rdeContact:roid>Csh8013-TEST</rdeContact:roid>
|
||||
<rdeContact:status s="linked"/>
|
||||
<rdeContact:status s="clientDeleteProhibited"/>
|
||||
<rdeContact:postalInfo type="int">
|
||||
<contact:name>John Doe</contact:name>
|
||||
<contact:org>Example Inc.</contact:org>
|
||||
<contact:addr>
|
||||
<contact:street>123 Example Dr.</contact:street>
|
||||
<contact:street>Suite 100</contact:street>
|
||||
<contact:city>Dulles</contact:city>
|
||||
<contact:sp>VA</contact:sp>
|
||||
<contact:pc>20166-6503</contact:pc>
|
||||
<contact:cc>US</contact:cc>
|
||||
</contact:addr>
|
||||
</rdeContact:postalInfo>
|
||||
<rdeContact:voice x="1234">+1.7035555555
|
||||
</rdeContact:voice>
|
||||
<rdeContact:fax>+1.7035555556
|
||||
</rdeContact:fax>
|
||||
<rdeContact:email>jdoe@example.test
|
||||
</rdeContact:email>
|
||||
<rdeContact:clID>RegistrarX</rdeContact:clID>
|
||||
<rdeContact:crRr client="jdoe">RegistrarX
|
||||
</rdeContact:crRr>
|
||||
<rdeContact:crDate>2009-09-13T08:01:00.0Z</rdeContact:crDate>
|
||||
<rdeContact:upRr client="jdoe">RegistrarX
|
||||
</rdeContact:upRr>
|
||||
<rdeContact:upDate>2009-11-26T09:10:00.0Z</rdeContact:upDate>
|
||||
<rdeContact:trDate>2009-12-03T09:05:00.0Z</rdeContact:trDate>
|
||||
<rdeContact:disclose flag="0">
|
||||
<contact:voice/>
|
||||
<contact:email/>
|
||||
</rdeContact:disclose>
|
||||
</rdeContact:contact>
|
||||
|
||||
<!-- Registrar: RegistrarX -->
|
||||
<rdeRegistrar:registrar>
|
||||
<rdeRegistrar:id>RegistrarX</rdeRegistrar:id>
|
||||
<rdeRegistrar:name>Registrar X</rdeRegistrar:name>
|
||||
<rdeRegistrar:gurid>123</rdeRegistrar:gurid>
|
||||
<rdeRegistrar:status>ok</rdeRegistrar:status>
|
||||
<rdeRegistrar:postalInfo type="int">
|
||||
<rdeRegistrar:addr>
|
||||
<rdeRegistrar:street>123 Example Dr.
|
||||
</rdeRegistrar:street>
|
||||
<rdeRegistrar:street>Suite 100
|
||||
</rdeRegistrar:street>
|
||||
<rdeRegistrar:city>Dulles</rdeRegistrar:city>
|
||||
<rdeRegistrar:sp>VA</rdeRegistrar:sp>
|
||||
<rdeRegistrar:pc>20166-6503</rdeRegistrar:pc>
|
||||
<rdeRegistrar:cc>US</rdeRegistrar:cc>
|
||||
</rdeRegistrar:addr>
|
||||
</rdeRegistrar:postalInfo>
|
||||
<rdeRegistrar:voice x="1234">+1.7035555555
|
||||
</rdeRegistrar:voice>
|
||||
<rdeRegistrar:fax>+1.7035555556
|
||||
</rdeRegistrar:fax>
|
||||
<rdeRegistrar:email>jdoe@example.test
|
||||
</rdeRegistrar:email>
|
||||
<rdeRegistrar:url>http://www.example.test
|
||||
</rdeRegistrar:url>
|
||||
<rdeRegistrar:whoisInfo>
|
||||
<rdeRegistrar:name>whois.example.test
|
||||
</rdeRegistrar:name>
|
||||
<rdeRegistrar:url>http://whois.example.test
|
||||
</rdeRegistrar:url>
|
||||
</rdeRegistrar:whoisInfo>
|
||||
<rdeRegistrar:crDate>2005-04-23T11:49:00.0Z</rdeRegistrar:crDate>
|
||||
<rdeRegistrar:upDate>2009-02-17T17:51:00.0Z</rdeRegistrar:upDate>
|
||||
</rdeRegistrar:registrar>
|
||||
|
||||
<!-- IDN Table -->
|
||||
<rdeIDN:idnTableRef id="pt-BR">
|
||||
<rdeIDN:url>
|
||||
http://www.iana.org/domains/idn-tables/tables/br_pt-br_1.0.html
|
||||
</rdeIDN:url>
|
||||
<rdeIDN:urlPolicy>
|
||||
http://registro.br/dominio/regras.html
|
||||
</rdeIDN:urlPolicy>
|
||||
</rdeIDN:idnTableRef>
|
||||
|
||||
<!-- NNDN: pinguino.test -->
|
||||
<rdeNNDN:NNDN>
|
||||
<rdeNNDN:aName>xn--exampl-gva.test</rdeNNDN:aName>
|
||||
<rdeNNDN:idnTableId>pt-BR</rdeNNDN:idnTableId>
|
||||
<rdeNNDN:originalName>example1.test</rdeNNDN:originalName>
|
||||
<rdeNNDN:nameState>withheld</rdeNNDN:nameState>
|
||||
<rdeNNDN:crDate>2005-04-23T11:49:00.0Z</rdeNNDN:crDate>
|
||||
</rdeNNDN:NNDN>
|
||||
|
||||
<!-- EppParams -->
|
||||
<rdeEppParams:eppParams>
|
||||
<rdeEppParams:version>1.0</rdeEppParams:version>
|
||||
<rdeEppParams:lang>en</rdeEppParams:lang>
|
||||
<rdeEppParams:objURI>
|
||||
urn:ietf:params:xml:ns:domain-1.0
|
||||
</rdeEppParams:objURI>
|
||||
<rdeEppParams:objURI>
|
||||
urn:ietf:params:xml:ns:contact-1.0
|
||||
</rdeEppParams:objURI>
|
||||
<rdeEppParams:objURI>
|
||||
urn:ietf:params:xml:ns:host-1.0
|
||||
</rdeEppParams:objURI>
|
||||
<rdeEppParams:svcExtension>
|
||||
<epp:extURI>urn:ietf:params:xml:ns:rgp-1.0
|
||||
</epp:extURI>
|
||||
<epp:extURI>urn:ietf:params:xml:ns:secDNS-1.1
|
||||
</epp:extURI>
|
||||
</rdeEppParams:svcExtension>
|
||||
<rdeEppParams:dcp>
|
||||
<epp:access><epp:all/></epp:access>
|
||||
<epp:statement>
|
||||
<epp:purpose>
|
||||
<epp:admin/>
|
||||
<epp:prov/>
|
||||
</epp:purpose>
|
||||
<epp:recipient>
|
||||
<epp:ours/>
|
||||
<epp:public/>
|
||||
</epp:recipient>
|
||||
<epp:retention>
|
||||
<epp:stated/>
|
||||
</epp:retention>
|
||||
</epp:statement>
|
||||
</rdeEppParams:dcp>
|
||||
</rdeEppParams:eppParams>
|
||||
<rdePolicy:policy
|
||||
scope="//rde:deposit/rde:contents/rdeDomain:domain"
|
||||
element="rdeDom:registrant" />
|
||||
</rde:contents>
|
||||
</rde:deposit>
|
|
@ -0,0 +1,24 @@
|
|||
<rdeDom:domain
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
|
||||
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0">
|
||||
<rdeDom:name>example1.example</rdeDom:name>
|
||||
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
|
||||
<rdeDom:status s="pendingTransfer"/>
|
||||
<rdeDom:registrant>jd1234</rdeDom:registrant>
|
||||
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
|
||||
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
|
||||
<rdeDom:clID>RegistrarX</rdeDom:clID>
|
||||
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
|
||||
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
|
||||
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
|
||||
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
|
||||
<rdeDom:upDate>2015-01-03T22:00:00.0Z</rdeDom:upDate>
|
||||
<rdeDom:trnData>
|
||||
<rdeDom:trStatus>pending</rdeDom:trStatus>
|
||||
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
|
||||
<rdeDom:reDate>2015-01-03T22:00:00.0Z</rdeDom:reDate>
|
||||
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
|
||||
<rdeDom:acDate>2015-01-08T22:00:00.0Z</rdeDom:acDate>
|
||||
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
|
||||
</rdeDom:trnData>
|
||||
</rdeDom:domain>
|
|
@ -19,6 +19,6 @@
|
|||
<rdeDom:reDate>2014-10-08T16:23:21.897803Z</rdeDom:reDate>
|
||||
<rdeDom:acRr>RegistrarY</rdeDom:acRr>
|
||||
<rdeDom:acDate>2014-10-09T08:25:43.305554Z</rdeDom:acDate>
|
||||
<rdeDom:exDate>2017-08-07T18:05:14.039016Z</rdeDom:exDate>
|
||||
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
|
||||
</rdeDom:trnData>
|
||||
</rdeDom:domain>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue