mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +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
|
@ -15,6 +15,7 @@
|
|||
package google.registry.config;
|
||||
|
||||
import static google.registry.config.ConfigUtils.makeUrl;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.google.appengine.api.utils.SystemProperty;
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -73,11 +74,6 @@ public final class ConfigModule {
|
|||
return REGISTRY_ENVIRONMENT;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public static RegistryConfig provideConfig(RegistryEnvironment environment) {
|
||||
return environment.config();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("projectId")
|
||||
public static String provideProjectId() {
|
||||
|
@ -356,8 +352,8 @@ public final class ConfigModule {
|
|||
*/
|
||||
@Provides
|
||||
@Config("eppResourceIndexBucketCount")
|
||||
public static int provideEppResourceIndexBucketCount(RegistryConfig config) {
|
||||
return config.getEppResourceIndexBucketCount();
|
||||
public static int provideEppResourceIndexBucketCount() {
|
||||
return RegistryConfig.getEppResourceIndexBucketCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -897,14 +893,15 @@ public final class ConfigModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* The time between a contact transfer request and its expiration date.
|
||||
* The global automatic transfer length for contacts. After this amount of time has
|
||||
* elapsed, the transfer is automatically approved.
|
||||
*
|
||||
* @see google.registry.flows.contact.ContactTransferRequestFlow
|
||||
*/
|
||||
@Provides
|
||||
@Config("contactAutomaticTransferLength")
|
||||
public static Duration provideContactAutomaticTransferLength(RegistryConfig config) {
|
||||
return config.getContactAutomaticTransferLength();
|
||||
public static Duration provideContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -960,6 +957,33 @@ public final class ConfigModule {
|
|||
return "google.registry.flows.custom.CustomLogicFactory";
|
||||
}
|
||||
|
||||
private static final String RESERVED_TERMS_EXPORT_DISCLAIMER = ""
|
||||
+ "# This list contains reserve terms for the TLD. Other terms may be reserved\n"
|
||||
+ "# but not included in this list, including terms EXAMPLE REGISTRY chooses not\n"
|
||||
+ "# to publish, and terms that ICANN commonly mandates to be reserved. This\n"
|
||||
+ "# list is subject to change and the most up-to-date source is always to\n"
|
||||
+ "# check availability directly with the Registry server.\n";
|
||||
|
||||
/**
|
||||
* Returns the header text at the top of the reserved terms exported list.
|
||||
*
|
||||
* @see google.registry.export.ExportUtils#exportReservedTerms
|
||||
*/
|
||||
@Provides
|
||||
@Config("reservedTermsExportDisclaimer")
|
||||
public static String provideReservedTermsExportDisclaimer() {
|
||||
return RESERVED_TERMS_EXPORT_DISCLAIMER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clientId of the registrar used by the {@code CheckApiServlet}.
|
||||
*/
|
||||
@Provides
|
||||
@Config("checkApiServletRegistrarClientId")
|
||||
public static String provideCheckApiServletRegistrarClientId() {
|
||||
return "TheRegistrar";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the help path for the RDAP terms of service.
|
||||
*
|
||||
|
@ -1050,8 +1074,12 @@ public final class ConfigModule {
|
|||
|
||||
public static final String CONTACT_AND_HOST_ROID_SUFFIX = "ROID";
|
||||
|
||||
public static final String RESERVED_TERMS_TEST_EXPORT_DISCLAIMER = "This is a disclaimer.\n";
|
||||
|
||||
public static final String GOOGLE_APPS_SEND_FROM_EMAIL_ADDRESS = "noreply@testing.example";
|
||||
|
||||
public static final String GOOGLE_APPS_ADMIN_EMAIL_DISPLAY_NAME = "Testing Nomulus";
|
||||
|
||||
public static final Duration CONTACT_AUTOMATIC_TRANSFER_LENGTH = standardDays(5);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,9 @@
|
|||
package google.registry.config;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.config.ConfigUtils.makeUrl;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import java.net.URL;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/**
|
||||
* Default production configuration for global constants that can't be injected.
|
||||
|
@ -34,15 +29,9 @@ import org.joda.time.Duration;
|
|||
@Immutable
|
||||
public final class ProductionRegistryConfigExample extends RegistryConfig {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final RegistryEnvironment environment;
|
||||
|
||||
private static final String RESERVED_TERMS_EXPORT_DISCLAIMER = ""
|
||||
+ "# This list contains reserve terms for the TLD. Other terms may be reserved\n"
|
||||
+ "# but not included in this list, including terms EXAMPLE REGISTRY chooses not\n"
|
||||
+ "# to publish, and terms that ICANN commonly mandates to be reserved. This\n"
|
||||
+ "# list is subject to change and the most up-to-date source is always to\n"
|
||||
+ "# check availability directly with the Registry server.\n";
|
||||
|
||||
public ProductionRegistryConfigExample(RegistryEnvironment environment) {
|
||||
this.environment = checkNotNull(environment);
|
||||
}
|
||||
|
@ -51,50 +40,4 @@ public final class ProductionRegistryConfigExample extends RegistryConfig {
|
|||
public Optional<String> getECatcherAddress() {
|
||||
throw new UnsupportedOperationException(); // n/a
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAndPort getServer() {
|
||||
switch (environment) {
|
||||
case LOCAL:
|
||||
return HostAndPort.fromParts("localhost", 8080);
|
||||
default:
|
||||
return HostAndPort.fromParts(
|
||||
String.format("tools-dot-%s.appspot.com", getProjectId()), 443);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReservedTermsExportDisclaimer() {
|
||||
return RESERVED_TERMS_EXPORT_DISCLAIMER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistrarDefaultWhoisServer() {
|
||||
return "whois.nic.registry.example";
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getRegistrarDefaultReferralUrl() {
|
||||
return makeUrl("https://www.registry.example");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEppResourceIndexBucketCount() {
|
||||
return 997;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getBaseOfyRetryDuration() {
|
||||
return Duration.millis(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckApiServletRegistrarClientId() {
|
||||
return "TheRegistrar";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
package google.registry.config;
|
||||
|
||||
import static google.registry.config.ConfigUtils.makeUrl;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
@ -109,7 +111,17 @@ public abstract class RegistryConfig {
|
|||
*
|
||||
* <p>This is used by the {@code nomulus} tool to connect to the App Engine remote API.
|
||||
*/
|
||||
public abstract HostAndPort getServer();
|
||||
public static HostAndPort getServer() {
|
||||
switch (RegistryEnvironment.get()) {
|
||||
case LOCAL:
|
||||
return HostAndPort.fromParts("localhost", 8080);
|
||||
case UNITTEST:
|
||||
throw new UnsupportedOperationException("Unit tests can't spin up a full server");
|
||||
default:
|
||||
return HostAndPort.fromParts(
|
||||
String.format("tools-dot-%s.appspot.com", getProjectId()), 443);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the amount of time a singleton should be cached, before expiring. */
|
||||
public static Duration getSingletonCacheRefreshDuration() {
|
||||
|
@ -148,46 +160,56 @@ public abstract class RegistryConfig {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the header text at the top of the reserved terms exported list.
|
||||
*
|
||||
* @see google.registry.export.ExportUtils#exportReservedTerms
|
||||
*/
|
||||
public abstract String getReservedTermsExportDisclaimer();
|
||||
|
||||
/**
|
||||
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
|
||||
*
|
||||
* @see "google.registry.whois.DomainWhoisResponse"
|
||||
* @see "google.registry.whois.RegistrarWhoisResponse"
|
||||
*/
|
||||
public abstract String getRegistrarDefaultWhoisServer();
|
||||
public static String getRegistrarDefaultWhoisServer() {
|
||||
switch (RegistryEnvironment.get()) {
|
||||
case UNITTEST:
|
||||
return "whois.nic.fakewhois.example";
|
||||
default:
|
||||
return "whois.nic.registry.example";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default referral URL that is used unless registrars have specified otherwise.
|
||||
*/
|
||||
public abstract URL getRegistrarDefaultReferralUrl();
|
||||
public static URL getRegistrarDefaultReferralUrl() {
|
||||
switch (RegistryEnvironment.get()) {
|
||||
case UNITTEST:
|
||||
return makeUrl("http://www.referral.example/path");
|
||||
default:
|
||||
return makeUrl("https://www.registry.example");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of EppResourceIndex buckets to be used.
|
||||
* Returns the number of {@code EppResourceIndex} buckets to be used.
|
||||
*/
|
||||
public abstract int getEppResourceIndexBucketCount();
|
||||
public static int getEppResourceIndexBucketCount() {
|
||||
switch (RegistryEnvironment.get()) {
|
||||
case UNITTEST:
|
||||
return 3;
|
||||
default:
|
||||
return 997;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base duration that gets doubled on each retry within {@code Ofy}.
|
||||
* Returns the base retry duration that gets doubled after each failure within {@code Ofy}.
|
||||
*/
|
||||
public abstract Duration getBaseOfyRetryDuration();
|
||||
|
||||
/**
|
||||
* Returns the global automatic transfer length for contacts. After this amount of time has
|
||||
* elapsed, the transfer is automatically approved.
|
||||
*/
|
||||
public abstract Duration getContactAutomaticTransferLength();
|
||||
|
||||
/**
|
||||
* Returns the clientId of the registrar used by the {@code CheckApiServlet}.
|
||||
*/
|
||||
public abstract String getCheckApiServletRegistrarClientId();
|
||||
public static Duration getBaseOfyRetryDuration() {
|
||||
switch (RegistryEnvironment.get()) {
|
||||
case UNITTEST:
|
||||
return Duration.ZERO;
|
||||
default:
|
||||
return Duration.millis(100);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: Please consider using ConfigModule instead of adding new methods to this file.
|
||||
}
|
||||
|
|
|
@ -14,13 +14,7 @@
|
|||
|
||||
package google.registry.config;
|
||||
|
||||
import static google.registry.config.ConfigUtils.makeUrl;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import java.net.URL;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/**
|
||||
* An implementation of RegistryConfig for unit testing that contains suitable testing data.
|
||||
|
@ -33,44 +27,4 @@ public class TestRegistryConfig extends RegistryConfig {
|
|||
public Optional<String> getECatcherAddress() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAndPort getServer() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReservedTermsExportDisclaimer() {
|
||||
return "This is a disclaimer.\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistrarDefaultWhoisServer() {
|
||||
return "whois.nic.fakewhois.example";
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getRegistrarDefaultReferralUrl() {
|
||||
return makeUrl("http://www.referral.example/path");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEppResourceIndexBucketCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getBaseOfyRetryDuration() {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckApiServletRegistrarClientId() {
|
||||
return "TheRegistrar";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.export;
|
|||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
|
||||
import static google.registry.export.ExportUtils.exportReservedTerms;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
|
@ -41,6 +40,7 @@ public class ExportReservedTermsAction implements Runnable {
|
|||
static final String RESERVED_TERMS_FILENAME = "reserved_terms.txt";
|
||||
|
||||
@Inject DriveConnection driveConnection;
|
||||
@Inject ExportUtils exportUtils;
|
||||
@Inject @Parameter(RequestParameters.PARAM_TLD) String tld;
|
||||
@Inject Response response;
|
||||
@Inject ExportReservedTermsAction() {}
|
||||
|
@ -70,7 +70,7 @@ public class ExportReservedTermsAction implements Runnable {
|
|||
RESERVED_TERMS_FILENAME,
|
||||
EXPORT_MIME_TYPE,
|
||||
registry.getDriveFolderId(),
|
||||
exportReservedTerms(registry).getBytes(UTF_8));
|
||||
exportUtils.exportReservedTerms(registry).getBytes(UTF_8));
|
||||
logger.infofmt("Exporting reserved terms succeeded for TLD %s, response was: %s",
|
||||
tld, resultMsg);
|
||||
}
|
||||
|
|
|
@ -18,22 +18,28 @@ import static google.registry.model.registry.label.ReservationType.UNRESERVED;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** Container class for exported-related static utility methods. */
|
||||
public class ExportUtils {
|
||||
/** Container class for exported-related utility methods. */
|
||||
public final class ExportUtils {
|
||||
|
||||
private ExportUtils() {}
|
||||
private final String reservedTermsExportDisclaimer;
|
||||
|
||||
@Inject
|
||||
public ExportUtils(
|
||||
@Config("reservedTermsExportDisclaimer") String reservedTermsExportDisclaimer) {
|
||||
this.reservedTermsExportDisclaimer = reservedTermsExportDisclaimer;
|
||||
}
|
||||
|
||||
/** Returns the file contents of the auto-export reserved terms document for the given TLD. */
|
||||
public static String exportReservedTerms(Registry registry) {
|
||||
StringBuilder termsBuilder =
|
||||
new StringBuilder(RegistryEnvironment.get().config().getReservedTermsExportDisclaimer());
|
||||
public String exportReservedTerms(Registry registry) {
|
||||
StringBuilder termsBuilder = new StringBuilder(reservedTermsExportDisclaimer);
|
||||
Set<String> reservedTerms = new TreeSet<>();
|
||||
for (Key<ReservedList> key : registry.getReservedLists()) {
|
||||
ReservedList reservedList = ReservedList.load(key).get();
|
||||
|
|
|
@ -35,7 +35,7 @@ import com.google.template.soy.SoyFileSet;
|
|||
import com.google.template.soy.tofu.SoyTofu;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.flows.soy.DomainCheckFeeEppSoyInfo;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtension;
|
||||
import google.registry.model.eppoutput.CheckData.DomainCheck;
|
||||
|
@ -69,7 +69,7 @@ public class CheckApiAction implements Runnable {
|
|||
@Inject @Parameter("domain") String domain;
|
||||
@Inject Response response;
|
||||
@Inject EppController eppController;
|
||||
@Inject RegistryConfig config;
|
||||
@Inject @Config("checkApiServletRegistrarClientId") String checkApiServletRegistrarClientId;
|
||||
@Inject CheckApiAction() {}
|
||||
|
||||
@Override
|
||||
|
@ -96,9 +96,8 @@ public class CheckApiAction implements Runnable {
|
|||
.setData(ImmutableMap.of("domainName", domainString))
|
||||
.render()
|
||||
.getBytes(UTF_8);
|
||||
SessionMetadata sessionMetadata = new StatelessRequestSessionMetadata(
|
||||
config.getCheckApiServletRegistrarClientId(),
|
||||
FEE_EXTENSION_URIS);
|
||||
SessionMetadata sessionMetadata =
|
||||
new StatelessRequestSessionMetadata(checkApiServletRegistrarClientId, FEE_EXTENSION_URIS);
|
||||
EppResponse response = eppController
|
||||
.handleEppCommand(
|
||||
sessionMetadata,
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
|
||||
package google.registry.model.index;
|
||||
|
||||
import static google.registry.config.RegistryConfig.getEppResourceIndexBucketCount;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.annotations.VirtualEntity;
|
||||
|
@ -38,7 +39,7 @@ public class EppResourceIndexBucket extends ImmutableObject {
|
|||
* change the number of buckets and utilize a random distribution once we do.
|
||||
*/
|
||||
private static long getBucketIdFromEppResource(Key<? extends EppResource> resourceKey) {
|
||||
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
||||
int numBuckets = getEppResourceIndexBucketCount();
|
||||
// IDs can't be 0, so add 1 to the hash.
|
||||
return Hashing.consistentHash(resourceKey.getName().hashCode(), numBuckets) + 1;
|
||||
}
|
||||
|
@ -56,8 +57,7 @@ public class EppResourceIndexBucket extends ImmutableObject {
|
|||
/** Returns the keys to all buckets. */
|
||||
public static Iterable<Key<EppResourceIndexBucket>> getAllBuckets() {
|
||||
ImmutableList.Builder<Key<EppResourceIndexBucket>> builder = new ImmutableList.Builder<>();
|
||||
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
|
||||
for (int bucketId = 1; bucketId <= numBuckets; bucketId++) {
|
||||
for (int bucketId = 1; bucketId <= getEppResourceIndexBucketCount(); bucketId++) {
|
||||
builder.add(getBucketKey(bucketId));
|
||||
}
|
||||
return builder.build();
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Strings.emptyToNull;
|
|||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
import static com.google.common.collect.Sets.immutableEnumSet;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
import static google.registry.config.RegistryConfig.getRegistrarDefaultWhoisServer;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION;
|
||||
|
@ -446,10 +447,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
}
|
||||
|
||||
public String getWhoisServer() {
|
||||
if (whoisServer == null) {
|
||||
return ENVIRONMENT.config().getRegistrarDefaultWhoisServer();
|
||||
}
|
||||
return whoisServer;
|
||||
return firstNonNull(whoisServer, getRegistrarDefaultWhoisServer());
|
||||
}
|
||||
|
||||
public boolean getBlockPremiumNames() {
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.google.appengine.api.urlfetch.HTTPRequest;
|
|||
import com.google.appengine.api.urlfetch.HTTPResponse;
|
||||
import com.google.appengine.api.urlfetch.URLFetchService;
|
||||
import google.registry.config.ConfigModule.Config;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
import google.registry.util.FormattingLogger;
|
||||
|
@ -62,7 +61,6 @@ public class RdeReporter {
|
|||
* ICANN Registry Interfaces - Interface details</a>*/
|
||||
private static final String REPORT_MIME = "text/xml";
|
||||
|
||||
@Inject RegistryConfig config;
|
||||
@Inject Retrier retrier;
|
||||
@Inject URLFetchService urlFetchService;
|
||||
@Inject @Config("rdeReportUrlPrefix") String reportUrlPrefix;
|
||||
|
|
|
@ -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();
|
||||
ImmutableSet.Builder<ImmutableObject> seen = new ImmutableSet.Builder<>();
|
||||
try {
|
||||
while (true) {
|
||||
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();
|
||||
}
|
||||
} 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;
|
||||
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(eppResource.getRepoId()).isNotEmpty();
|
||||
Key<EppResource> eppResourceKey = Key.create(eppResource);
|
||||
saver.entity(EppResourceIndex.create(eppResourceKey));
|
||||
.that(resource.getRepoId())
|
||||
.isNotEmpty();
|
||||
saver.entity(index);
|
||||
if (resource instanceof ForeignKeyedEppResource) {
|
||||
saver.entity(ForeignKeyIndex.create(eppResource, eppResource.getDeletionTime()));
|
||||
saver.entity(ForeignKeyIndex.create(resource, resource.getDeletionTime()));
|
||||
}
|
||||
if (resource instanceof DomainApplication) {
|
||||
saver.entity(
|
||||
DomainApplicationIndex.createUpdatedInstance((DomainApplication) resource));
|
||||
}
|
||||
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,10 +49,11 @@ 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())
|
||||
modified =
|
||||
modified
|
||||
.asBuilder()
|
||||
.setWhoisServer(getRegistrarDefaultWhoisServer())
|
||||
.setReferralUrl(getRegistrarDefaultReferralUrl().toString())
|
||||
.build();
|
||||
assertThat(response).containsEntry("status", "SUCCESS");
|
||||
assertThat(response).containsEntry("results", asList(modified.toJsonMap()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue