Remove old DomainList fields from Registry (#1231)

* Remove old DomainList fields from Registry

I also resaved all Registry objects in sandbox and production to make sure that the new field is populated on all entity objects.

* small fixes

* Some more small fixes

* Delete commented out code

* Remove existence check in tests
This commit is contained in:
sarahcaseybot
2021-07-08 17:19:11 -04:00
committed by GitHub
parent f5d344d5c9
commit d283cf1c90
17 changed files with 79 additions and 152 deletions
@@ -70,8 +70,7 @@ public final class OteAccountBuilderTest {
private void assertTldExists(String tld, TldState tldState, Money eapFee) {
Registry registry = Registry.get(tld);
assertThat(registry).isNotNull();
assertThat(registry.getPremiumList()).isPresent();
assertThat(registry.getPremiumList().get().getName()).isEqualTo("default_sandbox_list");
assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list");
assertThat(registry.getTldStateTransitions()).containsExactly(START_OF_TIME, tldState);
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardHours(1));
@@ -36,7 +36,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.dns.writer.VoidDnsWriter;
import google.registry.model.EntityTestCase;
import google.registry.model.registry.Registry.RegistryNotFoundException;
@@ -162,18 +161,18 @@ public final class RegistryTest extends EntityTestCase {
.asBuilder()
.setReservedLists(ImmutableSet.of(rl15))
.build();
assertThat(registry1.getReservedLists()).hasSize(1);
assertThat(registry1.getReservedListNames()).hasSize(1);
Registry registry2 =
registry1.asBuilder().setReservedLists(ImmutableSet.of(rl15, rl16)).build();
assertThat(registry1.getReservedLists()).hasSize(1);
assertThat(registry2.getReservedLists()).hasSize(2);
assertThat(registry1.getReservedListNames()).hasSize(1);
assertThat(registry2.getReservedListNames()).hasSize(2);
}
@TestOfyAndSql
void testGetReservedLists_doesntReturnNullWhenUninitialized() {
Registry registry = newRegistry("foo", "FOO");
assertThat(registry.getReservedLists()).isNotNull();
assertThat(registry.getReservedLists()).isEmpty();
assertThat(registry.getReservedListNames()).isNotNull();
assertThat(registry.getReservedListNames()).isEmpty();
}
@TestOfyAndSql
@@ -211,10 +210,9 @@ public final class RegistryTest extends EntityTestCase {
.build());
Registry r =
Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build();
assertThat(r.getReservedLists().stream().map(Key::getName))
.containsExactly("tld-reserved5", "tld-reserved6");
assertThat(r.getReservedListNames()).containsExactly("tld-reserved5", "tld-reserved6");
r = Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of()).build();
assertThat(r.getReservedLists()).isEmpty();
assertThat(r.getReservedListNames()).isEmpty();
}
@TestOfyAndSql
@@ -240,19 +238,18 @@ public final class RegistryTest extends EntityTestCase {
.asBuilder()
.setReservedListsByName(ImmutableSet.of("tld-reserved15", "tld-reserved16"))
.build();
assertThat(r.getReservedLists().stream().map(Key::getName))
.containsExactly("tld-reserved15", "tld-reserved16");
assertThat(r.getReservedListNames()).containsExactly("tld-reserved15", "tld-reserved16");
r = Registry.get("tld").asBuilder().setReservedListsByName(ImmutableSet.of()).build();
assertThat(r.getReservedLists()).isEmpty();
assertThat(r.getReservedListNames()).isEmpty();
}
@TestOfyAndSql
void testSetPremiumList() {
PremiumList pl2 = persistPremiumList("tld2", "lol,USD 50", "cat,USD 700");
Registry registry = Registry.get("tld").asBuilder().setPremiumList(pl2).build();
Optional<Key<PremiumList>> plKey = registry.getPremiumList();
assertThat(plKey).isPresent();
PremiumList stored = PremiumListDao.getLatestRevision(plKey.get().getName()).get();
Optional<String> pl = registry.getPremiumListName();
assertThat(pl).hasValue("tld2");
PremiumList stored = PremiumListDao.getLatestRevision(pl.get()).get();
assertThat(stored.getName()).isEqualTo("tld2");
}
@@ -86,7 +86,7 @@ class ReservedListTest {
@Test
void testGetReservationTypes_allLabelsAreUnreserved_withNoReservedLists() {
assertThat(Registry.get("tld").getReservedLists()).isEmpty();
assertThat(Registry.get("tld").getReservedListNames()).isEmpty();
assertThat(getReservationTypes("doodle", "tld")).isEmpty();
assertThat(getReservationTypes("access", "tld")).isEmpty();
assertThat(getReservationTypes("rich", "tld")).isEmpty();
@@ -16,7 +16,6 @@ package google.registry.schema.tld;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
import static google.registry.testing.DatabaseHelper.newRegistry;
@@ -27,7 +26,6 @@ import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import google.registry.model.registry.label.PremiumList;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
@@ -203,22 +201,16 @@ public class PremiumListDaoTest {
@Test
void getPremiumPrice_worksSuccessfully() {
PremiumList premiumList =
PremiumListDao.save(
new PremiumList.Builder()
.setName("premlist")
.setCurrency(USD)
.setLabelsToPrices(TEST_PRICES)
.setCreationTime(fakeClock.nowUtc())
.build());
persistResource(
newRegistry("foobar", "FOOBAR")
.asBuilder()
.setPremiumListKey(
Key.create(
getCrossTldKey(),
google.registry.model.registry.label.PremiumList.class,
"premlist"))
.build());
PremiumListDao.save(
new PremiumList.Builder()
.setName("premlist")
.setCurrency(USD)
.setLabelsToPrices(TEST_PRICES)
.setCreationTime(fakeClock.nowUtc())
.build());
newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build());
assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(Money.of(USD, 10.23));
assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(Money.of(USD, 1305.47));
assertThat(PremiumListDao.getPremiumPrice("premlist", "zirconium")).isEmpty();
@@ -226,29 +218,23 @@ public class PremiumListDaoTest {
@Test
void testGetPremiumPrice_worksForJPY() {
PremiumList premiumList =
PremiumListDao.save(
new PremiumList.Builder()
.setName("premlist")
.setCurrency(JPY)
.setLabelsToPrices(
ImmutableMap.of(
"silver",
BigDecimal.valueOf(10.00),
"gold",
BigDecimal.valueOf(1000.0),
"palladium",
BigDecimal.valueOf(15000)))
.setCreationTime(fakeClock.nowUtc())
.build());
persistResource(
newRegistry("foobar", "FOOBAR")
.asBuilder()
.setPremiumListKey(
Key.create(
getCrossTldKey(),
google.registry.model.registry.label.PremiumList.class,
"premlist"))
.build());
PremiumListDao.save(
new PremiumList.Builder()
.setName("premlist")
.setCurrency(JPY)
.setLabelsToPrices(
ImmutableMap.of(
"silver",
BigDecimal.valueOf(10.00),
"gold",
BigDecimal.valueOf(1000.0),
"palladium",
BigDecimal.valueOf(15000)))
.setCreationTime(fakeClock.nowUtc())
.build());
newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build());
assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(moneyOf(JPY, 10));
assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(moneyOf(JPY, 1000));
assertThat(PremiumListDao.getPremiumPrice("premlist", "palladium"))
@@ -32,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range;
import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry;
import java.math.BigDecimal;
import org.joda.money.Money;
@@ -279,7 +278,7 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
"--roid_suffix=Q9JYB4C",
"--dns_writers=VoidDnsWriter",
"xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
.containsExactly("xn--q9jyb4c_abuse", "common_abuse");
}
@@ -519,9 +518,7 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
"--roid_suffix=Q9JYB4C",
"--dns_writers=FooDnsWriter",
"xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isPresent();
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().get().getName())
.isEqualTo("xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c");
}
@Test
@@ -72,8 +72,7 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
assertThat(registry.getRoidSuffix()).isEqualTo(roidSuffix);
assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(tldState);
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
assertThat(registry.getPremiumList()).isNotNull();
assertThat(registry.getPremiumList().get().getName()).isEqualTo("default_sandbox_list");
assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list");
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardMinutes(60));
assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(Duration.standardMinutes(10));
assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardMinutes(5));
@@ -35,9 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry;
import google.registry.model.registry.label.PremiumList;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -254,7 +252,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
void testSuccess_setReservedLists() throws Exception {
runCommandForced("--reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@@ -264,7 +262,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
.containsExactly("xn--q9jyb4c_r2");
}
@@ -274,7 +272,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1"))
.build());
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@@ -284,7 +282,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists()).isEmpty();
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()).isEmpty();
}
@Test
@@ -293,7 +291,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
.containsExactly("xn--q9jyb4c_r2");
}
@@ -839,21 +837,20 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
void testSuccess_removePremiumListWithNull() throws Exception {
runCommandForced("--premium_list=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isEmpty();
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty();
}
@Test
void testSuccess_removePremiumListWithBlank() throws Exception {
runCommandForced("--premium_list=", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isEmpty();
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty();
}
@Test
void testSuccess_premiumListNotRemovedWhenNotSpecified() throws Exception {
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
Optional<Key<PremiumList>> premiumListKey = Registry.get("xn--q9jyb4c").getPremiumList();
assertThat(premiumListKey).isPresent();
assertThat(premiumListKey.get().getName()).isEqualTo("xn--q9jyb4c");
Optional<String> premiumListName = Registry.get("xn--q9jyb4c").getPremiumListName();
assertThat(premiumListName).hasValue("xn--q9jyb4c");
}
@Test
@@ -921,9 +918,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
@Test
void testSuccess_setPremiumList() throws Exception {
runCommandForced("--premium_list=xn--q9jyb4c", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isPresent();
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().get().getName())
.isEqualTo("xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c");
}
@Test
@@ -658,7 +658,6 @@ class google.registry.model.registry.Registry {
boolean dnsPaused;
boolean escrowEnabled;
boolean invoicingEnabled;
com.googlecode.objectify.Key<google.registry.model.registry.label.PremiumList> premiumList;
google.registry.model.CreateAutoTimestamp creationTime;
google.registry.model.common.TimedTransitionProperty<google.registry.model.registry.Registry$TldState, google.registry.model.registry.Registry$TldStateTransition> tldStateTransitions;
google.registry.model.common.TimedTransitionProperty<org.joda.money.Money, google.registry.model.registry.Registry$BillingCostTransition> eapFeeSchedule;
@@ -672,7 +671,6 @@ class google.registry.model.registry.Registry {
java.lang.String roidSuffix;
java.lang.String tldStr;
java.lang.String tldUnicode;
java.util.Set<com.googlecode.objectify.Key<google.registry.model.registry.label.ReservedList>> reservedLists;
java.util.Set<java.lang.String> allowedFullyQualifiedHostNames;
java.util.Set<java.lang.String> allowedRegistrantContactIds;
java.util.Set<java.lang.String> dnsWriters;