mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Update to only include changes to check for production required tags (#2273)
This commit is contained in:
parent
891e7c0174
commit
2166c28d6d
2 changed files with 48 additions and 0 deletions
|
@ -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);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue