diff --git a/java/google/registry/model/OteAccountBuilder.java b/java/google/registry/model/OteAccountBuilder.java index 51bb077b8..0370e6097 100644 --- a/java/google/registry/model/OteAccountBuilder.java +++ b/java/google/registry/model/OteAccountBuilder.java @@ -113,27 +113,9 @@ public final class OteAccountBuilder { RegistryEnvironment.get() != RegistryEnvironment.PRODUCTION, "Can't setup OT&E in production"); clientIdToTld = createClientIdToTldMap(baseClientId); - sunriseTld = - createTld( - baseClientId + "-sunrise", TldState.START_DATE_SUNRISE, null, null, null, false, 0); - gaTld = - createTld( - baseClientId + "-ga", - TldState.GENERAL_AVAILABILITY, - SHORT_ADD_GRACE_PERIOD, - SHORT_REDEMPTION_GRACE_PERIOD, - SHORT_PENDING_DELETE_LENGTH, - false, - 2); - eapTld = - createTld( - baseClientId + "-eap", - TldState.GENERAL_AVAILABILITY, - SHORT_ADD_GRACE_PERIOD, - SHORT_REDEMPTION_GRACE_PERIOD, - SHORT_PENDING_DELETE_LENGTH, - true, - 3); + sunriseTld = createTld(baseClientId + "-sunrise", TldState.START_DATE_SUNRISE, false, 0); + gaTld = createTld(baseClientId + "-ga", TldState.GENERAL_AVAILABILITY, false, 2); + eapTld = createTld(baseClientId + "-eap", TldState.GENERAL_AVAILABILITY, true, 3); registrars = clientIdToTld.keySet().stream() .map(OteAccountBuilder::createRegistrar) @@ -294,9 +276,6 @@ public final class OteAccountBuilder { private static Registry createTld( String tldName, TldState initialTldState, - Duration addGracePeriod, - Duration redemptionGracePeriod, - Duration pendingDeleteLength, boolean isEarlyAccess, int roidSuffix) { String tldNameAlphaNumerical = tldName.replaceAll("[^a-z0-9]", ""); @@ -313,16 +292,10 @@ public final class OteAccountBuilder { String.format( "%S%X", tldNameAlphaNumerical.substring(0, Math.min(tldNameAlphaNumerical.length(), 7)), - roidSuffix)); - if (addGracePeriod != null) { - builder.setAddGracePeriodLength(addGracePeriod); - } - if (pendingDeleteLength != null) { - builder.setPendingDeleteLength(pendingDeleteLength); - } - if (redemptionGracePeriod != null) { - builder.setRedemptionGracePeriodLength(redemptionGracePeriod); - } + roidSuffix)) + .setAddGracePeriodLength(SHORT_ADD_GRACE_PERIOD) + .setPendingDeleteLength(SHORT_PENDING_DELETE_LENGTH) + .setRedemptionGracePeriodLength(SHORT_REDEMPTION_GRACE_PERIOD); if (isEarlyAccess) { builder.setEapFeeSchedule(EAP_FEE_SCHEDULE); } diff --git a/java/google/registry/model/OteStats.java b/java/google/registry/model/OteStats.java index 2822412a1..1e86febbb 100644 --- a/java/google/registry/model/OteStats.java +++ b/java/google/registry/model/OteStats.java @@ -114,7 +114,7 @@ public class OteStats { eppInput -> eppInput.getSingleExtension(FeeCreateCommandExtension.class).isPresent()), DOMAIN_CREATES_WITH_SEC_DNS(1, equalTo(Type.DOMAIN_CREATE), HAS_SEC_DNS), DOMAIN_CREATES_WITHOUT_SEC_DNS(0, equalTo(Type.DOMAIN_CREATE), HAS_SEC_DNS.negate()), - DOMAIN_DELETES(2, equalTo(Type.DOMAIN_DELETE)), + DOMAIN_DELETES(1, equalTo(Type.DOMAIN_DELETE)), DOMAIN_RENEWS(0, equalTo(Type.DOMAIN_RENEW)), DOMAIN_RESTORES(1, equalTo(Type.DOMAIN_RESTORE)), DOMAIN_TRANSFER_APPROVES(1, equalTo(Type.DOMAIN_TRANSFER_APPROVE)), diff --git a/javatests/google/registry/model/OteAccountBuilderTest.java b/javatests/google/registry/model/OteAccountBuilderTest.java index 1aac53f30..f022df3cd 100644 --- a/javatests/google/registry/model/OteAccountBuilderTest.java +++ b/javatests/google/registry/model/OteAccountBuilderTest.java @@ -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 diff --git a/javatests/google/registry/model/OteStatsTest.java b/javatests/google/registry/model/OteStatsTest.java index 6af75bdcb..502701277 100644 --- a/javatests/google/registry/model/OteStatsTest.java +++ b/javatests/google/registry/model/OteStatsTest.java @@ -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); } } diff --git a/javatests/google/registry/model/OteStatsTestHelper.java b/javatests/google/registry/model/OteStatsTestHelper.java index 6af145dd9..1c8eaab94 100644 --- a/javatests/google/registry/model/OteStatsTestHelper.java +++ b/javatests/google/registry/model/OteStatsTestHelper.java @@ -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()); diff --git a/javatests/google/registry/tools/SetupOteCommandTest.java b/javatests/google/registry/tools/SetupOteCommandTest.java index d75e2bfcd..ff4a3f2dc 100644 --- a/javatests/google/registry/tools/SetupOteCommandTest.java +++ b/javatests/google/registry/tools/SetupOteCommandTest.java @@ -66,9 +66,6 @@ public class SetupOteCommandTest extends CommandTestCase { String tldName, String roidSuffix, TldState tldState, - Duration addGracePeriodLength, - Duration redemptionGracePeriodLength, - Duration pendingDeleteLength, boolean isEarlyAccess) { Registry registry = Registry.get(tldName); assertThat(registry).isNotNull(); @@ -77,9 +74,9 @@ public class SetupOteCommandTest extends CommandTestCase { assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter"); assertThat(registry.getPremiumList()).isNotNull(); assertThat(registry.getPremiumList().getName()).isEqualTo("default_sandbox_list"); - assertThat(registry.getAddGracePeriodLength()).isEqualTo(addGracePeriodLength); - assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(redemptionGracePeriodLength); - assertThat(registry.getPendingDeleteLength()).isEqualTo(pendingDeleteLength); + assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardMinutes(60)); + assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(Duration.standardMinutes(10)); + assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardMinutes(5)); ImmutableSortedMap eapFeeSchedule = registry.getEapFeeScheduleAsMap(); if (!isEarlyAccess) { assertThat(eapFeeSchedule) @@ -97,19 +94,6 @@ public class SetupOteCommandTest extends CommandTestCase { } } - /** Verify TLD creation with registry default durations. */ - private void verifyTldCreation( - String tldName, String roidSuffix, TldState tldState) { - verifyTldCreation( - tldName, - roidSuffix, - tldState, - Registry.DEFAULT_ADD_GRACE_PERIOD, - Registry.DEFAULT_REDEMPTION_GRACE_PERIOD, - Registry.DEFAULT_PENDING_DELETE_LENGTH, - false); - } - private void verifyRegistrarCreation( String registrarName, String allowedTld, @@ -156,22 +140,9 @@ public class SetupOteCommandTest extends CommandTestCase { "--email=contact@email.com", "--certfile=" + getCertFilename()); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE); - verifyTldCreation("blobio-ga", - "BLOBIOG2", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - false); - verifyTldCreation( - "blobio-eap", - "BLOBIOE3", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - true); + verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE, false); + verifyTldCreation("blobio-ga", "BLOBIOG2", GENERAL_AVAILABILITY, false); + verifyTldCreation("blobio-eap", "BLOBIOE3", GENERAL_AVAILABILITY, true); ImmutableList ipAddress = ImmutableList.of( CidrAddressBlock.create("1.1.1.1")); @@ -195,22 +166,9 @@ public class SetupOteCommandTest extends CommandTestCase { "--email=abc@email.com", "--certfile=" + getCertFilename()); - verifyTldCreation("abc-sunrise", "ABCSUNR0", START_DATE_SUNRISE); - verifyTldCreation("abc-ga", - "ABCGA2", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - false); - verifyTldCreation( - "abc-eap", - "ABCEAP3", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - true); + verifyTldCreation("abc-sunrise", "ABCSUNR0", START_DATE_SUNRISE, false); + verifyTldCreation("abc-ga", "ABCGA2", GENERAL_AVAILABILITY, false); + verifyTldCreation("abc-eap", "ABCEAP3", GENERAL_AVAILABILITY, true); ImmutableList ipAddress = ImmutableList.of(CidrAddressBlock.create("1.1.1.1")); @@ -234,14 +192,7 @@ public class SetupOteCommandTest extends CommandTestCase { "--email=contact@email.com", "--certhash=" + SAMPLE_CERT_HASH); - verifyTldCreation( - "blobio-eap", - "BLOBIOE3", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - true); + verifyTldCreation("blobio-eap", "BLOBIOE3", GENERAL_AVAILABILITY, true); ImmutableList ipAddress = ImmutableList.of(CidrAddressBlock.create("1.1.1.1")); @@ -259,23 +210,9 @@ public class SetupOteCommandTest extends CommandTestCase { "--email=contact@email.com", "--certfile=" + getCertFilename()); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE); - verifyTldCreation( - "blobio-ga", - "BLOBIOG2", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - false); - verifyTldCreation( - "blobio-eap", - "BLOBIOE3", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - true); + verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE, false); + verifyTldCreation("blobio-ga", "BLOBIOG2", GENERAL_AVAILABILITY, false); + verifyTldCreation("blobio-eap", "BLOBIOE3", GENERAL_AVAILABILITY, true); ImmutableList ipAddresses = ImmutableList.of( CidrAddressBlock.create("1.1.1.1"), @@ -461,15 +398,8 @@ public class SetupOteCommandTest extends CommandTestCase { "--email=contact@email.com", "--certfile=" + getCertFilename()); - verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE); - verifyTldCreation( - "blobio-ga", - "BLOBIOG2", - GENERAL_AVAILABILITY, - Duration.standardMinutes(60), - Duration.standardMinutes(10), - Duration.standardMinutes(5), - false); + verifyTldCreation("blobio-sunrise", "BLOBIOS0", START_DATE_SUNRISE, false); + verifyTldCreation("blobio-ga", "BLOBIOG2", GENERAL_AVAILABILITY, false); } @Test diff --git a/javatests/google/registry/tools/server/VerifyOteActionTest.java b/javatests/google/registry/tools/server/VerifyOteActionTest.java index 450328967..881a4b8d7 100644 --- a/javatests/google/registry/tools/server/VerifyOteActionTest.java +++ b/javatests/google/registry/tools/server/VerifyOteActionTest.java @@ -44,7 +44,7 @@ public class VerifyOteActionTest { @Test public void testSuccess_summarize_allPass() { assertThat(getResponse(true)) - .isEqualTo("# actions: 31 - Reqs: [----------------] 16/16 - Overall: PASS"); + .isEqualTo("# actions: 30 - Reqs: [----------------] 16/16 - Overall: PASS"); } @Test @@ -53,7 +53,7 @@ public class VerifyOteActionTest { OteStatsTestHelper.deleteDomainRestoreHistoryEntry(); OteStatsTestHelper.deleteHostDeleteHistoryEntry(); assertThat(getResponse(true)) - .isEqualTo("# actions: 35 - Reqs: [-.-----.------.-] 13/16 - Overall: FAIL"); + .isEqualTo("# actions: 34 - Reqs: [-.-----.------.-] 13/16 - Overall: FAIL"); } @Test @@ -65,7 +65,7 @@ public class VerifyOteActionTest { + "domain creates with fee: 1\n" + "domain creates with sec dns: 1\n" + ".*" - + "domain deletes: 2\n" + + "domain deletes: 1\n" + ".*" + "domain restores: 1\n" + "domain transfer approves: 1\n" @@ -95,7 +95,7 @@ public class VerifyOteActionTest { + "domain creates with fee: 1\n" + "domain creates with sec dns: 1\n" + ".*" - + "domain deletes: 2\n" + + "domain deletes: 1\n" + ".*" + "domain restores: 1\n" + "domain transfer approves: 1\n"