mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Add check for build_environment flag in updateReservedListCommand and updatePremiumListCommand (#2317)
* Add check for build_environment flag in updateReservedListCommand * Do the same for premium list
This commit is contained in:
parent
d1d59c1afd
commit
e492936cec
4 changed files with 77 additions and 81 deletions
|
@ -48,11 +48,9 @@ class UpdatePremiumListCommand extends CreateOrUpdatePremiumListCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String prompt() throws Exception {
|
protected String prompt() throws Exception {
|
||||||
// TODO(sarahbot): uncomment once go/r3pr/2292 is deployed
|
checkArgument(
|
||||||
// checkArgument(
|
!RegistryToolEnvironment.get().equals(RegistryToolEnvironment.PRODUCTION) || buildEnv,
|
||||||
// !RegistryToolEnvironment.get().equals(RegistryToolEnvironment.PRODUCTION) || buildEnv,
|
"The --build_environment flag must be used when running update_premium_list in production");
|
||||||
// "The --build_environment flag must be used when running update_premium_list in
|
|
||||||
// production");
|
|
||||||
name = Strings.isNullOrEmpty(name) ? convertFilePathToName(inputFile) : name;
|
name = Strings.isNullOrEmpty(name) ? convertFilePathToName(inputFile) : name;
|
||||||
PremiumList existingList =
|
PremiumList existingList =
|
||||||
PremiumListDao.getLatestRevision(name)
|
PremiumListDao.getLatestRevision(name)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff;
|
import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff;
|
||||||
import static google.registry.util.ListNamingUtils.convertFilePathToName;
|
import static google.registry.util.ListNamingUtils.convertFilePathToName;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
@ -47,11 +48,10 @@ final class UpdateReservedListCommand extends CreateOrUpdateReservedListCommand
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String prompt() throws Exception {
|
protected String prompt() throws Exception {
|
||||||
// TODO(sarahbot): uncomment once go/r3pr/2292 is deployed
|
checkArgument(
|
||||||
// checkArgument(
|
!RegistryToolEnvironment.get().equals(RegistryToolEnvironment.PRODUCTION) || buildEnv,
|
||||||
// !RegistryToolEnvironment.get().equals(RegistryToolEnvironment.PRODUCTION) || buildEnv,
|
"The --build_environment flag must be used when running update_reserved_list in"
|
||||||
// "The --build_environment flag must be used when running update_reserved_list in"
|
+ " production");
|
||||||
// + " production");
|
|
||||||
name = Strings.isNullOrEmpty(name) ? convertFilePathToName(input) : name;
|
name = Strings.isNullOrEmpty(name) ? convertFilePathToName(input) : name;
|
||||||
ReservedList existingReservedList =
|
ReservedList existingReservedList =
|
||||||
ReservedList.get(name)
|
ReservedList.get(name)
|
||||||
|
|
|
@ -206,39 +206,38 @@ class UpdatePremiumListCommandTest<C extends UpdatePremiumListCommand>
|
||||||
.containsExactly(PremiumEntry.create(0L, new BigDecimal("9090.00"), "doge"));
|
.containsExactly(PremiumEntry.create(0L, new BigDecimal("9090.00"), "doge"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(sarahbot): uncomment once go/r3pr/2292 is deployed
|
@Test
|
||||||
// @Test
|
void testFailure_runCommandOnProduction_noFlag() throws Exception {
|
||||||
// void testFailure_runCommandOnProduction_noFlag() throws Exception {
|
File tmpFile = tmpDir.resolve(String.format("%s.txt", TLD_TEST)).toFile();
|
||||||
// File tmpFile = tmpDir.resolve(String.format("%s.txt", TLD_TEST)).toFile();
|
String newPremiumListData = "eth,USD 9999";
|
||||||
// String newPremiumListData = "eth,USD 9999";
|
Files.asCharSink(tmpFile, UTF_8).write(newPremiumListData);
|
||||||
// Files.asCharSink(tmpFile, UTF_8).write(newPremiumListData);
|
IllegalArgumentException thrown =
|
||||||
// IllegalArgumentException thrown =
|
assertThrows(
|
||||||
// assertThrows(
|
IllegalArgumentException.class,
|
||||||
// IllegalArgumentException.class,
|
() ->
|
||||||
// () ->
|
runCommandInEnvironment(
|
||||||
// runCommandInEnvironment(
|
RegistryToolEnvironment.PRODUCTION,
|
||||||
// RegistryToolEnvironment.PRODUCTION,
|
"--name=" + TLD_TEST,
|
||||||
// "--name=" + TLD_TEST,
|
"--input=" + Paths.get(tmpFile.getPath())));
|
||||||
// "--input=" + Paths.get(tmpFile.getPath())));
|
assertThat(thrown.getMessage())
|
||||||
// assertThat(thrown.getMessage())
|
.isEqualTo(
|
||||||
// .isEqualTo(
|
"The --build_environment flag must be used when running update_premium_list in"
|
||||||
// "The --build_environment flag must be used when running update_premium_list in"
|
+ " production");
|
||||||
// + " production");
|
}
|
||||||
// }
|
|
||||||
//
|
@Test
|
||||||
// @Test
|
void testSuccess_runCommandOnProduction_buildEnvFlag() throws Exception {
|
||||||
// void testSuccess_runCommandOnProduction_buildEnvFlag() throws Exception {
|
File tmpFile = tmpDir.resolve(String.format("%s.txt", TLD_TEST)).toFile();
|
||||||
// File tmpFile = tmpDir.resolve(String.format("%s.txt", TLD_TEST)).toFile();
|
String newPremiumListData = "eth,USD 9999";
|
||||||
// String newPremiumListData = "eth,USD 9999";
|
Files.asCharSink(tmpFile, UTF_8).write(newPremiumListData);
|
||||||
// Files.asCharSink(tmpFile, UTF_8).write(newPremiumListData);
|
runCommandInEnvironment(
|
||||||
// runCommandInEnvironment(
|
RegistryToolEnvironment.PRODUCTION,
|
||||||
// RegistryToolEnvironment.PRODUCTION,
|
"--name=" + TLD_TEST,
|
||||||
// "--name=" + TLD_TEST,
|
"--input=" + Paths.get(tmpFile.getPath()),
|
||||||
// "--input=" + Paths.get(tmpFile.getPath()),
|
"--build_environment",
|
||||||
// "--build_environment",
|
"-f");
|
||||||
// "-f");
|
assertThat(PremiumListDao.loadAllPremiumEntries(TLD_TEST))
|
||||||
// assertThat(PremiumListDao.loadAllPremiumEntries(TLD_TEST))
|
.comparingElementsUsing(immutableObjectCorrespondence("revisionId"))
|
||||||
// .comparingElementsUsing(immutableObjectCorrespondence("revisionId"))
|
.containsExactly(PremiumEntry.create(0L, new BigDecimal("9999.00"), "eth"));
|
||||||
// .containsExactly(PremiumEntry.create(0L, new BigDecimal("9999.00"), "eth"));
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,40 +153,39 @@ class UpdateReservedListCommandTest
|
||||||
assertThat(reservedList.getReservationInList("helicopter")).hasValue(FULLY_BLOCKED);
|
assertThat(reservedList.getReservationInList("helicopter")).hasValue(FULLY_BLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(sarahbot): uncomment once go/r3pr/2292 is deployed
|
@Test
|
||||||
// @Test
|
void testFailure_runCommandOnProduction_noFlag() throws Exception {
|
||||||
// void testFailure_runCommandOnProduction_noFlag() throws Exception {
|
IllegalArgumentException thrown =
|
||||||
// IllegalArgumentException thrown =
|
assertThrows(
|
||||||
// assertThrows(
|
IllegalArgumentException.class,
|
||||||
// IllegalArgumentException.class,
|
() ->
|
||||||
// () ->
|
runCommandInEnvironment(
|
||||||
// runCommandInEnvironment(
|
RegistryToolEnvironment.PRODUCTION,
|
||||||
// RegistryToolEnvironment.PRODUCTION,
|
"--name=xn--q9jyb4c_common-reserved",
|
||||||
// "--name=xn--q9jyb4c_common-reserved",
|
"--input=" + reservedTermsPath));
|
||||||
// "--input=" + reservedTermsPath));
|
assertThat(thrown.getMessage())
|
||||||
// assertThat(thrown.getMessage())
|
.isEqualTo(
|
||||||
// .isEqualTo(
|
"The --build_environment flag must be used when running update_reserved_list in"
|
||||||
// "The --build_environment flag must be used when running update_reserved_list in"
|
+ " production");
|
||||||
// + " production");
|
}
|
||||||
// }
|
|
||||||
//
|
@Test
|
||||||
// @Test
|
void testSuccess_runCommandOnProduction_buildEnvFlag() throws Exception {
|
||||||
// void testSuccess_runCommandOnProduction_buildEnvFlag() throws Exception {
|
runCommandInEnvironment(
|
||||||
// runCommandInEnvironment(
|
RegistryToolEnvironment.PRODUCTION,
|
||||||
// RegistryToolEnvironment.PRODUCTION,
|
"--name=xn--q9jyb4c_common-reserved",
|
||||||
// "--name=xn--q9jyb4c_common-reserved",
|
"--input=" + reservedTermsPath,
|
||||||
// "--input=" + reservedTermsPath,
|
"--build_environment",
|
||||||
// "--build_environment",
|
"-f");
|
||||||
// "-f");
|
assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
||||||
// assertThat(ReservedList.get("xn--q9jyb4c_common-reserved")).isPresent();
|
ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
||||||
// ReservedList reservedList = ReservedList.get("xn--q9jyb4c_common-reserved").get();
|
assertThat(reservedList.getReservedListEntries()).hasSize(2);
|
||||||
// assertThat(reservedList.getReservedListEntries()).hasSize(2);
|
assertThat(reservedList.getReservationInList("baddies")).hasValue(FULLY_BLOCKED);
|
||||||
// assertThat(reservedList.getReservationInList("baddies")).hasValue(FULLY_BLOCKED);
|
assertThat(reservedList.getReservationInList("ford")).hasValue(FULLY_BLOCKED);
|
||||||
// assertThat(reservedList.getReservationInList("ford")).hasValue(FULLY_BLOCKED);
|
assertThat(reservedList.getReservationInList("helicopter")).isEmpty();
|
||||||
// assertThat(reservedList.getReservationInList("helicopter")).isEmpty();
|
assertInStdout("Update reserved list for xn--q9jyb4c_common-reserved?");
|
||||||
// assertInStdout("Update reserved list for xn--q9jyb4c_common-reserved?");
|
assertInStdout("helicopter: helicopter,FULLY_BLOCKED -> null");
|
||||||
// assertInStdout("helicopter: helicopter,FULLY_BLOCKED -> null");
|
assertInStdout("baddies: null -> baddies,FULLY_BLOCKED");
|
||||||
// assertInStdout("baddies: null -> baddies,FULLY_BLOCKED");
|
assertInStdout("ford: null -> ford,FULLY_BLOCKED # random comment");
|
||||||
// assertInStdout("ford: null -> ford,FULLY_BLOCKED # random comment");
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue