mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 17:28:25 +02:00
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:
parent
2f539d6008
commit
7951799595
4 changed files with 39 additions and 8 deletions
|
@ -17,7 +17,6 @@ package google.registry.model.registry;
|
|||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedListTest.GET_NAME_FUNCTION;
|
||||
|
@ -29,6 +28,8 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.expectThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
@ -488,4 +489,27 @@ public class RegistryTest extends EntityTestCase {
|
|||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_roidSuffixTooLong() {
|
||||
IllegalArgumentException e =
|
||||
expectThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> Registry.get("tld").asBuilder().setRoidSuffix("123456789"));
|
||||
assertThat(e).hasMessageThat().isEqualTo("ROID suffix must be in format ^[A-Z0-9_]{1,8}$");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_roidSuffixNotUppercased() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> Registry.get("tld").asBuilder().setRoidSuffix("abcd"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_roidSuffixContainsInvalidCharacters() {
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> Registry.get("tld").asBuilder().setRoidSuffix("ABC-DEF"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue