Update to only include changes to check for production required tags (#2273)

This commit is contained in:
sarahcaseybot 2024-01-24 17:12:46 -05:00 committed by GitHub
parent 891e7c0174
commit 2166c28d6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 0 deletions

View file

@ -105,6 +105,12 @@ public class ConfigureTldCommand extends MutatingCommand {
@Override @Override
protected void init() throws Exception { protected void init() throws Exception {
if (RegistryToolEnvironment.get().equals(RegistryToolEnvironment.PRODUCTION)) {
checkArgument(
buildEnv || breakGlass != null,
"Either the --break_glass or --build_environment flag must be used when"
+ " running the configure_tld command on Production");
}
String name = convertFilePathToName(inputFile); String name = convertFilePathToName(inputFile);
Map<String, Object> tldData = new Yaml().load(Files.newBufferedReader(inputFile)); Map<String, Object> tldData = new Yaml().load(Files.newBufferedReader(inputFile));
checkName(name, tldData); checkName(name, tldData);

View file

@ -671,4 +671,46 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
Tld notUpdatedTld = Tld.get("tld"); Tld notUpdatedTld = Tld.get("tld");
assertThat(notUpdatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 13)); assertThat(notUpdatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 13));
} }
@Test
void testFailure_runCommandOnProduction_noFlag() throws Exception {
createTld("tld");
File tldFile = tmpDir.resolve("tld.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() ->
runCommandInEnvironment(RegistryToolEnvironment.PRODUCTION, "--input=" + tldFile));
assertThat(thrown.getMessage())
.isEqualTo(
"Either the --break_glass or --build_environment flag must be used when running the"
+ " configure_tld command on Production");
}
@Test
void testSuccess_runCommandOnProduction_breakGlassFlag() throws Exception {
createTld("tld");
File tldFile = tmpDir.resolve("tld.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
runCommandInEnvironment(
RegistryToolEnvironment.PRODUCTION, "--input=" + tldFile, "--break_glass=true", "-f");
Tld updatedTld = Tld.get("tld");
assertThat(updatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 25));
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
assertThat(updatedTld.getBreakglassMode()).isTrue();
}
@Test
void testSuccess_runCommandOnProduction_buildEnvFlag() throws Exception {
createTld("tld");
File tldFile = tmpDir.resolve("tld.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
runCommandInEnvironment(
RegistryToolEnvironment.PRODUCTION, "--input=" + tldFile, "--build_environment", "-f");
Tld updatedTld = Tld.get("tld");
assertThat(updatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 25));
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
assertThat(updatedTld.getBreakglassMode()).isFalse();
}
} }