mirror of
https://github.com/google/nomulus.git
synced 2025-08-06 09:45:19 +02:00
DeReference the codebase
This change replaces all Ref objects in the code with Key objects. These are stored in datastore as the same object (raw datastore keys), so this is not a model change. Our best practices doc says to use Keys not Refs because: * The .get() method obscures what's actually going on - Much harder to visually audit the code for datastore loads - Hard to distinguish Ref<T> get()'s from Optional get()'s and Supplier get()'s * Implicit ofy().load() offers much less control - Antipattern for ultimate goal of making Ofy injectable - Can't control cache use or batch loading without making ofy() explicit anyway * Serialization behavior is surprising and could be quite dangerous/incorrect - Can lead to serialization errors. If it actually worked "as intended", it would lead to a Ref<> on a serialized object being replaced upon deserialization with a stale copy of the old value, which could potentially break all kinds of transactional expectations * Having both Ref<T> and Key<T> introduces extra boilerplate everywhere - E.g. helper methods all need to have Ref and Key overloads, or you need to call .key() to get the Key<T> for every Ref<T> you want to pass in - Creating a Ref<T> is more cumbersome, since it doesn't have all the create() overloads that Key<T> has, only create(Key<T>) and create(Entity) - no way to create directly from kind+ID/name, raw Key, websafe key string, etc. (Note that Refs are treated specially by Objectify's @Load method and Keys are not; we don't use that feature, but it is the one advantage Refs have over Keys.) The direct impetus for this change is that I am trying to audit our use of memcache, and the implicit .get() calls to datastore were making that very hard. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131965491
This commit is contained in:
parent
1a60073b24
commit
5098b03af4
119 changed files with 772 additions and 817 deletions
|
@ -17,6 +17,7 @@ package google.registry.flows.domain;
|
|||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -39,7 +40,7 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.domain.DomainAllocateFlow.HasFinalStatusException;
|
||||
|
@ -208,11 +209,11 @@ public class DomainAllocateFlowTest
|
|||
CLIENT_ID,
|
||||
null),
|
||||
createBillingEvent));
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(domain.getRegistrationExpirationTime());
|
||||
|
||||
assertThat(domain.getApplicationTime()).isEqualTo(APPLICATION_TIME);
|
||||
assertThat(domain.getApplication()).isEqualTo(Ref.create(application));
|
||||
assertThat(domain.getApplication()).isEqualTo(Key.create(application));
|
||||
if (nameservers == 0) {
|
||||
assertNoDnsTasksEnqueued();
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
|
@ -85,10 +85,10 @@ public class DomainApplicationDeleteFlowTest
|
|||
persistResource(newDomainApplication("example.tld").asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
.setRegistrant(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
||||
.build());
|
||||
doSuccessfulTest();
|
||||
|
|
|
@ -25,7 +25,7 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
|
@ -87,12 +87,12 @@ public class DomainApplicationInfoFlowTest
|
|||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setRegistrant(Key.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||
.setNameservers(hostsState.equals(HostsState.HOSTS_EXIST) ? ImmutableSet.of(
|
||||
Ref.create(host1), Ref.create(host2)) : null)
|
||||
Key.create(host1), Key.create(host2)) : null)
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
.setApplicationStatus(ApplicationStatus.PENDING_VALIDATION)
|
||||
|
@ -242,7 +242,7 @@ public class DomainApplicationInfoFlowTest
|
|||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||
.setNameservers(ImmutableSet.of(
|
||||
Ref.create(host1), Ref.create(host2)))
|
||||
Key.create(host1), Key.create(host2)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_sunrise_response_dsdata.xml", HostsState.NO_HOSTS_EXIST);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ public class DomainApplicationInfoFlowTest
|
|||
.setRepoId("123-COM")
|
||||
.setFullyQualifiedDomainName("timber.com")
|
||||
.setDeletionTime(DateTime.now().minusDays(1))
|
||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
||||
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ public class DomainApplicationInfoFlowTest
|
|||
persistResource(new DomainApplication.Builder()
|
||||
.setRepoId("123-TLD")
|
||||
.setFullyQualifiedDomainName("invalid.tld")
|
||||
.setRegistrant(Ref.create(persistActiveContact("jd1234")))
|
||||
.setRegistrant(Key.create(persistActiveContact("jd1234")))
|
||||
.setPhase(LaunchPhase.SUNRUSH)
|
||||
.build());
|
||||
runFlow();
|
||||
|
|
|
@ -29,7 +29,7 @@ import static google.registry.testing.DomainApplicationSubject.assertAboutApplic
|
|||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
|
@ -104,9 +104,9 @@ public class DomainApplicationUpdateFlowTest
|
|||
private DomainApplication persistApplication() throws Exception {
|
||||
return persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newApplicationBuilder().setRegistrant(Ref.create(sh8013)).build());
|
||||
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
}
|
||||
|
@ -180,13 +180,13 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(newApplicationBuilder()
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setRegistrant(sh8013Key)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -369,10 +369,10 @@ public class DomainApplicationUpdateFlowTest
|
|||
}
|
||||
|
||||
private void modifyApplicationToHave13Nameservers() throws Exception {
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 1; i < 15; i++) {
|
||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||
nameservers.add(Ref.create(loadByUniqueId(
|
||||
nameservers.add(Key.create(loadByUniqueId(
|
||||
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
|
||||
// to add "mak21" as a second tech contact.
|
||||
persistResource(reloadResourceByUniqueId().asBuilder().setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(
|
||||
DesignatedContact.create(Type.TECH, Key.create(
|
||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc()))))).build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
setEppInput("domain_update_sunrise_add_remove_same_host.xml");
|
||||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -590,7 +590,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -603,8 +603,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -616,8 +616,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistReferencedEntities();
|
||||
persistResource(newApplicationBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
: null;
|
||||
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
|
||||
assertAboutDomains().that(domain)
|
||||
.hasRegistrationExpirationTime(domain.getAutorenewBillingEvent().get().getEventTime()).and()
|
||||
.hasRegistrationExpirationTime(
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()).and()
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
|
||||
.hasPeriodYears(2);
|
||||
|
|
|
@ -42,7 +42,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
|
@ -111,8 +110,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
PollMessage.Autorenew autorenewPollMessage = persistResource(
|
||||
createAutorenewPollMessage("TheRegistrar").build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -122,7 +121,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
ContactResource contact = persistActiveContact("sh8013");
|
||||
domain = newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setCreationTimeForTest(TIME_BEFORE_FLOW)
|
||||
.setRegistrant(Ref.create(contact))
|
||||
.setRegistrant(Key.create(contact))
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.build();
|
||||
earlierHistoryEntry = persistResource(
|
||||
|
@ -153,9 +152,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
A_MONTH_AGO.plusDays(45),
|
||||
"TheRegistrar",
|
||||
Ref.create(autorenewBillingEvent))))
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
Key.create(autorenewBillingEvent))))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
.setClientId("TheRegistrar")
|
||||
.setEventTime(eventTime)
|
||||
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
|
||||
.setOneTimeEventRef(Ref.create(graceBillingEvent))
|
||||
.setOneTimeEventKey(Key.create(graceBillingEvent))
|
||||
.setParent(historyEntryDomainDelete)
|
||||
.build());
|
||||
}
|
||||
|
@ -238,7 +237,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
throws Exception {
|
||||
doImmediateDeleteTest(gracePeriodStatus, responseFilename, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
||||
|
||||
private void doImmediateDeleteTest(
|
||||
GracePeriodStatus gracePeriodStatus,
|
||||
String responseFilename,
|
||||
|
@ -296,7 +295,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
private void doSuccessfulTest_noAddGracePeriod(String responseFilename) throws Exception {
|
||||
doSuccessfulTest_noAddGracePeriod(responseFilename, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
||||
|
||||
private void doSuccessfulTest_noAddGracePeriod(
|
||||
String responseFilename, Map<String, String> substitutions) throws Exception {
|
||||
// Persist the billing event so it can be retrieved for cancellation generation and checking.
|
||||
|
@ -373,7 +372,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
// Modify the autorenew poll message so that it has unacked messages in the past. This should
|
||||
// prevent it from being deleted when the domain is deleted.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
||||
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -531,9 +530,10 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
assertThat(domain.getTransferData().getServerApproveBillingEvent()).isNull();
|
||||
assertThat(domain.getTransferData().getServerApproveAutorenewEvent()).isNull();
|
||||
assertThat(domain.getTransferData().getServerApproveAutorenewPollMessage()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveBillingEvent().get()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveAutorenewEvent().get()).isNull();
|
||||
assertThat(oldTransferData.getServerApproveAutorenewPollMessage().get()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveBillingEvent()).now()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewEvent()).now()).isNull();
|
||||
assertThat(ofy().load().key(oldTransferData.getServerApproveAutorenewPollMessage()).now())
|
||||
.isNull();
|
||||
assertThat(oldTransferData.getServerApproveEntities()).isNotEmpty(); // Just a sanity check.
|
||||
assertThat(ofy().load()
|
||||
.keys(oldTransferData.getServerApproveEntities().toArray(new Key<?>[]{})))
|
||||
|
@ -554,12 +554,12 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
persistResource(loadByUniqueId(
|
||||
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
// Persist another domain that's already been deleted and references this contact and host.
|
||||
persistResource(newDomainResource("example1.tld").asBuilder()
|
||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -575,7 +575,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
setupSuccessfulTest();
|
||||
persistResource(
|
||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
||||
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||
.setDeletionTime(clock.nowUtc().minusDays(1))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -607,7 +607,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
DomainResource domain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
HostResource subordinateHost = persistResource(
|
||||
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
|
||||
.setSuperordinateDomain(Ref.create(reloadResourceByUniqueId()))
|
||||
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
|
||||
.build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||
|
|
|
@ -27,7 +27,6 @@ import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.flows.ResourceQueryFlow.ResourceToQueryDoesNotExistException;
|
||||
|
@ -91,25 +90,25 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
|
||||
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
|
||||
.setRegistrant(Ref.create(registrant))
|
||||
.setRegistrant(Key.create(registrant))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(contact))))
|
||||
.setNameservers(inactive ? null : ImmutableSet.of(Ref.create(host1), Ref.create(host2)))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(contact))))
|
||||
.setNameservers(inactive ? null : ImmutableSet.of(Key.create(host1), Key.create(host2)))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
|
||||
.build());
|
||||
// Set the superordinate domain of ns1.example.com to example.com. In reality, this would have
|
||||
// happened in the flow that created it, but here we just overwrite it in the datastore.
|
||||
host1 = persistResource(
|
||||
host1.asBuilder().setSuperordinateDomain(Ref.create(domain)).build());
|
||||
host1.asBuilder().setSuperordinateDomain(Key.create(domain)).build());
|
||||
// Create a subordinate host that is not delegated to by anyone.
|
||||
host3 = persistResource(
|
||||
new HostResource.Builder()
|
||||
.setFullyQualifiedHostName("ns2.example.tld")
|
||||
.setRepoId("3FF-TLD")
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
// Add the subordinate host references to the existing domain.
|
||||
// Add the subordinate host keys to the existing domain.
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setSubordinateHosts(ImmutableSet.of(
|
||||
host1.getFullyQualifiedHostName(),
|
||||
|
@ -242,7 +241,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
persistResource(domain.asBuilder()
|
||||
.setDsData(ImmutableSet.of(DelegationSignerData.create(
|
||||
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC"))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host1), Ref.create(host3)))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host1), Key.create(host3)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_dsdata.xml", false);
|
||||
}
|
||||
|
@ -283,7 +282,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
clock.nowUtc().plusDays(1),
|
||||
"foo",
|
||||
Ref.create(Key.create(Recurring.class, 12345))))
|
||||
Key.create(Recurring.class, 12345)))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -32,7 +33,7 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
||||
|
@ -116,8 +117,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
domain = persistResource(domain.asBuilder()
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
@ -136,7 +137,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
DomainResource domain = reloadResourceByUniqueId();
|
||||
HistoryEntry historyEntryDomainRenew =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime()).isEqualTo(newExpiration);
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(newExpiration);
|
||||
assertAboutDomains().that(domain)
|
||||
.isActiveAt(clock.nowUtc()).and()
|
||||
.hasRegistrationExpirationTime(newExpiration).and()
|
||||
|
@ -345,7 +347,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
|
|||
persistDomain();
|
||||
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().getAutorenewPollMessage().get().asBuilder()
|
||||
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
|
||||
.setEventTime(expirationTime.minusYears(1))
|
||||
.build());
|
||||
runFlowAssertResponse(readFile("domain_renew_response.xml"));
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -126,7 +127,7 @@ public class DomainRestoreRequestFlowTest extends
|
|||
DomainResource domain = reloadResourceByUniqueId();
|
||||
HistoryEntry historyEntryDomainRestore =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(clock.nowUtc().plusYears(1));
|
||||
assertAboutDomains().that(domain)
|
||||
// New expiration time should be exactly a year from now.
|
||||
|
@ -386,7 +387,7 @@ public class DomainRestoreRequestFlowTest extends
|
|||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
runFlow();
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.flows.domain;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEventsForResource;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
|
@ -148,7 +149,7 @@ public class DomainTransferApproveFlowTest
|
|||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE);
|
||||
assertTransferApproved(domain);
|
||||
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
|
||||
assertThat(domain.getAutorenewBillingEvent().get().getEventTime())
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
assertTransferApproved(reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()));
|
||||
// We expect three billing events: one for the transfer, a closed autorenew for the losing
|
||||
|
@ -372,7 +373,7 @@ public class DomainTransferApproveFlowTest
|
|||
.setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer.
|
||||
.setBillingTime(
|
||||
oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
.setRecurringEventRef(domain.getAutorenewBillingEvent()));
|
||||
.setRecurringEventKey(domain.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -28,7 +28,7 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.Flow;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -120,14 +120,14 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(REGISTRATION_EXPIRATION_TIME)
|
||||
.setRegistrant(Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
|
||||
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
Type.ADMIN,
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
|
||||
.addGracePeriod(GracePeriod.create(
|
||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))
|
||||
|
@ -163,11 +163,11 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
|||
.setCurrentSponsorClientId("TheRegistrar")
|
||||
.setCreationClientId("TheRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
|
||||
.setSuperordinateDomain(Ref.create(domain))
|
||||
.setSuperordinateDomain(Key.create(domain))
|
||||
.build());
|
||||
domain = persistResource(domain.asBuilder()
|
||||
.setAutorenewBillingEvent(Ref.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Ref.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -192,7 +193,8 @@ public class DomainTransferRequestFlowTest
|
|||
.build())
|
||||
.toArray(BillingEvent.class));
|
||||
// The domain's autorenew billing event should still point to the losing client's event.
|
||||
BillingEvent.Recurring domainAutorenewEvent = domain.getAutorenewBillingEvent().get();
|
||||
BillingEvent.Recurring domainAutorenewEvent =
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now();
|
||||
assertThat(domainAutorenewEvent.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
|
||||
// The original grace periods should remain untouched.
|
||||
|
@ -263,8 +265,9 @@ public class DomainTransferRequestFlowTest
|
|||
|
||||
assertAboutDomains().that(domainAfterAutomaticTransfer)
|
||||
.hasRegistrationExpirationTime(expectedExpirationTime);
|
||||
assertThat(domainAfterAutomaticTransfer.getAutorenewBillingEvent().get().getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
assertThat(ofy().load().key(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).now()
|
||||
.getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
// And after the expected grace time, the grace period should be gone.
|
||||
DomainResource afterGracePeriod = domain.cloneProjectedAtTime(
|
||||
clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plus(
|
||||
|
@ -315,7 +318,7 @@ public class DomainTransferRequestFlowTest
|
|||
assertTransactionalFlow(true);
|
||||
runFlow(CommitMode.LIVE, userPrivileges);
|
||||
}
|
||||
|
||||
|
||||
private void runTest(String commandFilename, UserPrivileges userPrivileges) throws Exception {
|
||||
runTest(commandFilename, userPrivileges, ImmutableMap.<String, String>of());
|
||||
}
|
||||
|
@ -516,7 +519,7 @@ public class DomainTransferRequestFlowTest
|
|||
.setBillingTime(oldResource.getRegistrationExpirationTime().plus(
|
||||
Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
// The cancellation should refer to the old autorenew billing event.
|
||||
.setRecurringEventRef(oldResource.getAutorenewBillingEvent()));
|
||||
.setRecurringEventKey(oldResource.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,6 +18,7 @@ import static com.google.common.collect.Sets.union;
|
|||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -39,7 +40,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
|
@ -123,9 +123,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
DomainResource domain = persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Ref.create(host)))
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
historyEntryDomainCreate = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
|
@ -180,7 +180,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
HistoryEntry historyEntryDomainUpdate =
|
||||
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
||||
assertThat(resource.getNameservers()).containsExactly(
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
|
@ -201,7 +201,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setClientId("TheRegistrar")
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(sunrushAddBillingEvent.getBillingTime())
|
||||
.setOneTimeEventRef(Ref.create(sunrushAddBillingEvent))
|
||||
.setOneTimeEventKey(Key.create(sunrushAddBillingEvent))
|
||||
.setParent(historyEntryDomainUpdate)
|
||||
.build(),
|
||||
regularAddBillingEvent);
|
||||
|
@ -278,7 +278,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -302,7 +302,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
// serverHold on it.
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addGracePeriod(GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
|
@ -345,10 +345,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
private void modifyDomainToHave13Nameservers() throws Exception {
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 1; i < 15; i++) {
|
||||
if (i != 2) { // Skip 2 since that's the one that the tests will add.
|
||||
nameservers.add(Ref.create(loadByUniqueId(
|
||||
nameservers.add(Key.create(loadByUniqueId(
|
||||
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
|
||||
}
|
||||
}
|
||||
|
@ -374,11 +374,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistDomain();
|
||||
setEppInput("domain_update_max_everything.xml");
|
||||
// Create 26 hosts and 8 contacts. Start the domain with half of them.
|
||||
ImmutableSet.Builder<Ref<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
|
||||
for (int i = 0; i < 26; i++) {
|
||||
HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i));
|
||||
if (i < 13) {
|
||||
nameservers.add(Ref.create(host));
|
||||
nameservers.add(Key.create(host));
|
||||
}
|
||||
}
|
||||
ImmutableList.Builder<DesignatedContact> contactsBuilder = new ImmutableList.Builder<>();
|
||||
|
@ -386,14 +386,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
contactsBuilder.add(
|
||||
DesignatedContact.create(
|
||||
DesignatedContact.Type.values()[i % 4],
|
||||
Ref.create(persistActiveContact(String.format("max_test_%d", i)))));
|
||||
Key.create(persistActiveContact(String.format("max_test_%d", i)))));
|
||||
}
|
||||
ImmutableList<DesignatedContact> contacts = contactsBuilder.build();
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setNameservers(nameservers.build())
|
||||
.setContacts(ImmutableSet.copyOf(contacts.subList(0, 3)))
|
||||
.setRegistrant(contacts.get(3).getContactRef())
|
||||
.setRegistrant(contacts.get(3).getContactKey())
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
|
@ -406,7 +406,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
assertThat(domain.getNameservers()).hasSize(13);
|
||||
// getContacts does not return contacts of type REGISTRANT, so check these separately.
|
||||
assertThat(domain.getContacts()).hasSize(3);
|
||||
assertThat(domain.getRegistrant().get().getContactId()).isEqualTo("max_test_7");
|
||||
assertThat(ofy().load().key(domain.getRegistrant()).now().getContactId())
|
||||
.isEqualTo("max_test_7");
|
||||
assertNoBillingEvents();
|
||||
assertDnsTasksEnqueued("example.tld");
|
||||
}
|
||||
|
@ -458,19 +459,19 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
domain = persistResource(domain.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("ns2.example.tld")
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
domain = reloadResourceByUniqueId();
|
||||
assertThat(domain.getNameservers()).containsExactly(Ref.create(addedHost));
|
||||
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
|
||||
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
||||
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Ref.create(Key.create(domain)));
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -480,7 +481,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(Ref.create(sh8013))
|
||||
.setRegistrant(Key.create(sh8013))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -491,14 +492,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
Ref<ContactResource> sh8013Ref = Ref.create(sh8013);
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setRegistrant(sh8013Ref)
|
||||
.setRegistrant(sh8013Key)
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Ref),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Ref),
|
||||
DesignatedContact.create(Type.TECH, sh8013Ref)))
|
||||
DesignatedContact.create(Type.ADMIN, sh8013Key),
|
||||
DesignatedContact.create(Type.BILLING, sh8013Key),
|
||||
DesignatedContact.create(Type.TECH, sh8013Key)))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(readFile("domain_update_response.xml"));
|
||||
|
@ -890,7 +891,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Ref.create(
|
||||
DesignatedContact.create(Type.TECH, Key.create(
|
||||
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -986,7 +987,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Ref.create(
|
||||
.setNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1001,7 +1002,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Ref.create(
|
||||
Key.create(
|
||||
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
.build());
|
||||
runFlow();
|
||||
|
@ -1015,8 +1016,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1029,8 +1030,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand()).asBuilder()
|
||||
.setContacts(ImmutableSet.of(
|
||||
DesignatedContact.create(Type.ADMIN, Ref.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Ref.create(sh8013Contact))))
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
|
||||
.build());
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1109,10 +1110,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||
.build());
|
||||
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
||||
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
runFlow();
|
||||
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
||||
Ref.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1127,7 +1128,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
|
||||
.build());
|
||||
runFlow();
|
||||
assertThat(reloadResourceByUniqueId().getRegistrant().get().getContactId()).isEqualTo("sh8013");
|
||||
assertThat(ofy().load().key(reloadResourceByUniqueId().getRegistrant()).now().getContactId())
|
||||
.isEqualTo("sh8013");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1149,7 +1151,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistDomain();
|
||||
persistResource(
|
||||
reloadResourceByUniqueId().asBuilder()
|
||||
.addNameservers(ImmutableSet.of(Ref.create(
|
||||
.addNameservers(ImmutableSet.of(Key.create(
|
||||
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.build());
|
||||
persistResource(
|
||||
|
@ -1158,11 +1160,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
|
||||
.build());
|
||||
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
|
||||
Ref.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
|
||||
Ref.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue