Skip to content

Commit 9e02f41

Browse files
committed
Enable Fee-1.0 extension in prod
This extension has been in Sandbox for more than a month.
1 parent 9544d70 commit 9e02f41

6 files changed

Lines changed: 77 additions & 9 deletions

File tree

core/src/main/java/google/registry/model/common/FeatureFlag.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public enum FeatureName {
6868
/** Feature flag name used for testing only. */
6969
TEST_FEATURE(FeatureStatus.INACTIVE),
7070

71+
/** True if Fee Extension 1.0 (RFC 8748) is enabled in production. */
72+
// TODO(b/159033801) Delete this flag after 1.0 is hardened in prod.
73+
FEE_EXTENSION_1_DOT_0_IN_PROD(FeatureStatus.INACTIVE),
74+
7175
/** If we're not requiring the presence of contact data on domain EPP commands. */
7276
MINIMUM_DATASET_CONTACTS_OPTIONAL(FeatureStatus.INACTIVE),
7377

core/src/main/java/google/registry/model/eppcommon/ProtocolDefinition.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616

1717
import static com.google.common.collect.ImmutableSet.toImmutableSet;
1818
import static com.google.common.collect.Maps.uniqueIndex;
19+
import static google.registry.model.common.FeatureFlag.FeatureName.FEE_EXTENSION_1_DOT_0_IN_PROD;
20+
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
1921

2022
import com.google.common.annotations.VisibleForTesting;
2123
import com.google.common.base.VerifyException;
2224
import com.google.common.collect.ImmutableMap;
2325
import com.google.common.collect.ImmutableSet;
26+
import google.registry.model.common.FeatureFlag;
2427
import google.registry.model.domain.fee06.FeeCheckCommandExtensionV06;
2528
import google.registry.model.domain.fee06.FeeCheckResponseExtensionV06;
2629
import google.registry.model.domain.fee11.FeeCheckCommandExtensionV11;
@@ -58,7 +61,7 @@ public class ProtocolDefinition {
5861
/** Enum representing which environments should have which service extensions enabled. */
5962
private enum ServiceExtensionVisibility {
6063
ALL,
61-
ONLY_IN_NON_PRODUCTION,
64+
FEE_1_DOT_0_EXTENSION_VISIBILITY,
6265
NONE
6366
}
6467

@@ -82,7 +85,7 @@ public enum ServiceExtension {
8285
FEE_1_00(
8386
FeeCheckCommandExtensionStdV1.class,
8487
FeeCheckResponseExtensionStdV1.class,
85-
ServiceExtensionVisibility.ONLY_IN_NON_PRODUCTION),
88+
ServiceExtensionVisibility.FEE_1_DOT_0_EXTENSION_VISIBILITY),
8689
METADATA_1_0(MetadataExtension.class, null, ServiceExtensionVisibility.NONE);
8790

8891
private final Class<? extends CommandExtension> commandExtensionClass;
@@ -138,8 +141,9 @@ public static String getCommandExtensionXmlTag(Class<? extends CommandExtension>
138141
public boolean isVisible() {
139142
return switch (visibility) {
140143
case ALL -> true;
141-
case ONLY_IN_NON_PRODUCTION ->
142-
!RegistryEnvironment.get().equals(RegistryEnvironment.PRODUCTION);
144+
case FEE_1_DOT_0_EXTENSION_VISIBILITY ->
145+
!RegistryEnvironment.get().equals(RegistryEnvironment.PRODUCTION)
146+
|| tm().transact(() -> FeatureFlag.isActiveNow(FEE_EXTENSION_1_DOT_0_IN_PROD));
143147
case NONE -> false;
144148
};
145149
}

core/src/main/java/google/registry/tools/RegistryToolEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void setup() {
9191

9292
/** Sets up execution environment. Call this method before any classes are loaded. */
9393
@VisibleForTesting
94-
void setup(SystemPropertySetter systemPropertySetter) {
94+
public void setup(SystemPropertySetter systemPropertySetter) {
9595
instance = this;
9696
actualEnvironment.setup(systemPropertySetter);
9797
for (Map.Entry<String, String> entry : extraProperties.entrySet()) {

core/src/test/java/google/registry/flows/domain/ProductionSimulatingFeeExtensionsTest.java

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,31 @@
1515
package google.registry.flows.domain;
1616

1717
import static com.google.common.truth.Truth.assertThat;
18+
import static google.registry.model.common.FeatureFlag.FeatureName.FEE_EXTENSION_1_DOT_0_IN_PROD;
19+
import static google.registry.tools.RegistryToolEnvironment.PRODUCTION;
20+
import static google.registry.util.DateTimeUtils.START_OF_TIME;
1821

1922
import google.registry.model.eppcommon.ProtocolDefinition;
23+
import google.registry.persistence.transaction.JpaTestExtensions;
24+
import google.registry.testing.FakeClock;
25+
import google.registry.tools.CommandTestCase;
26+
import google.registry.tools.ConfigureFeatureFlagCommand;
2027
import google.registry.util.RegistryEnvironment;
28+
import org.joda.time.DateTime;
2129
import org.junit.jupiter.api.AfterEach;
2230
import org.junit.jupiter.api.BeforeEach;
2331
import org.junit.jupiter.api.Test;
32+
import org.junit.jupiter.api.extension.RegisterExtension;
2433

2534
/** Class for testing the XML extension definitions loaded in the prod environment. */
26-
public class ProductionSimulatingFeeExtensionsTest {
35+
public class ProductionSimulatingFeeExtensionsTest
36+
extends CommandTestCase<ConfigureFeatureFlagCommand> {
37+
38+
private final FakeClock clock = new FakeClock(DateTime.parse("2026-01-01T00:00:00Z"));
39+
40+
@RegisterExtension
41+
final JpaTestExtensions.JpaIntegrationTestExtension jpa =
42+
new JpaTestExtensions.Builder().withClock(clock).buildIntegrationTestExtension();
2743

2844
private RegistryEnvironment previousEnvironment;
2945

@@ -59,7 +75,28 @@ void testNonProdEnvironments() {
5975
}
6076

6177
@Test
62-
void testProdEnvironment() {
78+
void testProdEnvironment_feeExtensionFeatureNotSet() {
79+
RegistryEnvironment.PRODUCTION.setup();
80+
ProtocolDefinition.reloadServiceExtensionUris();
81+
// prod shouldn't have the fee extension version 1.0
82+
assertThat(ProtocolDefinition.getVisibleServiceExtensionUris())
83+
.containsExactly(
84+
"urn:ietf:params:xml:ns:launch-1.0",
85+
"urn:ietf:params:xml:ns:rgp-1.0",
86+
"urn:ietf:params:xml:ns:secDNS-1.1",
87+
"urn:ietf:params:xml:ns:fee-0.6",
88+
"urn:ietf:params:xml:ns:fee-0.11",
89+
"urn:ietf:params:xml:ns:fee-0.12");
90+
}
91+
92+
@Test
93+
void testProdEnvironment_feeExtensionFeatureActiveInTheFuture() throws Exception {
94+
runCommandInEnvironment(
95+
PRODUCTION,
96+
FEE_EXTENSION_1_DOT_0_IN_PROD.name(),
97+
"--force",
98+
"--status_map",
99+
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, clock.nowUtc().plusMillis(1)));
63100
RegistryEnvironment.PRODUCTION.setup();
64101
ProtocolDefinition.reloadServiceExtensionUris();
65102
// prod shouldn't have the fee extension version 1.0
@@ -72,4 +109,26 @@ void testProdEnvironment() {
72109
"urn:ietf:params:xml:ns:fee-0.11",
73110
"urn:ietf:params:xml:ns:fee-0.12");
74111
}
112+
113+
@Test
114+
void testProdEnvironment_feeExtensionFeatureActiveInThePast() throws Exception {
115+
runCommandInEnvironment(
116+
PRODUCTION,
117+
FEE_EXTENSION_1_DOT_0_IN_PROD.name(),
118+
"--force",
119+
"--status_map",
120+
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, clock.nowUtc().minusMillis(1)));
121+
RegistryEnvironment.PRODUCTION.setup();
122+
ProtocolDefinition.reloadServiceExtensionUris();
123+
// prod should have the fee extension version 1.0
124+
assertThat(ProtocolDefinition.getVisibleServiceExtensionUris())
125+
.containsExactly(
126+
"urn:ietf:params:xml:ns:launch-1.0",
127+
"urn:ietf:params:xml:ns:rgp-1.0",
128+
"urn:ietf:params:xml:ns:secDNS-1.1",
129+
"urn:ietf:params:xml:ns:fee-0.6",
130+
"urn:ietf:params:xml:ns:fee-0.11",
131+
"urn:ietf:params:xml:ns:fee-0.12",
132+
"urn:ietf:params:xml:ns:epp:fee-1.0");
133+
}
75134
}

core/src/test/java/google/registry/tools/CommandTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public final void afterEachCommandTestCase() {
9494
System.setErr(oldStderr);
9595
}
9696

97-
void runCommandInEnvironment(RegistryToolEnvironment env, String... args) throws Exception {
97+
protected void runCommandInEnvironment(RegistryToolEnvironment env, String... args)
98+
throws Exception {
9899
env.setup(systemPropertyExtension);
99100
try {
100101
JCommander jcommander = new JCommander(command);

db/src/main/resources/sql/schema/db-schema.sql.generated

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
);
334334

335335
create table "FeatureFlag" (
336-
feature_name text not null check (feature_name in ('TEST_FEATURE','MINIMUM_DATASET_CONTACTS_OPTIONAL','MINIMUM_DATASET_CONTACTS_PROHIBITED','INCLUDE_PENDING_DELETE_DATE_FOR_DOMAINS','PROHIBIT_CONTACT_OBJECTS_ON_LOGIN')),
336+
feature_name text not null check (feature_name in ('TEST_FEATURE','FEE_EXTENSION_1_DOT_0_IN_PROD','MINIMUM_DATASET_CONTACTS_OPTIONAL','MINIMUM_DATASET_CONTACTS_PROHIBITED','INCLUDE_PENDING_DELETE_DATE_FOR_DOMAINS','PROHIBIT_CONTACT_OBJECTS_ON_LOGIN')),
337337
status hstore not null,
338338
primary key (feature_name)
339339
);

0 commit comments

Comments
 (0)