From 61230b035c9f08192653be227d569170f12ca971 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 3 Feb 2017 09:28:29 -0800 Subject: [PATCH] Finish YAMLification of last necessary config values There are still some options in RegistryConfig that can't be configured in YAML, but it's not clear why anyone would need to change them from their default values. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146482435 --- .../registry/config/RegistryConfig.java | 64 +++++++------------ .../config/RegistryConfigSettings.java | 11 ++++ .../registry/config/default-config.yaml | 35 ++++++++++ .../nomulus-config-production-sample.yaml | 11 ++++ .../export/ExportReservedTermsActionTest.java | 3 +- .../registry/export/ExportUtilsTest.java | 5 +- .../registry/flows/EppLoggedOutTest.java | 2 +- .../registry/flows/session/HelloFlowTest.java | 2 +- .../{greeting_crr.xml => greeting.xml} | 2 +- .../{greeting_crr.xml => greeting.xml} | 2 +- .../RegistrarSettingsActionTestCase.java | 7 +- .../server/registrar/SendEmailUtilsTest.java | 8 +-- 12 files changed, 92 insertions(+), 60 deletions(-) rename javatests/google/registry/flows/session/testdata/{greeting_crr.xml => greeting.xml} (95%) rename javatests/google/registry/flows/testdata/{greeting_crr.xml => greeting.xml} (95%) diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java index 6977ece86..ea555aa3b 100644 --- a/java/google/registry/config/RegistryConfig.java +++ b/java/google/registry/config/RegistryConfig.java @@ -591,9 +591,8 @@ public final class RegistryConfig { */ @Provides @Config("rdeSshIdentity") - public static String provideSshIdentity() { - // Change this to your RDE identity. - return "rde@example.com"; + public static String provideSshIdentity(RegistryConfigSettings config) { + return config.rde.sshIdentityEmailAddress; } /** @@ -711,8 +710,8 @@ public final class RegistryConfig { */ @Provides @Config("rdapLinkBase") - public static String provideRdapLinkBase() { - return "https://nic.google/rdap/"; + public static String provideRdapLinkBase(RegistryConfigSettings config) { + return config.rdap.baseUrl; } /** @@ -781,20 +780,8 @@ public final class RegistryConfig { */ @Provides @Config("whoisDisclaimer") - public static String provideWhoisDisclaimer() { - return "WHOIS information is provided by Charleston Road Registry Inc. (CRR) solely for\n" - + "query-based, informational purposes. By querying our WHOIS database, you are\n" - + "agreeing to comply with these terms\n" - + "(http://www.registry.google/about/whois-disclaimer.html) so please read them\n" - + "carefully. Any information provided is \"as is\" without any guarantee of\n" - + "accuracy. You may not use such information to (a) allow, enable, or otherwise\n" - + "support the transmission of mass unsolicited, commercial advertising or\n" - + "solicitations; (b) enable high volume, automated, electronic processes that\n" - + "access the systems of CRR or any ICANN-Accredited Registrar, except as\n" - + "reasonably necessary to register domain names or modify existing registrations;\n" - + "or (c) engage in or support unlawful behavior. CRR reserves the right to\n" - + "restrict or deny your access to the Whois database, and may modify these terms\n" - + "at any time.\n"; + public static String provideWhoisDisclaimer(RegistryConfigSettings config) { + return config.registryPolicy.whoisDisclaimer; } /** @@ -889,8 +876,8 @@ public final class RegistryConfig { */ @Provides @Config("greetingServerId") - public static String provideGreetingServerId() { - return "Charleston Road Registry"; + public static String provideGreetingServerId(RegistryConfigSettings config) { + return config.registryPolicy.greetingServerId; } @Provides @@ -905,13 +892,6 @@ public final class RegistryConfig { return config.registryPolicy.whoisCommandFactoryClass; } - 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. * @@ -919,8 +899,8 @@ public final class RegistryConfig { */ @Provides @Config("reservedTermsExportDisclaimer") - public static String provideReservedTermsExportDisclaimer() { - return RESERVED_TERMS_EXPORT_DISCLAIMER; + public static String provideReservedTermsExportDisclaimer(RegistryConfigSettings config) { + return config.registryPolicy.reservedTermsExportDisclaimer; } /** @@ -928,8 +908,8 @@ public final class RegistryConfig { */ @Provides @Config("checkApiServletRegistrarClientId") - public static String provideCheckApiServletRegistrarClientId() { - return "TheRegistrar"; + public static String provideCheckApiServletRegistrarClientId(RegistryConfigSettings config) { + return config.registryPolicy.checkApiServletClientId; } @Singleton @@ -1114,6 +1094,16 @@ public final class RegistryConfig { return Duration.standardSeconds(CONFIG_SETTINGS.get().caching.singletonCachePersistSeconds); } + /** Returns the email address that outgoing emails from the app are sent from. */ + public static String getGSuiteOutgoingEmailAddress() { + return CONFIG_SETTINGS.get().gSuite.outgoingEmailAddress; + } + + /** Returns the display name that outgoing emails from the app are sent from. */ + public static String getGSuiteOutgoingEmailDisplayName() { + return CONFIG_SETTINGS.get().gSuite.outgoingEmailDisplayName; + } + /** * Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}. * @@ -1168,15 +1158,5 @@ public final class RegistryConfig { return getConfigSettings(); }}); - /** Config values used for local and unit test environments. */ - public static class LocalTestConfig { - - 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"; - } - private RegistryConfig() {} } diff --git a/java/google/registry/config/RegistryConfigSettings.java b/java/google/registry/config/RegistryConfigSettings.java index c4ef9a245..5f9cf099d 100644 --- a/java/google/registry/config/RegistryConfigSettings.java +++ b/java/google/registry/config/RegistryConfigSettings.java @@ -29,6 +29,7 @@ public class RegistryConfigSettings { public RegistrarConsole registrarConsole; public Monitoring monitoring; public Misc misc; + public Rdap rdap; public Braintree braintree; /** Configuration options that apply to the entire App Engine project. */ @@ -58,12 +59,16 @@ public class RegistryConfigSettings { public String customLogicFactoryClass; public String whoisCommandFactoryClass; public int contactAutomaticTransferDays; + public String greetingServerId; public List registrarChangesNotificationEmailAddresses; public String defaultRegistrarWhoisServer; public String defaultRegistrarReferralUrl; public String tmchCaMode; public String tmchCrlUrl; public String tmchMarksDbUrl; + public String checkApiServletClientId; + public String reservedTermsExportDisclaimer; + public String whoisDisclaimer; } /** Configuration for Cloud Datastore. */ @@ -84,6 +89,7 @@ public class RegistryConfigSettings { public static class Rde { public String reportUrlPrefix; public String uploadUrl; + public String sshIdentityEmailAddress; } /** Configuration for the web-based registrar console. */ @@ -108,6 +114,11 @@ public class RegistryConfigSettings { public String sheetExportId; } + /** Configuration for RDAP. */ + public static class Rdap { + public String baseUrl; + } + /** Configuration for Braintree credit card payment processing. */ public static class Braintree { public String merchantId; diff --git a/java/google/registry/config/default-config.yaml b/java/google/registry/config/default-config.yaml index f2e092183..13581d1a9 100644 --- a/java/google/registry/config/default-config.yaml +++ b/java/google/registry/config/default-config.yaml @@ -44,6 +44,9 @@ registryPolicy: # Length of time after which contact transfers automatically conclude. contactAutomaticTransferDays: 5 + # Server ID used in the 'svID' element of an EPP 'greeting'. + greetingServerId: Nomulus Registry + # List of email addresses that notifications of registrar and/or registrar # contact updates should be sent to, or empty list for no notifications. registrarChangesNotificationEmailAddresses: [] @@ -64,6 +67,31 @@ registryPolicy: # URL for the MarksDB registry interface. tmchMarksDbUrl: https://test.ry.marksdb.org + # Registry’s operations registrar, used for front-end availability/premium + # domain checks. + checkApiServletClientId: TheRegistrar + + # Disclaimer at the top of the exported reserved terms list. + reservedTermsExportDisclaimer: | + This list contains reserved terms for the TLD. Other terms may be reserved + but not included in this list, including terms the registry chooses not + to publish, and terms that ICANN commonly mandates to be reserved. This + list is subject to change and the most up-to-date source is always to + check availability directly with the Registry server. + + # Disclaimer at the top of WHOIS results. + whoisDisclaimer: | + WHOIS information is provided by the registry solely for query-based, + informational purposes. Any information provided is "as is" without any + guarantee of accuracy. You may not use such information to (a) allow, + enable, or otherwise support the transmission of mass unsolicited, + commercial advertising or solicitations; (b) enable high volume, automated, + electronic processes that access the registry's systems or any + ICANN-Accredited Registrar, except as reasonably necessary to register + domain names or modify existing registrations; or (c) engage in or support + unlawful behavior. We reserve the right to restrict or deny your access to + the WHOIS database, and may modify these terms at any time. + datastore: # Number of commit log buckets in Datastore. Don't change after initial # install. @@ -96,6 +124,9 @@ rde: # but not the password. uploadUrl: sftp://username@rde-provider.example + # Identity of the SSH keys (stored in the Keyring) used for RDE SFTP uploads. + sshIdentityEmailAddress: rde@example.com + registrarConsole: # Filename of the logo to use in the header of the console. This filename is # relative to ui/assets/images/ @@ -133,6 +164,10 @@ misc: # to. Leave this null to disable syncing. sheetExportId: null +rdap: + # Base URL (with trailing slash) for RDAP links. + baseUrl: http://domain-registry.example/rdap/ + # Braintree is a credit card payment processor that is used on the registrar # console to allow registrars to pay their invoices. braintree: diff --git a/java/google/registry/config/nomulus-config-production-sample.yaml b/java/google/registry/config/nomulus-config-production-sample.yaml index 627d70386..c34ea5e2f 100644 --- a/java/google/registry/config/nomulus-config-production-sample.yaml +++ b/java/google/registry/config/nomulus-config-production-sample.yaml @@ -19,6 +19,7 @@ gSuite: registryPolicy: contactAndHostRoidSuffix: placeholder productName: placeholder + greetingServerId: placeholder registrarChangesNotificationEmailAddresses: - placeholder - placeholder @@ -27,10 +28,17 @@ registryPolicy: tmchCaMode: PRODUCTION tmchCrlUrl: http://crl.icann.org/tmch.crl tmchMarksDbUrl: https://ry.marksdb.org + checkApiServletClientId: | + multi-line + placeholder + whoisDisclaimer: | + multi-line + placeholder rde: reportUrlPrefix: https://ry-api.icann.org/report/registry-escrow-report uploadUrl: sftp://placeholder@sftpipm2.ironmountain.com/Outbox + sshIdentityEmailAddress: placeholder registrarConsole: logoFilename: placeholder @@ -43,6 +51,9 @@ registrarConsole: misc: sheetExportId: placeholder +rdap: + baseUrl: placeholder + # You only need to specify this section if using Braintree. braintree: merchantId: placeholder diff --git a/javatests/google/registry/export/ExportReservedTermsActionTest.java b/javatests/google/registry/export/ExportReservedTermsActionTest.java index 489a20d45..b93121dad 100644 --- a/javatests/google/registry/export/ExportReservedTermsActionTest.java +++ b/javatests/google/registry/export/ExportReservedTermsActionTest.java @@ -32,7 +32,6 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableSet; import com.google.common.net.MediaType; -import google.registry.config.RegistryConfig.LocalTestConfig; import google.registry.model.registry.Registry; import google.registry.model.registry.label.ReservedList; import google.registry.request.Response; @@ -65,7 +64,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.exportUtils = new ExportUtils("This is a disclaimer.\n"); action.tld = tld; action.run(); } diff --git a/javatests/google/registry/export/ExportUtilsTest.java b/javatests/google/registry/export/ExportUtilsTest.java index 0100d96f5..e3219014f 100644 --- a/javatests/google/registry/export/ExportUtilsTest.java +++ b/javatests/google/registry/export/ExportUtilsTest.java @@ -15,7 +15,6 @@ package google.registry.export; import static com.google.common.truth.Truth.assertThat; -import static google.registry.config.RegistryConfig.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; @@ -57,9 +56,7 @@ public class ExportUtilsTest { createTld("tld"); persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build()); // Should not contain jimmy, tine, or oval. - assertThat( - new ExportUtils(RESERVED_TERMS_TEST_EXPORT_DISCLAIMER) - .exportReservedTerms(Registry.get("tld"))) + assertThat(new ExportUtils("This is a disclaimer.\n").exportReservedTerms(Registry.get("tld"))) .isEqualTo("This is a disclaimer.\ncat\nlol\nsnow\n"); } } diff --git a/javatests/google/registry/flows/EppLoggedOutTest.java b/javatests/google/registry/flows/EppLoggedOutTest.java index 5371e080b..a1f5824b0 100644 --- a/javatests/google/registry/flows/EppLoggedOutTest.java +++ b/javatests/google/registry/flows/EppLoggedOutTest.java @@ -40,7 +40,7 @@ public class EppLoggedOutTest extends EppTestCase { assertCommandAndResponse( "hello.xml", null, - "greeting_crr.xml", + "greeting.xml", ImmutableMap.of("DATE", now.toString(dateTimeNoMillis())), now); } diff --git a/javatests/google/registry/flows/session/HelloFlowTest.java b/javatests/google/registry/flows/session/HelloFlowTest.java index 66d7ed02d..f125af7fc 100644 --- a/javatests/google/registry/flows/session/HelloFlowTest.java +++ b/javatests/google/registry/flows/session/HelloFlowTest.java @@ -31,7 +31,7 @@ public class HelloFlowTest extends FlowTestCase { runFlowAssertResponse( loadFileWithSubstitutions( getClass(), - "greeting_crr.xml", + "greeting.xml", ImmutableMap.of("DATE", clock.nowUtc().toString(dateTimeNoMillis())))); } } diff --git a/javatests/google/registry/flows/session/testdata/greeting_crr.xml b/javatests/google/registry/flows/session/testdata/greeting.xml similarity index 95% rename from javatests/google/registry/flows/session/testdata/greeting_crr.xml rename to javatests/google/registry/flows/session/testdata/greeting.xml index 874cfc0d3..3e4d3a54d 100644 --- a/javatests/google/registry/flows/session/testdata/greeting_crr.xml +++ b/javatests/google/registry/flows/session/testdata/greeting.xml @@ -1,6 +1,6 @@ - Charleston Road Registry + Nomulus Registry %DATE% 1.0 diff --git a/javatests/google/registry/flows/testdata/greeting_crr.xml b/javatests/google/registry/flows/testdata/greeting.xml similarity index 95% rename from javatests/google/registry/flows/testdata/greeting_crr.xml rename to javatests/google/registry/flows/testdata/greeting.xml index 874cfc0d3..3e4d3a54d 100644 --- a/javatests/google/registry/flows/testdata/greeting_crr.xml +++ b/javatests/google/registry/flows/testdata/greeting.xml @@ -1,6 +1,6 @@ - Charleston Road Registry + Nomulus Registry %DATE% 1.0 diff --git a/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java b/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java index ada0953cd..b9bfc17c1 100644 --- a/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java +++ b/javatests/google/registry/ui/server/registrar/RegistrarSettingsActionTestCase.java @@ -14,8 +14,8 @@ package google.registry.ui.server.registrar; -import static google.registry.config.RegistryConfig.LocalTestConfig.GOOGLE_APPS_ADMIN_EMAIL_DISPLAY_NAME; -import static google.registry.config.RegistryConfig.LocalTestConfig.GOOGLE_APPS_SEND_FROM_EMAIL_ADDRESS; +import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailAddress; +import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailDisplayName; import static google.registry.security.JsonHttpTestUtils.createJsonPayload; import static google.registry.security.JsonHttpTestUtils.createJsonResponseSupplier; import static google.registry.security.XsrfTokenManager.generateToken; @@ -102,8 +102,7 @@ public class RegistrarSettingsActionTestCase { action.registrarChangesNotificationEmailAddresses = ImmutableList.of( "notification@test.example", "notification2@test.example"); action.sendEmailUtils = - new SendEmailUtils( - GOOGLE_APPS_SEND_FROM_EMAIL_ADDRESS, GOOGLE_APPS_ADMIN_EMAIL_DISPLAY_NAME); + new SendEmailUtils(getGSuiteOutgoingEmailAddress(), getGSuiteOutgoingEmailDisplayName()); inject.setStaticField(Ofy.class, "clock", clock); inject.setStaticField(SendEmailUtils.class, "emailService", emailService); inject.setStaticField(SyncRegistrarsSheetAction.class, "modulesService", modulesService); diff --git a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java index 2a5fed699..8087985a0 100644 --- a/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java +++ b/javatests/google/registry/ui/server/registrar/SendEmailUtilsTest.java @@ -15,6 +15,8 @@ package google.registry.ui.server.registrar; import static com.google.common.truth.Truth.assertThat; +import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailAddress; +import static google.registry.config.RegistryConfig.getGSuiteOutgoingEmailDisplayName; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; @@ -22,7 +24,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; -import google.registry.config.RegistryConfig.LocalTestConfig; import google.registry.testing.ExceptionRule; import google.registry.testing.InjectRule; import google.registry.util.SendEmailService; @@ -61,9 +62,8 @@ public class SendEmailUtilsTest { inject.setStaticField(SendEmailUtils.class, "emailService", emailService); message = new MimeMessage(Session.getDefaultInstance(new Properties(), null)); when(emailService.createMessage()).thenReturn(message); - sendEmailUtils = new SendEmailUtils( - LocalTestConfig.GOOGLE_APPS_SEND_FROM_EMAIL_ADDRESS, - LocalTestConfig.GOOGLE_APPS_ADMIN_EMAIL_DISPLAY_NAME); + sendEmailUtils = + new SendEmailUtils(getGSuiteOutgoingEmailAddress(), getGSuiteOutgoingEmailDisplayName()); } @Test