Add validation to ROID suffixes

I could've sworn we were already doing this, but apparently not? Anyway,
ROID suffixes have a number of requirements on them that weren't being
enforced, so this enforces them. All existing production data is compliant
with these requirements; the only existing bad data we have is in alpha and
sandbox.

ROID suffixes are now required to match the regex ^[A-Z0-9_]{1,8}$

See also https://tools.ietf.org/html/rfc5730

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173400001
This commit is contained in:
mcilwain 2017-10-25 08:19:47 -07:00 committed by jianglai
parent 2f539d6008
commit 7951799595
4 changed files with 39 additions and 8 deletions

View file

@ -16,7 +16,6 @@ package google.registry.tools;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistPremiumList;
@ -78,13 +77,13 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
@Test
public void testFailure_multipleArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time");
runCommandForced("--roid_suffix=blah", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c", "test");
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c", "test");
}
@Test
public void testFailure_multipleDuplicateArguments() throws Exception {
thrown.expect(IllegalArgumentException.class, "Can't create more than one TLD at a time");
runCommandForced("--roid_suffix=blah", "--dns_writers=VoidDnsWriter", "test", "test");
runCommandForced("--roid_suffix=BLAH", "--dns_writers=VoidDnsWriter", "test", "test");
}
@Test