mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Remove use of shouldPublishField from ReservedList (#2324)
* Remove use of shouldPublishField from ReservedList * Remove from tests * Update test comment * Fix indentation * fix test comment * Fix test * fix test * Make shouldPublish column nullable
This commit is contained in:
parent
15368ee1c6
commit
a4bd85068b
21 changed files with 54 additions and 146 deletions
|
@ -46,10 +46,8 @@ public final class ExportUtils {
|
||||||
() ->
|
() ->
|
||||||
new IllegalStateException(
|
new IllegalStateException(
|
||||||
String.format("Reserved list %s does not exist", reservedListName)));
|
String.format("Reserved list %s does not exist", reservedListName)));
|
||||||
if (reservedList.getShouldPublish()) {
|
for (ReservedListEntry entry : reservedList.getReservedListEntries().values()) {
|
||||||
for (ReservedListEntry entry : reservedList.getReservedListEntries().values()) {
|
reservedTerms.add(entry.getDomainLabel());
|
||||||
reservedTerms.add(entry.getDomainLabel());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Joiner.on("\n").appendTo(termsBuilder, reservedTerms);
|
Joiner.on("\n").appendTo(termsBuilder, reservedTerms);
|
||||||
|
|
|
@ -71,7 +71,8 @@ public final class ReservedList
|
||||||
*/
|
*/
|
||||||
@Insignificant @Transient Map<String, ReservedListEntry> reservedListMap;
|
@Insignificant @Transient Map<String, ReservedListEntry> reservedListMap;
|
||||||
|
|
||||||
@Column(nullable = false)
|
// TODO(b/321053918): Remove this field once the column is nullable
|
||||||
|
@Column(nullable = true)
|
||||||
boolean shouldPublish = true;
|
boolean shouldPublish = true;
|
||||||
|
|
||||||
@PreRemove
|
@PreRemove
|
||||||
|
@ -180,14 +181,6 @@ public final class ReservedList
|
||||||
return !getReferencingTlds().isEmpty();
|
return !getReferencingTlds().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this reserved list is included in the concatenated list of reserved terms
|
|
||||||
* published to Google Drive for viewing by registrars.
|
|
||||||
*/
|
|
||||||
public boolean getShouldPublish() {
|
|
||||||
return shouldPublish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link Map} of domain labels to {@link ReservedListEntry}.
|
* Returns a {@link Map} of domain labels to {@link ReservedListEntry}.
|
||||||
*
|
*
|
||||||
|
@ -330,11 +323,6 @@ public final class ReservedList
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setShouldPublish(boolean shouldPublish) {
|
|
||||||
getInstance().shouldPublish = shouldPublish;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the reservedListMap from input lines.
|
* Updates the reservedListMap from input lines.
|
||||||
*
|
*
|
||||||
|
|
|
@ -44,14 +44,6 @@ public abstract class CreateOrUpdateReservedListCommand extends ConfirmingComman
|
||||||
required = true)
|
required = true)
|
||||||
Path input;
|
Path input;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Parameter(
|
|
||||||
names = "--should_publish",
|
|
||||||
description =
|
|
||||||
"Whether the list is published to the concatenated list on Drive (defaults to true).",
|
|
||||||
arity = 1)
|
|
||||||
Boolean shouldPublish;
|
|
||||||
|
|
||||||
ReservedList reservedList;
|
ReservedList reservedList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,12 +53,10 @@ final class CreateReservedListCommand extends CreateOrUpdateReservedListCommand
|
||||||
}
|
}
|
||||||
DateTime now = DateTime.now(UTC);
|
DateTime now = DateTime.now(UTC);
|
||||||
List<String> allLines = Files.readAllLines(input, UTF_8);
|
List<String> allLines = Files.readAllLines(input, UTF_8);
|
||||||
boolean shouldPublish = this.shouldPublish == null || this.shouldPublish;
|
|
||||||
reservedList =
|
reservedList =
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName(name)
|
.setName(name)
|
||||||
.setReservedListMapFromLines(allLines)
|
.setReservedListMapFromLines(allLines)
|
||||||
.setShouldPublish(shouldPublish)
|
|
||||||
.setCreationTimestamp(now)
|
.setCreationTimestamp(now)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -60,38 +60,21 @@ final class UpdateReservedListCommand extends CreateOrUpdateReservedListCommand
|
||||||
new IllegalArgumentException(
|
new IllegalArgumentException(
|
||||||
String.format(
|
String.format(
|
||||||
"Could not update reserved list %s because it doesn't exist.", name)));
|
"Could not update reserved list %s because it doesn't exist.", name)));
|
||||||
boolean shouldPublish =
|
|
||||||
this.shouldPublish == null ? existingReservedList.getShouldPublish() : this.shouldPublish;
|
|
||||||
List<String> allLines = Files.readAllLines(input, UTF_8);
|
List<String> allLines = Files.readAllLines(input, UTF_8);
|
||||||
ReservedList.Builder updated =
|
ReservedList.Builder updated =
|
||||||
existingReservedList
|
existingReservedList.asBuilder().setReservedListMapFromLines(allLines);
|
||||||
.asBuilder()
|
|
||||||
.setReservedListMapFromLines(allLines)
|
|
||||||
.setShouldPublish(shouldPublish);
|
|
||||||
reservedList = updated.build();
|
reservedList = updated.build();
|
||||||
boolean shouldPublishChanged =
|
|
||||||
existingReservedList.getShouldPublish() != reservedList.getShouldPublish();
|
|
||||||
boolean reservedListEntriesChanged =
|
boolean reservedListEntriesChanged =
|
||||||
!existingReservedList
|
!existingReservedList
|
||||||
.getReservedListEntries()
|
.getReservedListEntries()
|
||||||
.equals(reservedList.getReservedListEntries());
|
.equals(reservedList.getReservedListEntries());
|
||||||
if (!shouldPublishChanged && !reservedListEntriesChanged) {
|
if (!reservedListEntriesChanged) {
|
||||||
newChange = false;
|
newChange = false;
|
||||||
return "No entity changes to apply.";
|
return "No entity changes to apply.";
|
||||||
}
|
}
|
||||||
String result = String.format("Update reserved list for %s?\n", name);
|
return String.format("Update reserved list for %s?\n", name)
|
||||||
if (shouldPublishChanged) {
|
+ prettyPrintEntityDeepDiff(
|
||||||
result +=
|
existingReservedList.getReservedListEntries(), reservedList.getReservedListEntries());
|
||||||
String.format(
|
|
||||||
"shouldPublish: %s -> %s\n",
|
|
||||||
existingReservedList.getShouldPublish(), reservedList.getShouldPublish());
|
|
||||||
}
|
|
||||||
if (reservedListEntriesChanged) {
|
|
||||||
result +=
|
|
||||||
prettyPrintEntityDeepDiff(
|
|
||||||
existingReservedList.getReservedListEntries(), reservedList.getReservedListEntries());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,6 @@ public final class ReservedDomainsTestingUtils {
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName(listName)
|
.setName(listName)
|
||||||
.setCreationTimestamp(START_OF_TIME)
|
.setCreationTimestamp(START_OF_TIME)
|
||||||
.setShouldPublish(true)
|
|
||||||
.setReservedListMap(entries)
|
.setReservedListMap(entries)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,6 @@ public final class ReservedDomainsTestingUtils {
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName(listName)
|
.setName(listName)
|
||||||
.setCreationTimestamp(START_OF_TIME)
|
.setCreationTimestamp(START_OF_TIME)
|
||||||
.setShouldPublish(true)
|
|
||||||
.setReservedListMap(
|
.setReservedListMap(
|
||||||
new ImmutableMap.Builder<String, ReservedListEntry>()
|
new ImmutableMap.Builder<String, ReservedListEntry>()
|
||||||
.putAll(existingEntries)
|
.putAll(existingEntries)
|
||||||
|
@ -97,7 +95,6 @@ public final class ReservedDomainsTestingUtils {
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName(listName)
|
.setName(listName)
|
||||||
.setCreationTimestamp(START_OF_TIME)
|
.setCreationTimestamp(START_OF_TIME)
|
||||||
.setShouldPublish(true)
|
|
||||||
.setReservedListMap(newEntries)
|
.setReservedListMap(newEntries)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ public class UploadBsaUnavailableDomainsActionTest {
|
||||||
ReservedList reservedList =
|
ReservedList reservedList =
|
||||||
persistReservedList(
|
persistReservedList(
|
||||||
"tld-reserved_list",
|
"tld-reserved_list",
|
||||||
true,
|
|
||||||
"tine,FULLY_BLOCKED",
|
"tine,FULLY_BLOCKED",
|
||||||
"flagrant,NAME_COLLISION",
|
"flagrant,NAME_COLLISION",
|
||||||
"jimmy,RESERVED_FOR_SPECIFIC_USE");
|
"jimmy,RESERVED_FOR_SPECIFIC_USE");
|
||||||
|
|
|
@ -43,13 +43,8 @@ class ExportUtilsTest {
|
||||||
"tld-reserved2",
|
"tld-reserved2",
|
||||||
"lol,NAME_COLLISION",
|
"lol,NAME_COLLISION",
|
||||||
"snow,FULLY_BLOCKED");
|
"snow,FULLY_BLOCKED");
|
||||||
ReservedList rl3 = persistReservedList(
|
|
||||||
"tld-reserved3",
|
|
||||||
false,
|
|
||||||
"tine,FULLY_BLOCKED");
|
|
||||||
createTld("tld");
|
createTld("tld");
|
||||||
persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build());
|
persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2).build());
|
||||||
// Should not contain jimmy, tine, or oval.
|
|
||||||
assertThat(new ExportUtils("# This is a disclaimer.").exportReservedTerms(Tld.get("tld")))
|
assertThat(new ExportUtils("# This is a disclaimer.").exportReservedTerms(Tld.get("tld")))
|
||||||
.isEqualTo("# This is a disclaimer.\ncat\nlol\nsnow\n");
|
.isEqualTo("# This is a disclaimer.\ncat\nlol\nsnow\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,7 +300,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved15")
|
.setName("tld-reserved15")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
ReservedList rl16 =
|
ReservedList rl16 =
|
||||||
|
@ -309,7 +308,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved16")
|
.setName("tld-reserved16")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
Tld registry1 =
|
Tld registry1 =
|
||||||
|
@ -347,7 +345,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved5")
|
.setName("tld-reserved5")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
ReservedList rl6 =
|
ReservedList rl6 =
|
||||||
|
@ -356,7 +353,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved6")
|
.setName("tld-reserved6")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
Tld r = Tld.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build();
|
Tld r = Tld.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build();
|
||||||
|
@ -372,7 +368,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved15")
|
.setName("tld-reserved15")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
ImmutableList.of("potato,FULLY_BLOCKED", "phone,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
persistReservedList(
|
persistReservedList(
|
||||||
|
@ -380,7 +375,6 @@ public final class TldTest extends EntityTestCase {
|
||||||
.setName("tld-reserved16")
|
.setName("tld-reserved16")
|
||||||
.setReservedListMapFromLines(
|
.setReservedListMapFromLines(
|
||||||
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
ImmutableList.of("port,FULLY_BLOCKED", "manteau,FULLY_BLOCKED"))
|
||||||
.setShouldPublish(true)
|
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.build());
|
.build());
|
||||||
Tld r =
|
Tld r =
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class ReservedListDaoTest {
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName("testlist")
|
.setName("testlist")
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.setShouldPublish(false)
|
|
||||||
.setReservedListMap(testReservations)
|
.setReservedListMap(testReservations)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -102,7 +101,6 @@ public class ReservedListDaoTest {
|
||||||
assertThat(persistedList.getRevisionId()).isNotNull();
|
assertThat(persistedList.getRevisionId()).isNotNull();
|
||||||
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||||
assertThat(persistedList.getName()).isEqualTo("testlist");
|
assertThat(persistedList.getName()).isEqualTo("testlist");
|
||||||
assertThat(persistedList.getShouldPublish()).isFalse();
|
|
||||||
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
|
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,6 @@ public class ReservedListDaoTest {
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName("testlist")
|
.setName("testlist")
|
||||||
.setCreationTimestamp(fakeClock.nowUtc())
|
.setCreationTimestamp(fakeClock.nowUtc())
|
||||||
.setShouldPublish(false)
|
|
||||||
.setReservedListMap(
|
.setReservedListMap(
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"old",
|
"old",
|
||||||
|
@ -124,7 +121,6 @@ public class ReservedListDaoTest {
|
||||||
assertThat(persistedList.getRevisionId()).isNotNull();
|
assertThat(persistedList.getRevisionId()).isNotNull();
|
||||||
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
assertThat(persistedList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||||
assertThat(persistedList.getName()).isEqualTo("testlist");
|
assertThat(persistedList.getName()).isEqualTo("testlist");
|
||||||
assertThat(persistedList.getShouldPublish()).isFalse();
|
|
||||||
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
|
assertThat(persistedList.getReservedListEntries()).containsExactlyEntriesIn(testReservations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,23 +345,17 @@ public final class DatabaseHelper {
|
||||||
domain.asBuilder().setAutorenewBillingEvent(billingRecurrence.createVKey()).build());
|
domain.asBuilder().setAutorenewBillingEvent(billingRecurrence.createVKey()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReservedList persistReservedList(String listName, String... lines) {
|
|
||||||
return persistReservedList(listName, true, lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ReservedList persistReservedList(ReservedList reservedList) {
|
public static ReservedList persistReservedList(ReservedList reservedList) {
|
||||||
ReservedListDao.save(reservedList);
|
ReservedListDao.save(reservedList);
|
||||||
maybeAdvanceClock();
|
maybeAdvanceClock();
|
||||||
return reservedList;
|
return reservedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReservedList persistReservedList(
|
public static ReservedList persistReservedList(String listName, String... lines) {
|
||||||
String listName, boolean shouldPublish, String... lines) {
|
|
||||||
ReservedList reservedList =
|
ReservedList reservedList =
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName(listName)
|
.setName(listName)
|
||||||
.setReservedListMapFromLines(ImmutableList.copyOf(lines))
|
.setReservedListMapFromLines(ImmutableList.copyOf(lines))
|
||||||
.setShouldPublish(shouldPublish)
|
|
||||||
.setCreationTimestamp(DateTime.now(DateTimeZone.UTC))
|
.setCreationTimestamp(DateTime.now(DateTimeZone.UTC))
|
||||||
.build();
|
.build();
|
||||||
return persistReservedList(reservedList);
|
return persistReservedList(reservedList);
|
||||||
|
|
|
@ -97,12 +97,10 @@ abstract class CreateOrUpdateReservedListCommandTestCase<
|
||||||
ReservedList createCloudSqlReservedList(
|
ReservedList createCloudSqlReservedList(
|
||||||
String name,
|
String name,
|
||||||
DateTime creationTime,
|
DateTime creationTime,
|
||||||
boolean shouldPublish,
|
|
||||||
ImmutableMap<String, ReservedListEntry> labelsToEntries) {
|
ImmutableMap<String, ReservedListEntry> labelsToEntries) {
|
||||||
return new ReservedList.Builder()
|
return new ReservedList.Builder()
|
||||||
.setName(name)
|
.setName(name)
|
||||||
.setCreationTimestamp(creationTime)
|
.setCreationTimestamp(creationTime)
|
||||||
.setShouldPublish(shouldPublish)
|
|
||||||
.setReservedListMap(labelsToEntries)
|
.setReservedListMap(labelsToEntries)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,27 +56,6 @@ class CreateReservedListCommandTest
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSuccess_shouldPublishDefaultsToTrue() throws Exception {
|
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSuccess_shouldPublishSetToTrue_works() throws Exception {
|
|
||||||
runCommandForced("--input=" + reservedTermsPath, "--should_publish=true");
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSuccess_shouldPublishSetToFalse_works() throws Exception {
|
|
||||||
runCommandForced("--input=" + reservedTermsPath, "--should_publish=false");
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved").get().getShouldPublish()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testFailure_reservedListWithThatNameAlreadyExists() {
|
void testFailure_reservedListWithThatNameAlreadyExists() {
|
||||||
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED");
|
||||||
|
|
|
@ -37,16 +37,15 @@ class UpdateReservedListCommandTest
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
populateInitialReservedListInDatabase(true);
|
populateInitialReservedListInDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateInitialReservedListInDatabase(boolean shouldPublish) {
|
private void populateInitialReservedListInDatabase() {
|
||||||
persistReservedList(
|
persistReservedList(
|
||||||
new ReservedList.Builder()
|
new ReservedList.Builder()
|
||||||
.setName("xn--q9jyb4c_common-reserved")
|
.setName("xn--q9jyb4c_common-reserved")
|
||||||
.setReservedListMapFromLines(ImmutableList.of("helicopter,FULLY_BLOCKED"))
|
.setReservedListMapFromLines(ImmutableList.of("helicopter,FULLY_BLOCKED"))
|
||||||
.setCreationTimestamp(START_OF_TIME)
|
.setCreationTimestamp(START_OF_TIME)
|
||||||
.setShouldPublish(shouldPublish)
|
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,25 +59,6 @@ class UpdateReservedListCommandTest
|
||||||
runSuccessfulUpdateTest("--input=" + reservedTermsPath);
|
runSuccessfulUpdateTest("--input=" + reservedTermsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSuccess_shouldPublish_setToFalseCorrectly() throws Exception {
|
|
||||||
runSuccessfulUpdateTest("--input=" + reservedTermsPath, "--should_publish=false");
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
|
||||||
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
|
||||||
assertThat(reservedList.getShouldPublish()).isFalse();
|
|
||||||
assertInStdout("Update reserved list for xn--q9jyb4c_common-reserved?");
|
|
||||||
assertInStdout("shouldPublish: true -> false");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSuccess_shouldPublish_doesntOverrideFalseIfNotSpecified() throws Exception {
|
|
||||||
populateInitialReservedListInDatabase(false);
|
|
||||||
runCommandForced("--input=" + reservedTermsPath);
|
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
|
||||||
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
|
||||||
assertThat(reservedList.getShouldPublish()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runSuccessfulUpdateTest(String... args) throws Exception {
|
private void runSuccessfulUpdateTest(String... args) throws Exception {
|
||||||
runCommandForced(args);
|
runCommandForced(args);
|
||||||
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
|
@ -133,11 +113,9 @@ class UpdateReservedListCommandTest
|
||||||
// CreateOrUpdateReservedListCommandTestCases.java
|
// CreateOrUpdateReservedListCommandTestCases.java
|
||||||
UpdateReservedListCommand command = new UpdateReservedListCommand();
|
UpdateReservedListCommand command = new UpdateReservedListCommand();
|
||||||
command.input = Paths.get(reservedTermsPath);
|
command.input = Paths.get(reservedTermsPath);
|
||||||
command.shouldPublish = false;
|
|
||||||
command.init();
|
command.init();
|
||||||
|
|
||||||
assertThat(command.prompt()).contains("Update reserved list for xn--q9jyb4c_common-reserved?");
|
assertThat(command.prompt()).contains("Update reserved list for xn--q9jyb4c_common-reserved?");
|
||||||
assertThat(command.prompt()).contains("shouldPublish: true -> false");
|
|
||||||
assertThat(command.prompt()).contains("helicopter: helicopter,FULLY_BLOCKED -> null");
|
assertThat(command.prompt()).contains("helicopter: helicopter,FULLY_BLOCKED -> null");
|
||||||
assertThat(command.prompt()).contains("baddies: null -> baddies,FULLY_BLOCKED");
|
assertThat(command.prompt()).contains("baddies: null -> baddies,FULLY_BLOCKED");
|
||||||
assertThat(command.prompt()).contains("ford: null -> ford,FULLY_BLOCKED # random comment");
|
assertThat(command.prompt()).contains("ford: null -> ford,FULLY_BLOCKED # random comment");
|
||||||
|
|
|
@ -31,8 +31,8 @@ class ListReservedListsActionTest extends ListActionTestCase {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
ReservedList rl1 = persistReservedList("xn--q9jyb4c-published", true, "blah,FULLY_BLOCKED");
|
ReservedList rl1 = persistReservedList("xn--q9jyb4c-published", "blah,FULLY_BLOCKED");
|
||||||
ReservedList rl2 = persistReservedList("xn--q9jyb4c-private", false, "dugong,FULLY_BLOCKED");
|
ReservedList rl2 = persistReservedList("xn--q9jyb4c-private", "dugong,FULLY_BLOCKED");
|
||||||
createTld("xn--q9jyb4c");
|
createTld("xn--q9jyb4c");
|
||||||
persistResource(Tld.get("xn--q9jyb4c").asBuilder().setReservedLists(rl1, rl2).build());
|
persistResource(Tld.get("xn--q9jyb4c").asBuilder().setReservedLists(rl1, rl2).build());
|
||||||
action = new ListReservedListsAction();
|
action = new ListReservedListsAction();
|
||||||
|
@ -53,13 +53,13 @@ class ListReservedListsActionTest extends ListActionTestCase {
|
||||||
void testRun_withParameters() {
|
void testRun_withParameters() {
|
||||||
testRunSuccess(
|
testRunSuccess(
|
||||||
action,
|
action,
|
||||||
Optional.of("shouldPublish"),
|
Optional.of("revisionId"),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
"^name\\s+shouldPublish\\s*$",
|
"^name\\s+revisionId\\s*$",
|
||||||
"^-+\\s+-+\\s*$",
|
"^-+\\s+-+\\s*$",
|
||||||
"^xn--q9jyb4c-private\\s+false\\s*$",
|
"^xn--q9jyb4c-private\\s+2\\s*$",
|
||||||
"^xn--q9jyb4c-published\\s+true\\s*$");
|
"^xn--q9jyb4c-published\\s+1\\s*$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -71,8 +71,8 @@ class ListReservedListsActionTest extends ListActionTestCase {
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
"^name\\s+.*shouldPublish.*",
|
"^name\\s+.*shouldPublish.*",
|
||||||
"^-+\\s+-+",
|
"^-+\\s+-+",
|
||||||
"^xn--q9jyb4c-private\\s+.*false",
|
"^xn--q9jyb4c-private\\s+.*",
|
||||||
"^xn--q9jyb4c-published\\s+.*true");
|
"^xn--q9jyb4c-published\\s+.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -261,11 +261,11 @@ td.section {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="property_name">generated on</td>
|
<td class="property_name">generated on</td>
|
||||||
<td class="property_value">2024-01-29 21:20:38.361551592</td>
|
<td class="property_value">2024-02-27 19:20:22.44744298</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="property_name">last flyway file</td>
|
<td class="property_name">last flyway file</td>
|
||||||
<td id="lastFlywayFile" class="property_value">V154__add_create_billing_cost_transitions_to_tld.sql</td>
|
<td id="lastFlywayFile" class="property_value">V155__reserved_list_null_should_publish.sql</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -277,11 +277,11 @@ td.section {
|
||||||
SchemaCrawler_Diagram
|
SchemaCrawler_Diagram
|
||||||
</title>
|
</title>
|
||||||
<polygon fill="white" stroke="transparent" points="-4,4 -4,-3205 4025,-3205 4025,4 -4,4" />
|
<polygon fill="white" stroke="transparent" points="-4,4 -4,-3205 4025,-3205 4025,4 -4,4" />
|
||||||
<text text-anchor="start" x="3730.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
|
<text text-anchor="start" x="3737" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
|
||||||
<text text-anchor="start" x="3813.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
|
<text text-anchor="start" x="3820" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
|
||||||
<text text-anchor="start" x="3729.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
|
<text text-anchor="start" x="3736" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
|
||||||
<text text-anchor="start" x="3813.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-01-29 21:20:38.361551592</text>
|
<text text-anchor="start" x="3820" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-02-27 19:20:22.44744298</text>
|
||||||
<polygon fill="none" stroke="#888888" points="3726,-4 3726,-44 4013,-44 4013,-4 3726,-4" /> <!-- allocationtoken_a08ccbef -->
|
<polygon fill="none" stroke="#888888" points="3733,-4 3733,-44 4013,-44 4013,-4 3733,-4" /> <!-- allocationtoken_a08ccbef -->
|
||||||
<g id="node1" class="node">
|
<g id="node1" class="node">
|
||||||
<title>
|
<title>
|
||||||
allocationtoken_a08ccbef
|
allocationtoken_a08ccbef
|
||||||
|
|
|
@ -261,11 +261,11 @@ td.section {
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="property_name">generated on</td>
|
<td class="property_name">generated on</td>
|
||||||
<td class="property_value">2024-01-29 21:20:36.077463726</td>
|
<td class="property_value">2024-02-27 19:20:20.412729849</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="property_name">last flyway file</td>
|
<td class="property_name">last flyway file</td>
|
||||||
<td id="lastFlywayFile" class="property_value">V154__add_create_billing_cost_transitions_to_tld.sql</td>
|
<td id="lastFlywayFile" class="property_value">V155__reserved_list_null_should_publish.sql</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -280,7 +280,7 @@ td.section {
|
||||||
<text text-anchor="start" x="4414.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
|
<text text-anchor="start" x="4414.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
|
||||||
<text text-anchor="start" x="4497.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
|
<text text-anchor="start" x="4497.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
|
||||||
<text text-anchor="start" x="4413.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
|
<text text-anchor="start" x="4413.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
|
||||||
<text text-anchor="start" x="4497.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-01-29 21:20:36.077463726</text>
|
<text text-anchor="start" x="4497.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-02-27 19:20:20.412729849</text>
|
||||||
<polygon fill="none" stroke="#888888" points="4410,-4 4410,-44 4697,-44 4697,-4 4410,-4" /> <!-- allocationtoken_a08ccbef -->
|
<polygon fill="none" stroke="#888888" points="4410,-4 4410,-44 4697,-44 4697,-4 4410,-4" /> <!-- allocationtoken_a08ccbef -->
|
||||||
<g id="node1" class="node">
|
<g id="node1" class="node">
|
||||||
<title>
|
<title>
|
||||||
|
@ -3488,7 +3488,7 @@ td.section {
|
||||||
<text text-anchor="start" x="3788.5" y="-6614.3" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text>
|
<text text-anchor="start" x="3788.5" y="-6614.3" font-family="Helvetica,sans-Serif" font-size="14.00">text not null</text>
|
||||||
<text text-anchor="start" x="3655.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00">should_publish</text>
|
<text text-anchor="start" x="3655.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00">should_publish</text>
|
||||||
<text text-anchor="start" x="3779.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00"> </text>
|
<text text-anchor="start" x="3779.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00"> </text>
|
||||||
<text text-anchor="start" x="3788.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00">bool not null</text>
|
<text text-anchor="start" x="3788.5" y="-6595.3" font-family="Helvetica,sans-Serif" font-size="14.00">bool</text>
|
||||||
<polygon fill="none" stroke="#888888" points="3652,-6588.5 3652,-6704.5 3913,-6704.5 3913,-6588.5 3652,-6588.5" />
|
<polygon fill="none" stroke="#888888" points="3652,-6588.5 3652,-6704.5 3913,-6704.5 3913,-6588.5 3652,-6588.5" />
|
||||||
</g> <!-- reservedentry_1a7b8520->reservedlist_b97c3f1c -->
|
</g> <!-- reservedentry_1a7b8520->reservedlist_b97c3f1c -->
|
||||||
<g id="edge78" class="edge">
|
<g id="edge78" class="edge">
|
||||||
|
@ -11012,7 +11012,7 @@ td.section {
|
||||||
<tr>
|
<tr>
|
||||||
<td class="spacer"></td>
|
<td class="spacer"></td>
|
||||||
<td class="minwidth">should_publish</td>
|
<td class="minwidth">should_publish</td>
|
||||||
<td class="minwidth">bool not null</td>
|
<td class="minwidth">bool</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="3"></td>
|
<td colspan="3"></td>
|
||||||
|
|
|
@ -152,3 +152,4 @@ V151__add_bsa_unblockable_domain_table.sql
|
||||||
V152__add_bsa_domain_refresh_table.sql
|
V152__add_bsa_domain_refresh_table.sql
|
||||||
V153__drop_bsa_domain_in_use_table.sql
|
V153__drop_bsa_domain_in_use_table.sql
|
||||||
V154__add_create_billing_cost_transitions_to_tld.sql
|
V154__add_create_billing_cost_transitions_to_tld.sql
|
||||||
|
V155__reserved_list_null_should_publish.sql
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- Copyright 2024 The Nomulus Authors. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
-- you may not use this file except in compliance with the License.
|
||||||
|
-- You may obtain a copy of the License at
|
||||||
|
--
|
||||||
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
--
|
||||||
|
-- Unless required by applicable law or agreed to in writing, software
|
||||||
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
-- See the License for the specific language governing permissions and
|
||||||
|
-- limitations under the License.
|
||||||
|
|
||||||
|
-- Note: we drop the not-null constraints from the history tables but we keep them in the
|
||||||
|
-- EPP resource tables since nothing inserted there should be null
|
||||||
|
|
||||||
|
ALTER TABLE "ReservedList" ALTER COLUMN should_publish DROP NOT NULL;
|
|
@ -693,7 +693,7 @@
|
||||||
revision_id bigserial not null,
|
revision_id bigserial not null,
|
||||||
creation_timestamp timestamptz,
|
creation_timestamp timestamptz,
|
||||||
name text not null,
|
name text not null,
|
||||||
should_publish boolean not null,
|
should_publish boolean,
|
||||||
primary key (revision_id)
|
primary key (revision_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1022,7 +1022,7 @@ CREATE TABLE public."ReservedList" (
|
||||||
revision_id bigint NOT NULL,
|
revision_id bigint NOT NULL,
|
||||||
creation_timestamp timestamp with time zone NOT NULL,
|
creation_timestamp timestamp with time zone NOT NULL,
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
should_publish boolean NOT NULL
|
should_publish boolean
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue