mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 00:42:12 +02:00
Enforce canonicalization of premium/reserved list labels
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193401336
This commit is contained in:
parent
c6a4264606
commit
2c0fb6d5a6
7 changed files with 108 additions and 17 deletions
|
@ -1669,7 +1669,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidPunycode() throws Exception {
|
||||
doFailingDomainNameTest("xn--abcdefg.tld", InvalidPunycodeException.class);
|
||||
// You don't want to know what this string (might?) mean.
|
||||
doFailingDomainNameTest("xn--uxa129t5ap4f1h1bc3p.tld", InvalidPunycodeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -25,8 +25,10 @@ import static google.registry.testing.JUnitBackports.assertThrows;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.PremiumList.PremiumListEntry;
|
||||
import google.registry.model.registry.label.PremiumList.PremiumListRevision;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -98,4 +100,30 @@ public class PremiumListTest {
|
|||
.contains(
|
||||
"List 'tld' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidation_labelMustBeLowercase() {
|
||||
Exception e =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new PremiumListEntry.Builder()
|
||||
.setPrice(Money.parse("USD 399"))
|
||||
.setLabel("UPPER.tld")
|
||||
.build());
|
||||
assertThat(e).hasMessageThat().contains("must be in puny-coded, lower-case form");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidation_labelMustBePunyCoded() {
|
||||
Exception e =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new PremiumListEntry.Builder()
|
||||
.setPrice(Money.parse("USD 399"))
|
||||
.setLabel("lower.みんな")
|
||||
.build());
|
||||
assertThat(e).hasMessageThat().contains("must be in puny-coded, lower-case form");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@ public class ReservedListTest {
|
|||
"reserved",
|
||||
"trombone,FULLY_BLOCKED # yup",
|
||||
"oysters,MISTAKEN_PREMIUM # this is a loooong comment",
|
||||
"nullComment,ALLOWED_IN_SUNRISE #");
|
||||
"nullcomment,ALLOWED_IN_SUNRISE #");
|
||||
assertThat(reservedList.getReservedListEntries()).hasSize(3);
|
||||
|
||||
ReservedListEntry trombone = reservedList.getReservedListEntries().get("trombone");
|
||||
|
@ -423,8 +423,8 @@ public class ReservedListTest {
|
|||
assertThat(oysters.reservationType).isEqualTo(ReservationType.MISTAKEN_PREMIUM);
|
||||
assertThat(oysters.comment).isEqualTo("this is a loooong comment");
|
||||
|
||||
ReservedListEntry nullComment = reservedList.getReservedListEntries().get("nullComment");
|
||||
assertThat(nullComment.label).isEqualTo("nullComment");
|
||||
ReservedListEntry nullComment = reservedList.getReservedListEntries().get("nullcomment");
|
||||
assertThat(nullComment.label).isEqualTo("nullcomment");
|
||||
assertThat(nullComment.reservationType).isEqualTo(ReservationType.ALLOWED_IN_SUNRISE);
|
||||
assertThat(nullComment.comment).isEmpty();
|
||||
}
|
||||
|
@ -582,4 +582,22 @@ public class ReservedListTest {
|
|||
.contains(
|
||||
"List 'blah' cannot contain duplicate labels. Dupes (with counts) were: [lol x 2]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidation_labelMustBeLowercase() {
|
||||
Exception e =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ReservedListEntry.create("UPPER.tld", FULLY_BLOCKED, null, null));
|
||||
assertThat(e).hasMessageThat().contains("must be in puny-coded, lower-case form");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidation_labelMustBePunyCoded() {
|
||||
Exception e =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> ReservedListEntry.create("lower.みんな", FULLY_BLOCKED, null, null));
|
||||
assertThat(e).hasMessageThat().contains("must be in puny-coded, lower-case form");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue