Set short redemption/add/delete periods for all OT&E TLDs

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228791942
This commit is contained in:
guyben 2019-01-10 15:46:30 -08:00 committed by Ben McIlwain
parent 765e63e7e9
commit a4fca18657
7 changed files with 64 additions and 164 deletions

View file

@ -17,6 +17,7 @@ package google.registry.model;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.testing.AppEngineRule.makeRegistrar1;
import static google.registry.testing.CertificateSamples.SAMPLE_CERT;
import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
@ -65,25 +66,12 @@ public final class OteAccountBuilderTest {
persistPremiumList("default_sandbox_list", "sandbox,USD 1000");
}
private void assertTldExists(String tld, Registry.TldState tldState) {
private void assertTldExists(String tld, TldState tldState, Money eapFee) {
Registry registry = Registry.get(tld);
assertThat(registry).isNotNull();
assertThat(registry.getPremiumList().getName()).isEqualTo("default_sandbox_list");
assertThat(registry.getTldStateTransitions()).containsExactly(START_OF_TIME, tldState);
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardDays(5));
assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardDays(5));
assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(Duration.standardDays(30));
assertThat(registry.getEapFeeScheduleAsMap()).containsExactly(START_OF_TIME, Money.zero(USD));
}
private void assertTldExistsGa(String tld, Money eapFee) {
Registry registry = Registry.get(tld);
assertThat(registry).isNotNull();
assertThat(registry.getPremiumList().getName()).isEqualTo("default_sandbox_list");
assertThat(registry.getTldStateTransitions())
.containsExactly(START_OF_TIME, GENERAL_AVAILABILITY);
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardHours(1));
assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardMinutes(5));
assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(Duration.standardMinutes(10));
@ -119,9 +107,9 @@ public final class OteAccountBuilderTest {
public void testCreateOteEntities_success() {
OteAccountBuilder.forClientId("myclientid").addContact("email@example.com").buildAndPersist();
assertTldExists("myclientid-sunrise", TldState.START_DATE_SUNRISE);
assertTldExistsGa("myclientid-ga", Money.zero(USD));
assertTldExistsGa("myclientid-eap", Money.of(USD, 100));
assertTldExists("myclientid-sunrise", START_DATE_SUNRISE, Money.zero(USD));
assertTldExists("myclientid-ga", GENERAL_AVAILABILITY, Money.zero(USD));
assertTldExists("myclientid-eap", GENERAL_AVAILABILITY, Money.of(USD, 100));
assertRegistrarExists("myclientid-1", "myclientid-sunrise");
assertRegistrarExists("myclientid-3", "myclientid-ga");
assertRegistrarExists("myclientid-4", "myclientid-ga");
@ -140,9 +128,9 @@ public final class OteAccountBuilderTest {
.addContact("someone@example.com")
.buildAndPersist();
assertTldExists("myclientid-sunrise", TldState.START_DATE_SUNRISE);
assertTldExistsGa("myclientid-ga", Money.zero(USD));
assertTldExistsGa("myclientid-eap", Money.of(USD, 100));
assertTldExists("myclientid-sunrise", START_DATE_SUNRISE, Money.zero(USD));
assertTldExists("myclientid-ga", GENERAL_AVAILABILITY, Money.zero(USD));
assertTldExists("myclientid-eap", GENERAL_AVAILABILITY, Money.of(USD, 100));
assertRegistrarExists("myclientid-1", "myclientid-sunrise");
assertRegistrarExists("myclientid-3", "myclientid-ga");
assertRegistrarExists("myclientid-4", "myclientid-ga");
@ -237,8 +225,9 @@ public final class OteAccountBuilderTest {
}
@Test
public void testCreateOteEntities_entityExists_failsWhenNotReplaceExisting() {
public void testCreateOteEntities_registrarExists_failsWhenNotReplaceExisting() {
persistSimpleResource(makeRegistrar1().asBuilder().setClientId("myclientid-1").build());
OteAccountBuilder oteSetupHelper = OteAccountBuilder.forClientId("myclientid");
assertThat(assertThrows(IllegalStateException.class, () -> oteSetupHelper.buildAndPersist()))
@ -247,15 +236,29 @@ public final class OteAccountBuilderTest {
}
@Test
public void testCreateOteEntities_entityExists_succeedsWhenReplaceExisting() {
persistSimpleResource(makeRegistrar1().asBuilder().setClientId("myclientid-4").build());
createTld("myclientid-ga", GENERAL_AVAILABILITY);
public void testCreateOteEntities_tldExists_failsWhenNotReplaceExisting() {
createTld("myclientid-ga", START_DATE_SUNRISE);
OteAccountBuilder oteSetupHelper = OteAccountBuilder.forClientId("myclientid");
assertThat(assertThrows(IllegalStateException.class, () -> oteSetupHelper.buildAndPersist()))
.hasMessageThat()
.contains("Found existing object(s) conflicting with OT&E objects");
}
@Test
public void testCreateOteEntities_entitiesExist_succeedsWhenReplaceExisting() {
persistSimpleResource(makeRegistrar1().asBuilder().setClientId("myclientid-1").build());
// we intentionally create the -ga TLD with the wrong state, to make sure it's overwritten.
createTld("myclientid-ga", START_DATE_SUNRISE);
OteAccountBuilder.forClientId("myclientid").setReplaceExisting(true).buildAndPersist();
assertTldExistsGa("myclientid-ga", Money.zero(USD));
// Just checking a sample of the resulting entities to make sure it indeed succeeded. The full
// entities are checked in other tests
assertTldExists("myclientid-ga", GENERAL_AVAILABILITY, Money.zero(USD));
assertRegistrarExists("myclientid-1", "myclientid-sunrise");
assertRegistrarExists("myclientid-3", "myclientid-ga");
assertRegistrarExists("myclientid-4", "myclientid-ga");
}
@Test

View file

@ -38,7 +38,7 @@ public final class OteStatsTest {
public void testSuccess_allPass() {
OteStats stats = OteStats.getFromRegistrar("blobio");
assertThat(stats.getFailures()).isEmpty();
assertThat(stats.getSize()).isEqualTo(31);
assertThat(stats.getSize()).isEqualTo(30);
}
@Test
@ -51,7 +51,7 @@ public final class OteStatsTest {
.containsExactly(
StatType.DOMAIN_CREATES_IDN, StatType.DOMAIN_RESTORES, StatType.HOST_DELETES)
.inOrder();
assertThat(stats.getSize()).isEqualTo(35);
assertThat(stats.getSize()).isEqualTo(34);
}
@Test
@ -74,7 +74,7 @@ public final class OteStatsTest {
+ "domain creates with fee: 1\n"
+ "domain creates with sec dns: 1\n"
+ "domain creates without sec dns: 4\n"
+ "domain deletes: 2\n"
+ "domain deletes: 1\n"
+ "domain renews: 0\n"
+ "domain restores: 1\n"
+ "domain transfer approves: 1\n"
@ -90,7 +90,7 @@ public final class OteStatsTest {
+ "host deletes: 1\n"
+ "host updates: 1\n"
+ "unclassified flows: 0\n"
+ "TOTAL: 31";
+ "TOTAL: 30";
assertThat(stats.toString()).isEqualTo(expected);
}
@ -115,7 +115,7 @@ public final class OteStatsTest {
+ "domain creates with fee: 1\n"
+ "domain creates with sec dns: 1\n"
+ "domain creates without sec dns: 4\n"
+ "domain deletes: 2\n"
+ "domain deletes: 1\n"
+ "domain renews: 0\n"
+ "domain restores: 1\n"
+ "domain transfer approves: 1\n"
@ -131,7 +131,7 @@ public final class OteStatsTest {
+ "host deletes: 0\n"
+ "host updates: 10\n"
+ "unclassified flows: 0\n"
+ "TOTAL: 39";
+ "TOTAL: 38";
assertThat(stats.toString()).isEqualTo(expected);
}
}

View file

@ -70,12 +70,6 @@ public final class OteStatsTestHelper {
.setType(Type.DOMAIN_DELETE)
.setXmlBytes(getBytes("domain_delete.xml"))
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-3")
.setType(Type.DOMAIN_DELETE)
.setXmlBytes(getBytes("domain_delete.xml"))
.build());
domainRestoreHistoryEntry =
persistResource(
new HistoryEntry.Builder()
@ -109,13 +103,13 @@ public final class OteStatsTestHelper {
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-4")
.setClientId("blobio-1")
.setType(Type.DOMAIN_UPDATE)
.setXmlBytes(getBytes("domain_update_with_secdns.xml"))
.build());
persistResource(
new HistoryEntry.Builder()
.setClientId("blobio-5")
.setClientId("blobio-1")
.setType(Type.HOST_CREATE)
.setXmlBytes(getBytes("host_create_complete.xml"))
.build());