diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java
index 5d0fae842..528041770 100644
--- a/java/google/registry/config/RegistryConfig.java
+++ b/java/google/registry/config/RegistryConfig.java
@@ -19,6 +19,7 @@ import static google.registry.config.ConfigUtils.makeUrl;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -33,6 +34,7 @@ import java.lang.annotation.Retention;
import java.net.URI;
import java.net.URL;
import java.util.Optional;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.inject.Named;
import javax.inject.Qualifier;
@@ -1063,7 +1065,13 @@ public final class RegistryConfig {
@Provides
@Config("reservedTermsExportDisclaimer")
public static String provideReservedTermsExportDisclaimer(RegistryConfigSettings config) {
- return config.registryPolicy.reservedTermsExportDisclaimer;
+ return Splitter.on('\n')
+ .omitEmptyStrings()
+ .trimResults()
+ .splitToList(config.registryPolicy.reservedTermsExportDisclaimer)
+ .stream()
+ .map(s -> "# " + s)
+ .collect(Collectors.joining("\n"));
}
/** Returns the clientId of the registrar used by the {@code CheckApiServlet}. */
@@ -1390,7 +1398,8 @@ public final class RegistryConfig {
*
Memoizing without cache expiration is used because the app must be re-deployed in order to
* change the contents of the YAML config files.
*/
- private static final Supplier CONFIG_SETTINGS =
+ @VisibleForTesting
+ static final Supplier CONFIG_SETTINGS =
memoize(YamlUtils::getConfigSettings);
private RegistryConfig() {}
diff --git a/java/google/registry/config/files/nomulus-config-unittest.yaml b/java/google/registry/config/files/nomulus-config-unittest.yaml
index cd3078a5e..a41fd9cf6 100644
--- a/java/google/registry/config/files/nomulus-config-unittest.yaml
+++ b/java/google/registry/config/files/nomulus-config-unittest.yaml
@@ -6,6 +6,9 @@ registryPolicy:
- notification@test.example
- notification2@test.example
defaultRegistrarWhoisServer: whois.nic.fakewhois.example
+ reservedTermsExportDisclaimer: |
+ Disclaimer line 1.
+ Line 2 is this 1.
datastore:
commitLogBucketsNum: 3
diff --git a/java/google/registry/export/ExportUtils.java b/java/google/registry/export/ExportUtils.java
index 96b06f8e6..668b49cfe 100644
--- a/java/google/registry/export/ExportUtils.java
+++ b/java/google/registry/export/ExportUtils.java
@@ -37,7 +37,7 @@ public final class ExportUtils {
/** Returns the file contents of the auto-export reserved terms document for the given TLD. */
public String exportReservedTerms(Registry registry) {
- StringBuilder termsBuilder = new StringBuilder(reservedTermsExportDisclaimer);
+ StringBuilder termsBuilder = new StringBuilder(reservedTermsExportDisclaimer).append("\n");
Set reservedTerms = new TreeSet<>();
for (Key key : registry.getReservedLists()) {
ReservedList reservedList = ReservedList.load(key).get();
diff --git a/javatests/google/registry/config/RegistryConfigTest.java b/javatests/google/registry/config/RegistryConfigTest.java
index 6faaddf29..5762e4ea2 100644
--- a/javatests/google/registry/config/RegistryConfigTest.java
+++ b/javatests/google/registry/config/RegistryConfigTest.java
@@ -15,6 +15,8 @@
package google.registry.config;
import static com.google.common.truth.Truth.assertThat;
+import static google.registry.config.RegistryConfig.CONFIG_SETTINGS;
+import static google.registry.config.RegistryConfig.ConfigModule.provideReservedTermsExportDisclaimer;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -23,13 +25,16 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class RegistryConfigTest {
- public RegistryConfigTest() {}
-
@Test
public void test_clientSecretFilename() {
// Verify that we're pulling this from the default.
assertThat(RegistryConfig.getClientSecretFilename()).isEqualTo(
"/google/registry/tools/resources/client_secret.json");
}
-}
+ @Test
+ public void test_reservedTermsExportDisclaimer_isPrependedWithOctothorpes() {
+ assertThat(provideReservedTermsExportDisclaimer(CONFIG_SETTINGS.get()))
+ .isEqualTo("# Disclaimer line 1.\n" + "# Line 2 is this 1.");
+ }
+}
diff --git a/javatests/google/registry/export/ExportReservedTermsActionTest.java b/javatests/google/registry/export/ExportReservedTermsActionTest.java
index 81175cf24..ce8722a24 100644
--- a/javatests/google/registry/export/ExportReservedTermsActionTest.java
+++ b/javatests/google/registry/export/ExportReservedTermsActionTest.java
@@ -60,7 +60,7 @@ public class ExportReservedTermsActionTest {
ExportReservedTermsAction action = new ExportReservedTermsAction();
action.response = response;
action.driveConnection = driveConnection;
- action.exportUtils = new ExportUtils("This is a disclaimer.\n");
+ action.exportUtils = new ExportUtils("# This is a disclaimer.");
action.tld = tld;
action.run();
}
@@ -85,9 +85,7 @@ public class ExportReservedTermsActionTest {
@Test
public void test_uploadFileToDrive_succeeds() throws Exception {
runAction("tld");
- byte[] expected =
- ("This is a disclaimer.\ncat\nlol\n")
- .getBytes(UTF_8);
+ byte[] expected = "# This is a disclaimer.\ncat\nlol\n".getBytes(UTF_8);
verify(driveConnection)
.createOrUpdateFile(RESERVED_TERMS_FILENAME, EXPORT_MIME_TYPE, "brouhaha", expected);
verify(response).setStatus(SC_OK);
diff --git a/javatests/google/registry/export/ExportUtilsTest.java b/javatests/google/registry/export/ExportUtilsTest.java
index c5fc5a65c..5c29856ab 100644
--- a/javatests/google/registry/export/ExportUtilsTest.java
+++ b/javatests/google/registry/export/ExportUtilsTest.java
@@ -53,7 +53,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("This is a disclaimer.\n").exportReservedTerms(Registry.get("tld")))
- .isEqualTo("This is a disclaimer.\ncat\nlol\nsnow\n");
+ assertThat(new ExportUtils("# This is a disclaimer.").exportReservedTerms(Registry.get("tld")))
+ .isEqualTo("# This is a disclaimer.\ncat\nlol\nsnow\n");
}
}