Deprecate more fields in RegistryConfig

This primarily addresses issues with TMCH testing mode and email sending utils.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143710550
This commit is contained in:
mcilwain 2017-01-05 14:38:38 -08:00 committed by Ben McIlwain
parent c05424b947
commit 25a8bbe890
23 changed files with 203 additions and 265 deletions

View file

@ -16,6 +16,7 @@ package google.registry.config;
import static google.registry.config.ConfigUtils.makeUrl;
import com.google.appengine.api.utils.SystemProperty;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -214,8 +215,8 @@ public final class ConfigModule {
/** @see RegistryConfig#getCommitLogDatastoreRetention() */
@Provides
@Config("commitLogDatastoreRetention")
public static Duration provideCommitLogDatastoreRetention(RegistryConfig config) {
return config.getCommitLogDatastoreRetention();
public static Duration provideCommitLogDatastoreRetention() {
return RegistryConfig.getCommitLogDatastoreRetention();
}
/**
@ -423,8 +424,8 @@ public final class ConfigModule {
*/
@Provides
@Config("tmchCaTestingMode")
public static boolean provideTmchCaTestingMode(RegistryConfig config) {
return config.getTmchCaTestingMode();
public static boolean provideTmchCaTestingMode() {
return RegistryConfig.getTmchCaTestingMode();
}
/**
@ -467,6 +468,29 @@ public final class ConfigModule {
}
}
/**
* The email address that outgoing emails from the app are sent from.
*
* @see google.registry.util.SendEmailUtils
*/
@Provides
@Config("googleAppsSendFromEmailAddress")
public static String provideGoogleAppsSendFromEmailAddress() {
return String.format("noreply@%s.appspotmail.com", SystemProperty.applicationId.get());
}
/**
* The display name that is used on outgoing emails sent by Nomulus.
*
* @see google.registry.util.SendEmailUtils
*/
@Provides
@Config("googleAppsAdminEmailDisplayName")
public static String provideGoogleAppsAdminEmailDisplayName() {
// Production example: "Example Registry"
return "Google Domain Registry";
}
/**
* Returns the Google Cloud Storage bucket for staging escrow deposits pending upload.
*
@ -1025,5 +1049,9 @@ public final class ConfigModule {
public static class LocalTestConfig {
public static final String CONTACT_AND_HOST_ROID_SUFFIX = "ROID";
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";
}
}

View file

@ -18,7 +18,6 @@ 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.appengine.api.utils.SystemProperty;
import com.google.common.base.Optional;
import com.google.common.net.HostAndPort;
import java.net.URL;
@ -48,33 +47,6 @@ public final class ProductionRegistryConfigExample extends RegistryConfig {
this.environment = checkNotNull(environment);
}
/**
* {@inheritDoc}
*
* <p>Thirty days makes a sane default, because it's highly unlikely we'll ever need to generate a
* deposit older than that. And if we do, we could always bring up a separate App Engine instance
* and replay the commit logs off GCS.
*/
@Override
public Duration getCommitLogDatastoreRetention() {
return Duration.standardDays(30);
}
@Override
public String getSnapshotsBucket() {
return RegistryConfig.getProjectId() + "-snapshots";
}
@Override
public boolean getTmchCaTestingMode() {
switch (environment) {
case PRODUCTION:
return false;
default:
return true;
}
}
@Override
public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException(); // n/a
@ -91,36 +63,11 @@ public final class ProductionRegistryConfigExample extends RegistryConfig {
}
}
@Override
public Duration getSingletonCacheRefreshDuration() {
return Duration.standardMinutes(10);
}
@Override
public Duration getDomainLabelListCacheDuration() {
return Duration.standardHours(1);
}
@Override
public Duration getSingletonCachePersistDuration() {
return Duration.standardDays(365);
}
@Override
public String getReservedTermsExportDisclaimer() {
return RESERVED_TERMS_EXPORT_DISCLAIMER;
}
@Override
public String getGoogleAppsAdminEmailDisplayName() {
return "Example Registry";
}
@Override
public String getGoogleAppsSendFromEmailAddress() {
return String.format("noreply@%s.appspotmail.com", SystemProperty.applicationId.get());
}
@Override
public String getRegistrarDefaultWhoisServer() {
return "whois.nic.registry.example";

View file

@ -49,7 +49,9 @@ public abstract class RegistryConfig {
*
* @see google.registry.export.ExportSnapshotServlet
*/
public abstract String getSnapshotsBucket();
public static String getSnapshotsBucket() {
return getProjectId() + "-snapshots";
}
/**
* Number of sharded commit log buckets.
@ -82,14 +84,23 @@ public abstract class RegistryConfig {
* @see google.registry.backup.DeleteOldCommitLogsAction
* @see google.registry.model.translators.CommitLogRevisionsTranslatorFactory
*/
public abstract Duration getCommitLogDatastoreRetention();
public static Duration getCommitLogDatastoreRetention() {
return Duration.standardDays(30);
}
/**
* Returns {@code true} if TMCH certificate authority should be in testing mode.
*
* @see google.registry.tmch.TmchCertificateAuthority
*/
public abstract boolean getTmchCaTestingMode();
public static boolean getTmchCaTestingMode() {
switch (RegistryEnvironment.get()) {
case PRODUCTION:
return false;
default:
return true;
}
}
public abstract Optional<String> getECatcherAddress();
@ -101,7 +112,16 @@ public abstract class RegistryConfig {
public abstract HostAndPort getServer();
/** Returns the amount of time a singleton should be cached, before expiring. */
public abstract Duration getSingletonCacheRefreshDuration();
public static Duration getSingletonCacheRefreshDuration() {
switch (RegistryEnvironment.get()) {
case UNITTEST:
// All cache durations are set to zero so that unit tests can update and then retrieve data
// immediately without failure.
return Duration.ZERO;
default:
return Duration.standardMinutes(10);
}
}
/**
* Returns the amount of time a domain label list should be cached in memory before expiring.
@ -109,10 +129,24 @@ public abstract class RegistryConfig {
* @see google.registry.model.registry.label.ReservedList
* @see google.registry.model.registry.label.PremiumList
*/
public abstract Duration getDomainLabelListCacheDuration();
public static Duration getDomainLabelListCacheDuration() {
switch (RegistryEnvironment.get()) {
case UNITTEST:
return Duration.ZERO;
default:
return Duration.standardHours(1);
}
}
/** Returns the amount of time a singleton should be cached in persist mode, before expiring. */
public abstract Duration getSingletonCachePersistDuration();
public static Duration getSingletonCachePersistDuration() {
switch (RegistryEnvironment.get()) {
case UNITTEST:
return Duration.ZERO;
default:
return Duration.standardDays(365);
}
}
/**
* Returns the header text at the top of the reserved terms exported list.
@ -121,20 +155,6 @@ public abstract class RegistryConfig {
*/
public abstract String getReservedTermsExportDisclaimer();
/**
* Returns a display name that is used on outgoing emails sent by Nomulus.
*
* @see google.registry.util.SendEmailUtils
*/
public abstract String getGoogleAppsAdminEmailDisplayName();
/**
* Returns the email address that outgoing emails from the app are sent from.
*
* @see google.registry.util.SendEmailUtils
*/
public abstract String getGoogleAppsSendFromEmailAddress();
/**
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
*

View file

@ -28,6 +28,7 @@ import javax.annotation.concurrent.ThreadSafe;
* passing the {@link RegistryEnvironment} as a single parameter.
*/
@ThreadSafe
@Deprecated // will be replaced by YAML config; see b/33386530 for details
public final class RegistryConfigLoader {
public static final String REGISTRY_CONFIG_PROPERTY = "google.registry.config";

View file

@ -72,14 +72,19 @@ public enum RegistryEnvironment {
/** Globally override registry configuration from within a unit test. */
@VisibleForTesting
@Deprecated
public static void overrideConfigurationForTesting(@Nullable RegistryConfig newConfig) {
configOverride = newConfig;
}
@Nullable
@Deprecated
private static RegistryConfig configOverride;
@Deprecated
private static final RegistryConfig testingConfig = new TestRegistryConfig();
@Deprecated
private final RegistryConfig config = RegistryConfigLoader.load(this);
/** System property for configuring which environment we should use. */

View file

@ -29,21 +29,6 @@ public class TestRegistryConfig extends RegistryConfig {
public TestRegistryConfig() {}
@Override
public Duration getCommitLogDatastoreRetention() {
return Duration.standardDays(30);
}
@Override
public String getSnapshotsBucket() {
return RegistryConfig.getProjectId() + "-snapshots";
}
@Override
public boolean getTmchCaTestingMode() {
return true;
}
@Override
public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException();
@ -54,38 +39,11 @@ public class TestRegistryConfig extends RegistryConfig {
throw new UnsupportedOperationException();
}
@Override
public Duration getSingletonCacheRefreshDuration() {
// All cache durations are set to zero so that unit tests can update and then retrieve data
// immediately without failure.
return Duration.ZERO;
}
@Override
public Duration getDomainLabelListCacheDuration() {
return Duration.ZERO;
}
@Override
public Duration getSingletonCachePersistDuration() {
return Duration.ZERO;
}
@Override
public String getReservedTermsExportDisclaimer() {
return "This is a disclaimer.\n";
}
@Override
public String getGoogleAppsAdminEmailDisplayName() {
return "Testing Nomulus";
}
@Override
public String getGoogleAppsSendFromEmailAddress() {
return "noreply@testing.example";
}
@Override
public String getRegistrarDefaultWhoisServer() {
return "whois.nic.fakewhois.example";