mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Make all but one field on RegistryConfig static
The next step will be to get rid of RegistryConfig descendants and RegistryConfigLoader entirely. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143812815
This commit is contained in:
parent
7fba7c1e4f
commit
c5c74961bb
23 changed files with 224 additions and 324 deletions
|
@ -32,6 +32,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.MediaType;
|
||||
import google.registry.config.ConfigModule.LocalTestConfig;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.request.Response;
|
||||
|
@ -64,6 +65,7 @@ public class ExportReservedTermsActionTest {
|
|||
ExportReservedTermsAction action = new ExportReservedTermsAction();
|
||||
action.response = response;
|
||||
action.driveConnection = driveConnection;
|
||||
action.exportUtils = new ExportUtils(LocalTestConfig.RESERVED_TERMS_TEST_EXPORT_DISCLAIMER);
|
||||
action.tld = tld;
|
||||
action.run();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.export;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.config.ConfigModule.LocalTestConfig.RESERVED_TERMS_TEST_EXPORT_DISCLAIMER;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -56,7 +57,9 @@ public class ExportUtilsTest {
|
|||
createTld("tld");
|
||||
persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build());
|
||||
// Should not contain jimmy, tine, or oval.
|
||||
assertThat(ExportUtils.exportReservedTerms(Registry.get("tld")))
|
||||
assertThat(
|
||||
new ExportUtils(RESERVED_TERMS_TEST_EXPORT_DISCLAIMER)
|
||||
.exportReservedTerms(Registry.get("tld")))
|
||||
.isEqualTo("This is a disclaimer.\ncat\nlol\nsnow\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ package google.registry.export.sheet;
|
|||
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.config.RegistryConfig.getRegistrarDefaultReferralUrl;
|
||||
import static google.registry.config.RegistryConfig.getRegistrarDefaultWhoisServer;
|
||||
import static google.registry.model.common.Cursor.CursorType.SYNC_REGISTRAR_SHEET;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -263,10 +265,8 @@ public class SyncRegistrarsSheetTest {
|
|||
assertThat(row).containsEntry("ipAddressWhitelist", "");
|
||||
assertThat(row).containsEntry("url", "http://www.example.org/aaa_registrar");
|
||||
assertThat(row).containsEntry("icannReferralEmail", "");
|
||||
assertThat(row).containsEntry("whoisServer",
|
||||
ENVIRONMENT.config().getRegistrarDefaultWhoisServer());
|
||||
assertThat(row).containsEntry("referralUrl",
|
||||
ENVIRONMENT.config().getRegistrarDefaultReferralUrl().toString());
|
||||
assertThat(row).containsEntry("whoisServer", getRegistrarDefaultWhoisServer());
|
||||
assertThat(row).containsEntry("referralUrl", getRegistrarDefaultReferralUrl().toString());
|
||||
|
||||
row = rows.get(1);
|
||||
assertThat(row).containsEntry("clientIdentifier", "anotherregistrar");
|
||||
|
@ -298,8 +298,7 @@ public class SyncRegistrarsSheetTest {
|
|||
assertThat(row).containsEntry("blockPremiumNames", "false");
|
||||
assertThat(row).containsEntry("ipAddressWhitelist", "");
|
||||
assertThat(row).containsEntry("url", "http://www.example.org/another_registrar");
|
||||
assertThat(row).containsEntry("referralUrl",
|
||||
ENVIRONMENT.config().getRegistrarDefaultReferralUrl().toString());
|
||||
assertThat(row).containsEntry("referralUrl", getRegistrarDefaultReferralUrl().toString());
|
||||
assertThat(row).containsEntry("icannReferralEmail", "jim@example.net");
|
||||
|
||||
Cursor cursor = ofy().load().key(Cursor.createGlobalKey(SYNC_REGISTRAR_SHEET)).now();
|
||||
|
@ -342,8 +341,7 @@ public class SyncRegistrarsSheetTest {
|
|||
assertThat(row).containsEntry("phoneNumber", "");
|
||||
assertThat(row).containsEntry("faxNumber", "");
|
||||
assertThat(row).containsEntry("allowedTlds", "");
|
||||
assertThat(row).containsEntry("whoisServer",
|
||||
ENVIRONMENT.config().getRegistrarDefaultWhoisServer());
|
||||
assertThat(row).containsEntry("whoisServer", getRegistrarDefaultWhoisServer());
|
||||
assertThat(row).containsEntry("blockPremiumNames", "false");
|
||||
assertThat(row).containsEntry("ipAddressWhitelist", "");
|
||||
assertThat(row).containsEntry("url", "");
|
||||
|
|
|
@ -21,7 +21,6 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
|
|||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -60,7 +59,7 @@ public class CheckApiActionTest {
|
|||
private Map<String, Object> getCheckResponse(String domain) {
|
||||
action.domain = domain;
|
||||
action.response = new FakeResponse();
|
||||
action.config = RegistryEnvironment.UNITTEST.config();
|
||||
action.checkApiServletRegistrarClientId = "TheRegistrar";
|
||||
action.eppController = DaggerEppTestComponent.builder()
|
||||
.fakesAndMocksModule(new FakesAndMocksModule())
|
||||
.build()
|
||||
|
|
|
@ -22,7 +22,7 @@ import static google.registry.testing.DatastoreHelper.getPollMessages;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.config.ConfigModule.LocalTestConfig;
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||
import google.registry.flows.exceptions.AlreadyPendingTransferException;
|
||||
|
@ -57,8 +57,7 @@ public class ContactTransferRequestFlowTest
|
|||
private void doSuccessfulTest(String commandFilename, String expectedXmlFilename)
|
||||
throws Exception {
|
||||
setEppInput(commandFilename);
|
||||
DateTime afterTransfer =
|
||||
clock.nowUtc().plus(RegistryEnvironment.get().config().getContactAutomaticTransferLength());
|
||||
DateTime afterTransfer = clock.nowUtc().plus(LocalTestConfig.CONTACT_AUTOMATIC_TRANSFER_LENGTH);
|
||||
|
||||
// Setup done; run the test.
|
||||
assertTransactionalFlow(true);
|
||||
|
|
|
@ -17,11 +17,11 @@ package google.registry.mapreduce.inputs;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static google.registry.mapreduce.inputs.EppResourceInputs.createChildEntityInput;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.index.EppResourceIndexBucket.getBucketKey;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistEppResourceInFirstBucket;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
|
@ -30,7 +30,6 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.TestRegistryConfig;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
|
@ -41,7 +40,6 @@ import google.registry.model.index.EppResourceIndex;
|
|||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.RegistryConfigRule;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
@ -69,9 +67,6 @@ public class ChildEntityInputTest {
|
|||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
@Rule
|
||||
public final RegistryConfigRule configRule = new RegistryConfigRule();
|
||||
|
||||
DomainResource domainA;
|
||||
DomainResource domainB;
|
||||
HistoryEntry domainHistoryEntryA;
|
||||
|
@ -82,19 +77,10 @@ public class ChildEntityInputTest {
|
|||
BillingEvent.Recurring recurringA;
|
||||
BillingEvent.Recurring recurringB;
|
||||
|
||||
private void overrideBucketCount(final int count) {
|
||||
configRule.override(new TestRegistryConfig() {
|
||||
@Override
|
||||
public int getEppResourceIndexBucketCount() {
|
||||
return count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupResources() {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
domainA = persistActiveDomain("a.tld");
|
||||
ContactResource contact = persistEppResourceInFirstBucket(newContactResource("contact1234"));
|
||||
domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld", contact));
|
||||
domainHistoryEntryA = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setParent(domainA)
|
||||
|
@ -102,7 +88,7 @@ public class ChildEntityInputTest {
|
|||
.build());
|
||||
contactHistoryEntry = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setParent(loadByForeignKey(ContactResource.class, "contact1234", now))
|
||||
.setParent(contact)
|
||||
.setModificationTime(now)
|
||||
.build());
|
||||
oneTimeA = persistResource(
|
||||
|
@ -129,7 +115,7 @@ public class ChildEntityInputTest {
|
|||
}
|
||||
|
||||
private void setupSecondDomainResources() {
|
||||
domainB = persistActiveDomain("b.tld");
|
||||
domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld"));
|
||||
domainHistoryEntryB = persistResource(
|
||||
new HistoryEntry.Builder()
|
||||
.setParent(domainB)
|
||||
|
@ -211,110 +197,81 @@ public class ChildEntityInputTest {
|
|||
@Test
|
||||
public void testSuccess_childEntityReader_multipleChildTypes() throws Exception {
|
||||
setupResources();
|
||||
Set<ImmutableObject> seen = new HashSet<>();
|
||||
|
||||
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
|
||||
.createReaders().get(0);
|
||||
assertThat(getAllFromReader(reader)).containsExactly(
|
||||
domainHistoryEntryA, contactHistoryEntry, oneTimeA, recurringA);
|
||||
}
|
||||
|
||||
private static Set<ImmutableObject> getAllFromReader(InputReader<ImmutableObject> reader)
|
||||
throws Exception {
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
seen.add(reader.next());
|
||||
seen.add(reader.next());
|
||||
seen.add(reader.next());
|
||||
seen.add(reader.next());
|
||||
assertThat(seen).containsExactly(
|
||||
domainHistoryEntryA, contactHistoryEntry, oneTimeA, recurringA);
|
||||
thrown.expect(NoSuchElementException.class);
|
||||
reader.next();
|
||||
ImmutableSet.Builder<ImmutableObject> seen = new ImmutableSet.Builder<>();
|
||||
try {
|
||||
while (true) {
|
||||
seen.add(reader.next());
|
||||
}
|
||||
} catch (NoSuchElementException e) {
|
||||
// Swallow; this is expected.
|
||||
}
|
||||
return seen.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_filterParentTypes() throws Exception {
|
||||
setupResources();
|
||||
Set<ImmutableObject> seen = new HashSet<>();
|
||||
|
||||
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(ContactResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||
HistoryEntry.class, BillingEvent.OneTime.class, BillingEvent.Recurring.class))
|
||||
.createReaders().get(0);
|
||||
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
seen.add(reader.next());
|
||||
assertThat(seen).containsExactly(contactHistoryEntry);
|
||||
thrown.expect(NoSuchElementException.class);
|
||||
reader.next();
|
||||
assertThat(getAllFromReader(reader)).containsExactly(contactHistoryEntry);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_polymorphicChildFiltering() throws Exception {
|
||||
setupResources();
|
||||
Set<ImmutableObject> seen = new HashSet<>();
|
||||
|
||||
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(BillingEvent.OneTime.class))
|
||||
.createReaders().get(0);
|
||||
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
seen.add(reader.next());
|
||||
assertThat(seen).containsExactly(oneTimeA);
|
||||
thrown.expect(NoSuchElementException.class);
|
||||
reader.next();
|
||||
assertThat(getAllFromReader(reader)).containsExactly(oneTimeA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_polymorphicChildClass() throws Exception {
|
||||
setupResources();
|
||||
Set<ImmutableObject> seen = new HashSet<>();
|
||||
|
||||
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(EppResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(BillingEvent.class))
|
||||
.createReaders().get(0);
|
||||
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
seen.add(reader.next());
|
||||
seen.add(reader.next());
|
||||
assertThat(seen).containsExactly(oneTimeA, recurringA);
|
||||
thrown.expect(NoSuchElementException.class);
|
||||
reader.next();
|
||||
assertThat(getAllFromReader(reader)).containsExactly(oneTimeA, recurringA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_noneReturned() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
|
||||
InputReader<ImmutableObject> reader = EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(ContactResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||
BillingEvent.OneTime.class)).createReaders().get(0);
|
||||
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
thrown.expect(NoSuchElementException.class);
|
||||
reader.next();
|
||||
assertThat(getAllFromReader(reader)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_readerCountMatchesBucketCount() throws Exception {
|
||||
overrideBucketCount(123);
|
||||
assertThat(EppResourceInputs.createChildEntityInput(
|
||||
ImmutableSet.<Class<? extends EppResource>>of(DomainResource.class),
|
||||
ImmutableSet.<Class<? extends ImmutableObject>>of(
|
||||
BillingEvent.OneTime.class)).createReaders()).hasSize(123);
|
||||
BillingEvent.OneTime.class)).createReaders()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_childEntityReader_oneReaderPerBucket() throws Exception {
|
||||
overrideBucketCount(3);
|
||||
createTld("tld");
|
||||
Set<ImmutableObject> historyEntries = new HashSet<>();
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
|
|
|
@ -20,18 +20,17 @@ import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInp
|
|||
import static google.registry.mapreduce.inputs.EppResourceInputs.createKeyInput;
|
||||
import static google.registry.model.index.EppResourceIndexBucket.getBucketKey;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.newContactResource;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.newDomainResource;
|
||||
import static google.registry.testing.DatastoreHelper.newHostResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistEppResourceInFirstBucket;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
|
||||
|
||||
import com.google.appengine.tools.mapreduce.InputReader;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.TestRegistryConfig;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
|
@ -41,7 +40,6 @@ import google.registry.model.host.HostResource;
|
|||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.RegistryConfigRule;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
@ -66,18 +64,6 @@ public class EppResourceInputsTest {
|
|||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
@Rule
|
||||
public final RegistryConfigRule configRule = new RegistryConfigRule();
|
||||
|
||||
private void overrideBucketCount(final int count) {
|
||||
configRule.override(new TestRegistryConfig() {
|
||||
@Override
|
||||
public int getEppResourceIndexBucketCount() {
|
||||
return count;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T serializeAndDeserialize(T obj) throws Exception {
|
||||
try (ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
|
@ -128,14 +114,12 @@ public class EppResourceInputsTest {
|
|||
|
||||
@Test
|
||||
public void testReaderCountMatchesBucketCount() throws Exception {
|
||||
overrideBucketCount(123);
|
||||
assertThat(createKeyInput(DomainBase.class).createReaders()).hasSize(123);
|
||||
assertThat(createEntityInput(DomainBase.class).createReaders()).hasSize(123);
|
||||
assertThat(createKeyInput(DomainBase.class).createReaders()).hasSize(3);
|
||||
assertThat(createEntityInput(DomainBase.class).createReaders()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyInput_oneReaderPerBucket() throws Exception {
|
||||
overrideBucketCount(3);
|
||||
createTld("tld");
|
||||
Set<Key<DomainResource>> domains = new HashSet<>();
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
|
@ -159,7 +143,6 @@ public class EppResourceInputsTest {
|
|||
|
||||
@Test
|
||||
public void testEntityInput_oneReaderPerBucket() throws Exception {
|
||||
overrideBucketCount(3);
|
||||
createTld("tld");
|
||||
Set<DomainResource> domains = new HashSet<>();
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
|
@ -186,9 +169,8 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_keyReader_survivesAcrossSerialization() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
DomainResource domainA = persistActiveDomain("a.tld");
|
||||
DomainResource domainB = persistActiveDomain("b.tld");
|
||||
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
|
||||
DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld"));
|
||||
// Should be ignored. We'll know if it isn't because the progress counts will be off.
|
||||
persistActiveContact("contact");
|
||||
Set<Key<DomainBase>> seen = new HashSet<>();
|
||||
|
@ -212,9 +194,8 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_entityReader_survivesAcrossSerialization() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
DomainResource domainA = persistActiveDomain("a.tld");
|
||||
DomainResource domainB = persistActiveDomain("b.tld");
|
||||
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
|
||||
DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld"));
|
||||
// Should be ignored. We'll know if it isn't because the progress counts will be off.
|
||||
persistActiveContact("contact");
|
||||
Set<DomainResource> seen = new HashSet<>();
|
||||
|
@ -241,12 +222,10 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_entityReader_allowsPolymorphicMatches() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
DomainResource domain = persistActiveDomain("a.tld");
|
||||
DomainApplication application = persistActiveDomainApplication("b.tld");
|
||||
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
|
||||
DomainApplication application = persistEppResourceInFirstBucket(newDomainApplication("b.tld"));
|
||||
Set<DomainBase> seen = new HashSet<>();
|
||||
InputReader<DomainBase> reader =
|
||||
createEntityInput(DomainBase.class).createReaders().get(0);
|
||||
InputReader<DomainBase> reader = createEntityInput(DomainBase.class).createReaders().get(0);
|
||||
reader.beginShard();
|
||||
reader.beginSlice();
|
||||
assertThat(reader.getProgress()).isWithin(EPSILON).of(0);
|
||||
|
@ -262,9 +241,8 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_entityReader_skipsPolymorphicMismatches() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
persistActiveDomainApplication("b.tld");
|
||||
DomainResource domainA = persistActiveDomain("a.tld");
|
||||
persistEppResourceInFirstBucket(newDomainApplication("b.tld"));
|
||||
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
|
||||
InputReader<DomainResource> reader =
|
||||
createEntityInput(DomainResource.class).createReaders().get(0);
|
||||
reader.beginShard();
|
||||
|
@ -281,10 +259,9 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_entityReader_filtersOnMultipleTypes() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
DomainResource domain = persistActiveDomain("a.tld");
|
||||
HostResource host = persistActiveHost("ns1.example.com");
|
||||
persistActiveContact("contact");
|
||||
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
|
||||
HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com"));
|
||||
persistEppResourceInFirstBucket(newContactResource("contact"));
|
||||
Set<EppResource> seen = new HashSet<>();
|
||||
InputReader<EppResource> reader =
|
||||
EppResourceInputs.<EppResource>createEntityInput(
|
||||
|
@ -304,12 +281,12 @@ public class EppResourceInputsTest {
|
|||
@Test
|
||||
public void testSuccess_entityReader_noFilteringWhenUsingEppResource() throws Exception {
|
||||
createTld("tld");
|
||||
overrideBucketCount(1);
|
||||
ContactResource contact = persistActiveContact("contact");
|
||||
ContactResource contact = persistEppResourceInFirstBucket(newContactResource("contact"));
|
||||
// Specify the contact since persistActiveDomain{Application} creates a hidden one.
|
||||
DomainResource domain = persistResource(newDomainResource("a.tld", contact));
|
||||
DomainApplication application = persistResource(newDomainApplication("b.tld", contact));
|
||||
HostResource host = persistActiveHost("ns1.example.com");
|
||||
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld", contact));
|
||||
DomainApplication application =
|
||||
persistEppResourceInFirstBucket(newDomainApplication("b.tld", contact));
|
||||
HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com"));
|
||||
Set<EppResource> seen = new HashSet<>();
|
||||
InputReader<EppResource> reader = createEntityInput(EppResource.class).createReaders().get(0);
|
||||
reader.beginShard();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.index;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
|
@ -23,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import org.junit.Before;
|
||||
|
@ -62,10 +62,9 @@ public class EppResourceIndexTest extends EntityTestCase {
|
|||
/**
|
||||
* Returns all EppResourceIndex objects across all buckets.
|
||||
*/
|
||||
private ImmutableList<EppResourceIndex> getEppResourceIndexObjects() {
|
||||
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
||||
private static ImmutableList<EppResourceIndex> getEppResourceIndexObjects() {
|
||||
ImmutableList.Builder<EppResourceIndex> indexEntities = new ImmutableList.Builder<>();
|
||||
for (int i = 0; i < numBuckets; i++) {
|
||||
for (int i = 0; i < getEppResourceIndexBucketCount(); i++) {
|
||||
indexEntities.addAll(ofy().load()
|
||||
.type(EppResourceIndex.class)
|
||||
.ancestor(Key.create(EppResourceIndexBucket.class, i + 1)));
|
||||
|
|
|
@ -42,8 +42,6 @@ import com.google.appengine.tools.cloudstorage.GcsServiceFactory;
|
|||
import com.google.common.base.Ascii;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.ByteSource;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.gcs.GcsUtils;
|
||||
import google.registry.model.common.Cursor;
|
||||
import google.registry.model.common.Cursor.CursorType;
|
||||
|
@ -97,13 +95,11 @@ public class RdeReportActionTest {
|
|||
private final HTTPResponse httpResponse = mock(HTTPResponse.class);
|
||||
|
||||
private final GcsService gcsService = GcsServiceFactory.createGcsService();
|
||||
private final RegistryConfig config = RegistryEnvironment.get().config();
|
||||
private final GcsFilename reportFile =
|
||||
new GcsFilename("tub", "test_2006-06-06_full_S1_R0-report.xml.ghostryde");
|
||||
|
||||
private RdeReportAction createAction() {
|
||||
RdeReporter reporter = new RdeReporter();
|
||||
reporter.config = config;
|
||||
reporter.reportUrlPrefix = "https://rde-report.example";
|
||||
reporter.urlFetchService = urlFetchService;
|
||||
reporter.password = "foo";
|
||||
|
|
|
@ -21,6 +21,7 @@ import static com.google.common.collect.Iterables.toArray;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.config.ConfigModule.LocalTestConfig.CONTACT_AND_HOST_ROID_SUFFIX;
|
||||
import static google.registry.config.ConfigModule.LocalTestConfig.CONTACT_AUTOMATIC_TRANSFER_LENGTH;
|
||||
import static google.registry.flows.ResourceFlowUtils.createTransferResponse;
|
||||
import static google.registry.model.EppResourceUtils.createDomainRepoId;
|
||||
import static google.registry.model.EppResourceUtils.createRepoId;
|
||||
|
@ -52,7 +53,6 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.VoidWork;
|
||||
import com.googlecode.objectify.Work;
|
||||
import com.googlecode.objectify.cmd.Saver;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.dns.writer.VoidDnsWriter;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.EppResource;
|
||||
|
@ -75,6 +75,7 @@ import google.registry.model.eppcommon.Trid;
|
|||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.index.EppResourceIndex;
|
||||
import google.registry.model.index.EppResourceIndexBucket;
|
||||
import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.ofy.ObjectifyService;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
|
@ -479,8 +480,7 @@ public class DatastoreHelper {
|
|||
.setCurrentSponsorClientId("TheRegistrar")
|
||||
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
||||
.setTransferData(createTransferDataBuilder(requestTime, expirationTime)
|
||||
.setPendingTransferExpirationTime(now.plus(
|
||||
RegistryEnvironment.get().config().getContactAutomaticTransferLength()))
|
||||
.setPendingTransferExpirationTime(now.plus(CONTACT_AUTOMATIC_TRANSFER_LENGTH))
|
||||
.setServerApproveEntities(
|
||||
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
|
||||
// Pretend it's 3 days since the request
|
||||
|
@ -770,22 +770,27 @@ public class DatastoreHelper {
|
|||
return persistResource(resource, true);
|
||||
}
|
||||
|
||||
private static <R> void saveResource(final R resource, final boolean wantBackup) {
|
||||
private static <R> void saveResource(R resource, boolean wantBackup) {
|
||||
Saver saver = wantBackup ? ofy().save() : ofy().saveWithoutBackup();
|
||||
saver.entity(resource);
|
||||
if (resource instanceof EppResource) {
|
||||
EppResource eppResource = (EppResource) resource;
|
||||
assertWithMessage("Cannot persist an EppResource with a missing repoId in tests")
|
||||
.that(eppResource.getRepoId()).isNotEmpty();
|
||||
Key<EppResource> eppResourceKey = Key.create(eppResource);
|
||||
saver.entity(EppResourceIndex.create(eppResourceKey));
|
||||
if (resource instanceof ForeignKeyedEppResource) {
|
||||
saver.entity(ForeignKeyIndex.create(eppResource, eppResource.getDeletionTime()));
|
||||
}
|
||||
if (resource instanceof DomainApplication) {
|
||||
saver.entity(
|
||||
DomainApplicationIndex.createUpdatedInstance((DomainApplication) resource));
|
||||
}
|
||||
persistEppResourceExtras(
|
||||
eppResource, EppResourceIndex.create(Key.create(eppResource)), saver);
|
||||
}
|
||||
}
|
||||
|
||||
private static <R extends EppResource> void persistEppResourceExtras(
|
||||
R resource, EppResourceIndex index, Saver saver) {
|
||||
assertWithMessage("Cannot persist an EppResource with a missing repoId in tests")
|
||||
.that(resource.getRepoId())
|
||||
.isNotEmpty();
|
||||
saver.entity(index);
|
||||
if (resource instanceof ForeignKeyedEppResource) {
|
||||
saver.entity(ForeignKeyIndex.create(resource, resource.getDeletionTime()));
|
||||
}
|
||||
if (resource instanceof DomainApplication) {
|
||||
saver.entity(DomainApplicationIndex.createUpdatedInstance((DomainApplication) resource));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -804,6 +809,21 @@ public class DatastoreHelper {
|
|||
return ofy().load().entity(resource).now();
|
||||
}
|
||||
|
||||
/** Persists an EPP resource with the {@link EppResourceIndex} always going into bucket one. */
|
||||
public static <R extends EppResource> R persistEppResourceInFirstBucket(final R resource) {
|
||||
final EppResourceIndex eppResourceIndex =
|
||||
EppResourceIndex.create(Key.create(EppResourceIndexBucket.class, 1), Key.create(resource));
|
||||
ofy().transact(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
Saver saver = ofy().save();
|
||||
saver.entity(resource);
|
||||
persistEppResourceExtras(resource, eppResourceIndex, saver);
|
||||
}});
|
||||
ofy().clearSessionCache();
|
||||
return ofy().load().entity(resource).now();
|
||||
}
|
||||
|
||||
public static <R> void persistResources(final Iterable<R> resources) {
|
||||
persistResources(resources, false);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.testing.mapreduce;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -33,7 +34,6 @@ import com.google.appengine.tools.pipeline.impl.servlets.TaskHandler;
|
|||
import com.google.apphosting.api.ApiProxy;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.mapreduce.MapreduceRunner;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -88,8 +88,8 @@ public abstract class MapreduceTestCase<T> extends ShardableTestCase {
|
|||
}
|
||||
|
||||
protected MapreduceRunner makeDefaultRunner() {
|
||||
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
||||
return new MapreduceRunner(Optional.<Integer>of(numBuckets), Optional.<Integer>of(1));
|
||||
return new MapreduceRunner(
|
||||
Optional.<Integer>of(getEppResourceIndexBucketCount()), Optional.<Integer>of(1));
|
||||
}
|
||||
|
||||
protected List<QueueStateInfo.TaskStateInfo> getTasks(String queueName) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.beust.jcommander.ParameterException;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import google.registry.config.TestRegistryConfig;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
|
@ -77,7 +77,7 @@ public class GenerateEscrowDepositCommandTest
|
|||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
command.encryptor = EncryptEscrowDepositCommandTest.createEncryptor();
|
||||
command.counter = new RdeCounter();
|
||||
command.eppResourceIndexBucketCount = new TestRegistryConfig().getEppResourceIndexBucketCount();
|
||||
command.eppResourceIndexBucketCount = RegistryConfig.getEppResourceIndexBucketCount();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.config.RegistryConfig.getRegistrarDefaultReferralUrl;
|
||||
import static google.registry.config.RegistryConfig.getRegistrarDefaultWhoisServer;
|
||||
import static google.registry.testing.CertificateSamples.SAMPLE_CERT;
|
||||
import static google.registry.testing.CertificateSamples.SAMPLE_CERT2;
|
||||
import static google.registry.testing.CertificateSamples.SAMPLE_CERT2_HASH;
|
||||
|
@ -23,7 +25,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
|
@ -48,11 +49,12 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
|
|||
"op", "update",
|
||||
"args", modified.toJsonMap()));
|
||||
// Empty whoisServer and referralUrl fields should be set to defaults by server.
|
||||
modified = modified.asBuilder()
|
||||
.setWhoisServer(RegistryEnvironment.get().config().getRegistrarDefaultWhoisServer())
|
||||
.setReferralUrl(
|
||||
RegistryEnvironment.get().config().getRegistrarDefaultReferralUrl().toString())
|
||||
.build();
|
||||
modified =
|
||||
modified
|
||||
.asBuilder()
|
||||
.setWhoisServer(getRegistrarDefaultWhoisServer())
|
||||
.setReferralUrl(getRegistrarDefaultReferralUrl().toString())
|
||||
.build();
|
||||
assertThat(response).containsEntry("status", "SUCCESS");
|
||||
assertThat(response).containsEntry("results", asList(modified.toJsonMap()));
|
||||
assertThat(Registrar.loadByClientId(CLIENT_ID)).isEqualTo(modified);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue