mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 08:22:13 +02:00
Add LRP TLD states to Registry and *_tld tools
Also had to add an EnumParameter class to support List<T extends Enum<T>>, as these aren't natively supported by JCommander (although single Enum parameters are.) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129464699
This commit is contained in:
parent
751df4b488
commit
1ef8716177
10 changed files with 259 additions and 2 deletions
|
@ -443,4 +443,21 @@ public class RegistryTest extends EntityTestCase {
|
|||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_lrpTldState_notInTransitions() {
|
||||
Registry registry = Registry.get("tld").asBuilder()
|
||||
.setTldStateTransitions(ImmutableSortedMap.<DateTime, TldState>naturalOrder()
|
||||
.put(START_OF_TIME, TldState.PREDELEGATION)
|
||||
.put(clock.nowUtc().plusMonths(1), TldState.SUNRISE)
|
||||
.put(clock.nowUtc().plusMonths(3), TldState.LANDRUSH)
|
||||
.put(clock.nowUtc().plusMonths(4), TldState.QUIET_PERIOD)
|
||||
.put(clock.nowUtc().plusMonths(5), TldState.GENERAL_AVAILABILITY)
|
||||
.build())
|
||||
.build();
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Cannot specify an LRP TLD state that is not part of the TLD state transitions.");
|
||||
registry.asBuilder().setLrpTldStates(ImmutableSet.of(TldState.SUNRUSH)).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -683,6 +683,7 @@ class google.registry.model.registry.Registry {
|
|||
java.lang.String tldStr;
|
||||
java.lang.String tldUnicode;
|
||||
java.util.Set<com.googlecode.objectify.Key<google.registry.model.registry.label.ReservedList>> reservedLists;
|
||||
java.util.Set<google.registry.model.registry.Registry$TldState> lrpTldStates;
|
||||
java.util.Set<java.lang.String> allowedFullyQualifiedHostNames;
|
||||
java.util.Set<java.lang.String> allowedRegistrantContactIds;
|
||||
org.joda.money.CurrencyUnit currency;
|
||||
|
|
|
@ -211,6 +211,29 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
.containsExactly("xn--q9jyb4c_abuse", "common_abuse");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addLrpTldState() throws Exception {
|
||||
runCommandForced(
|
||||
"--lrp_tld_states=SUNRISE",
|
||||
"--initial_tld_state=SUNRISE",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates())
|
||||
.containsExactly(TldState.SUNRISE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_addMultipleLrpTldStates() throws Exception {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
runCommandForced(
|
||||
"--lrp_tld_states=SUNRISE,LANDRUSH",
|
||||
String.format("--tld_state_transitions=%s=SUNRISE,%s=LANDRUSH", START_OF_TIME, now.plus(1)),
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates())
|
||||
.containsExactly(TldState.SUNRISE, TldState.LANDRUSH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_setPremiumPriceAckRequired() throws Exception {
|
||||
runCommandForced("--premium_price_ack_required=true", "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
|
||||
|
@ -406,6 +429,30 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
runCommandForced("--roid_suffix=BLAH", "randomtld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_lrpTldState_notInTldStateTransitions() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Cannot specify an LRP TLD state that is not part of the TLD state transitions.");
|
||||
runCommandForced(
|
||||
"--lrp_tld_states=SUNRISE",
|
||||
"--initial_tld_state=PREDELEGATION",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_lrpTldState_badTldState() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"No enum constant google.registry.model.registry.Registry.TldState.LANDRISE");
|
||||
runCommandForced(
|
||||
"--lrp_tld_states=LANDRISE",
|
||||
"--initial_tld_state=PREDELEGATION",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"xn--q9jyb4c");
|
||||
}
|
||||
|
||||
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
|
||||
runCommandForced("--reserved_lists", reservedLists, "--roid_suffix=Q9JYB4C", "xn--q9jyb4c");
|
||||
}
|
||||
|
|
|
@ -814,6 +814,68 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
runCommandForced("--premium_list=phonies", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_updateLrpTldState() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(2), TldState.SUNRISE,
|
||||
now.minusMonths(1), TldState.LANDRUSH,
|
||||
now, TldState.GENERAL_AVAILABILITY))
|
||||
.setLrpTldStates(ImmutableSet.of(TldState.SUNRISE))
|
||||
.build());
|
||||
runCommandForced("--lrp_tld_states=LANDRUSH", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates()).containsExactly(TldState.LANDRUSH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_updateMultipleLrpTldStates() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(2), TldState.SUNRISE,
|
||||
now.minusMonths(1), TldState.LANDRUSH,
|
||||
now, TldState.GENERAL_AVAILABILITY))
|
||||
.setLrpTldStates(ImmutableSet.<TldState>of())
|
||||
.build());
|
||||
runCommandForced("--lrp_tld_states=SUNRISE,LANDRUSH", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates())
|
||||
.containsExactly(TldState.LANDRUSH, TldState.SUNRISE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_updateLrpTldStates_notInTransitions() throws Exception {
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(2), TldState.SUNRISE,
|
||||
now, TldState.GENERAL_AVAILABILITY))
|
||||
.setLrpTldStates(ImmutableSet.of(TldState.SUNRISE))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Cannot specify an LRP TLD state that is not part of the TLD state transitions.");
|
||||
runCommandForced("--lrp_tld_states=LANDRUSH", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_updateLrpTldStates_badTldState() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"No enum constant google.registry.model.registry.Registry.TldState.LOUD_PERIOD");
|
||||
runCommandForced(
|
||||
"--lrp_tld_states=LOUD_PERIOD",
|
||||
"--initial_tld_state=PREDELEGATION",
|
||||
"--roid_suffix=Q9JYB4C",
|
||||
"xn--q9jyb4c");
|
||||
}
|
||||
|
||||
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {
|
||||
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ java_library(
|
|||
"//third_party/java/joda_time",
|
||||
"//third_party/java/junit",
|
||||
"//third_party/java/truth",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/tools/params",
|
||||
"//javatests/google/registry/testing",
|
||||
],
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.tools.params;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link EnumParameter}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class EnumParameterTest {
|
||||
|
||||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
// There's no additional functionality exposed by this (or any other) EnumParameter, but using
|
||||
// this in the test as EnumParameter is abstract.
|
||||
private final TldStateParameter instance = new TldStateParameter();
|
||||
|
||||
@Test
|
||||
public void testSuccess_convertEnum() throws Exception {
|
||||
assertThat(instance.convert("PREDELEGATION")).isEqualTo(TldState.PREDELEGATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_badValue() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"No enum constant google.registry.model.registry.Registry.TldState.GENERAL_SUNRUSH");
|
||||
instance.convert("GENERAL_SUNRUSH");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue