mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 11:16:04 +02:00
Add new reserved domain creation from allocation tokens mechanism
Note that this gets rid of anchor tenant codes in reserved lists (yay!), which are no longer valid. They have to come from allocation tokens now. This removes support for LRP from domain application create flow (that's fine, we never used it and I'm going to delete all of LRP later). It also uses allocation tokens from EPP authcodes as a fallback, for now, but that will be removed later once we switch fully to the allocation token mechanism. This doesn't yet allow registration of RESERVED_FOR_SPECIFIC_USE domains using the allocation token extension; that will come in the next CL. Ditto for showing these reserved domains as available on domain checks when the allocation token is specified. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=209019617
This commit is contained in:
parent
782643ce33
commit
d2f849ac0f
19 changed files with 184 additions and 346 deletions
|
@ -37,7 +37,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
|||
.setToken("abc123")
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
|
||||
.setDomainName("foo.example")
|
||||
.setCreationTime(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.build());
|
||||
assertThat(ofy().load().entity(token).now()).isEqualTo(token);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
|||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setDomainName("blahdomain.fake")
|
||||
.setCreationTime(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.build()),
|
||||
"token",
|
||||
"domainName");
|
||||
|
@ -69,11 +69,11 @@ public class AllocationTokenTest extends EntityTestCase {
|
|||
AllocationToken.Builder builder =
|
||||
new AllocationToken.Builder()
|
||||
.setToken("foobar")
|
||||
.setCreationTime(DateTime.parse("2010-11-12T05:00:00Z"));
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"));
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> builder.setCreationTime(DateTime.parse("2010-11-13T05:00:00Z")));
|
||||
() -> builder.setCreationTimeForTest(DateTime.parse("2010-11-13T05:00:00Z")));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("creationTime can only be set once");
|
||||
}
|
||||
|
||||
|
|
|
@ -180,46 +180,6 @@ public class RegistryTest extends EntityTestCase {
|
|||
assertThat(r.getReservedLists()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetReservedLists_succeedsWithDuplicateIdenticalAuthCodes() {
|
||||
ReservedList rl1 = persistReservedList(
|
||||
"tld-reserved007",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,identical",
|
||||
"cat,FULLY_BLOCKED");
|
||||
ReservedList rl2 = persistReservedList(
|
||||
"tld-reserved008",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,identical",
|
||||
"tim,FULLY_BLOCKED");
|
||||
Registry registry = Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build();
|
||||
assertThat(registry.getReservedLists()).containsExactly(Key.create(rl1), Key.create(rl2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetReservedLists_failsForConflictingAuthCodes() {
|
||||
ReservedList rl1 = persistReservedList(
|
||||
"tld-reserved055",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,conflict1",
|
||||
"cat,FULLY_BLOCKED");
|
||||
ReservedList rl2 = persistReservedList(
|
||||
"tld-reserved056",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,conflict2",
|
||||
"tim,FULLY_BLOCKED");
|
||||
ReservedList rl3 = persistReservedList(
|
||||
"tld-reserved057",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,another_conflict");
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> {
|
||||
@SuppressWarnings("unused")
|
||||
Registry unused =
|
||||
Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build();
|
||||
});
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("auth code conflicts for labels: [lol=[conflict1, conflict2, another_conflict]]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPremiumList() {
|
||||
PremiumList pl2 = persistPremiumList("tld2", "lol,USD 50", "cat,USD 700");
|
||||
|
|
|
@ -23,13 +23,10 @@ import static google.registry.model.registry.label.DomainLabelMetrics.reservedLi
|
|||
import static google.registry.model.registry.label.DomainLabelMetrics.reservedListProcessingTime;
|
||||
import static google.registry.model.registry.label.ReservationType.ALLOWED_IN_SUNRISE;
|
||||
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
|
||||
import static google.registry.model.registry.label.ReservationType.MISTAKEN_PREMIUM;
|
||||
import static google.registry.model.registry.label.ReservationType.NAMESERVER_RESTRICTED;
|
||||
import static google.registry.model.registry.label.ReservationType.NAME_COLLISION;
|
||||
import static google.registry.model.registry.label.ReservationType.RESERVED_FOR_ANCHOR_TENANT;
|
||||
import static google.registry.model.registry.label.ReservedList.getAllowedNameservers;
|
||||
import static google.registry.model.registry.label.ReservedList.getReservationTypes;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -118,47 +115,6 @@ public class ReservedListTest {
|
|||
verifyUnreservedCheckCount(26);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesAnchorTenantReservation() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setReservedLists(ImmutableSet.of(
|
||||
persistReservedList(
|
||||
"reserved1",
|
||||
"lol,RESERVED_FOR_ANCHOR_TENANT,foobar1",
|
||||
"lol2,RESERVED_FOR_ANCHOR_TENANT,abcdefg # This is a comment")))
|
||||
.build());
|
||||
assertThat(getReservationTypes("lol", "tld")).containsExactly(RESERVED_FOR_ANCHOR_TENANT);
|
||||
assertThat(getReservationTypes("lol2", "tld")).containsExactly(RESERVED_FOR_ANCHOR_TENANT);
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foobar1"))
|
||||
.isTrue();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foobar"))
|
||||
.isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol2.tld"), "abcdefg"))
|
||||
.isTrue();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol2.tld"), "abcdefg "))
|
||||
.isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("random.tld"), "abcdefg"))
|
||||
.isFalse();
|
||||
assertThat(reservedListChecks)
|
||||
.hasValueForLabels(1, "tld", "0", "(none)", "(none)")
|
||||
.and()
|
||||
.hasValueForLabels(6, "tld", "1", "reserved1", RESERVED_FOR_ANCHOR_TENANT.toString())
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
assertThat(reservedListProcessingTime)
|
||||
.hasAnyValueForLabels("tld", "0", "(none)", "(none)")
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "1", "reserved1", RESERVED_FOR_ANCHOR_TENANT.toString())
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
assertThat(reservedListHits)
|
||||
.hasValueForLabels(6, "tld", "reserved1", RESERVED_FOR_ANCHOR_TENANT.toString())
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllowedNameservers() {
|
||||
ReservedList rl1 =
|
||||
|
@ -191,87 +147,6 @@ public class ReservedListTest {
|
|||
assertThat(getAllowedNameservers(InternetDomainName.from("lol4.tld"))).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesAnchorTenantReservation_falseOnOtherReservationTypes() {
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setReservedLists(
|
||||
ImmutableSet.of(
|
||||
persistReservedList(
|
||||
"reserved2",
|
||||
"lol,FULLY_BLOCKED",
|
||||
"lol2,NAME_COLLISION",
|
||||
"lol3,MISTAKEN_PREMIUM",
|
||||
"lol4,ALLOWED_IN_SUNRISE",
|
||||
"lol5,NAMESERVER_RESTRICTED,na1.domain.tld")))
|
||||
.build());
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "")).isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol2.tld"), "")).isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol3.tld"), "")).isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol4.tld"), "")).isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol5.tld"), "")).isFalse();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol6.tld"), "")).isFalse();
|
||||
assertThat(reservedListChecks)
|
||||
.hasValueForLabels(1, "tld", "1", "reserved2", FULLY_BLOCKED.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "1", "reserved2", NAME_COLLISION.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "1", "reserved2", MISTAKEN_PREMIUM.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "1", "reserved2", ALLOWED_IN_SUNRISE.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "1", "reserved2", NAMESERVER_RESTRICTED.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "0", "(none)", "(none)")
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
assertThat(reservedListProcessingTime)
|
||||
.hasAnyValueForLabels("tld", "1", "reserved2", FULLY_BLOCKED.toString())
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "1", "reserved2", NAME_COLLISION.toString())
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "1", "reserved2", MISTAKEN_PREMIUM.toString())
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "1", "reserved2", ALLOWED_IN_SUNRISE.toString())
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "1", "reserved2", NAMESERVER_RESTRICTED.toString())
|
||||
.and()
|
||||
.hasAnyValueForLabels("tld", "0", "(none)", "(none)")
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
assertThat(reservedListHits)
|
||||
.hasValueForLabels(1, "tld", "reserved2", FULLY_BLOCKED.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "reserved2", NAME_COLLISION.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "reserved2", MISTAKEN_PREMIUM.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "reserved2", ALLOWED_IN_SUNRISE.toString())
|
||||
.and()
|
||||
.hasValueForLabels(1, "tld", "reserved2", NAMESERVER_RESTRICTED.toString())
|
||||
.and()
|
||||
.hasNoOtherValues();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesAnchorTenantReservation_duplicatingAuthCodes() {
|
||||
ReservedList rl1 = persistReservedList("reserved1", "lol,RESERVED_FOR_ANCHOR_TENANT,foo");
|
||||
ReservedList rl2 = persistReservedList("reserved2", "lol,RESERVED_FOR_ANCHOR_TENANT,foo");
|
||||
createTld("tld");
|
||||
persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build());
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "foo")).isTrue();
|
||||
assertThat(matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar")).isFalse();
|
||||
persistReservedList("reserved2", "lol,RESERVED_FOR_ANCHOR_TENANT,bar");
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> matchesAnchorTenantReservation(InternetDomainName.from("lol.tld"), "bar"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("There are conflicting auth codes for domain: lol.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReservationTypes_concatsMultipleListsCorrectly() {
|
||||
ReservedList rl1 = persistReservedList(
|
||||
|
@ -494,8 +369,7 @@ public class ReservedListTest {
|
|||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Only anchor tenant and nameserver restricted reservations "
|
||||
+ "should have restrictions imposed");
|
||||
"Allowed nameservers must be specified for NAMESERVER_RESTRICTED reservations only");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -524,24 +398,6 @@ public class ReservedListTest {
|
|||
assertThat(thrown).hasMessageThat().contains("domain.tld is not a valid nameserver hostname");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSave_noPasswordWithAnchorTenantReservation() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setReservedLists(
|
||||
ImmutableSet.of(
|
||||
persistReservedList("reserved1", "lol,RESERVED_FOR_ANCHOR_TENANT")))
|
||||
.build()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Anchor tenant reservations must have an auth code configured");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSave_noNameserversWithNameserverRestrictedReservation() {
|
||||
IllegalArgumentException thrown =
|
||||
|
@ -558,7 +414,7 @@ public class ReservedListTest {
|
|||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Nameserver restricted reservations must have at least one nameserver configured");
|
||||
"Allowed nameservers must be specified for NAMESERVER_RESTRICTED reservations only");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -723,6 +723,7 @@ enum google.registry.model.registry.label.ReservationType {
|
|||
NAMESERVER_RESTRICTED;
|
||||
NAME_COLLISION;
|
||||
RESERVED_FOR_ANCHOR_TENANT;
|
||||
RESERVED_FOR_SPECIFIC_USE;
|
||||
}
|
||||
class google.registry.model.registry.label.ReservedList {
|
||||
@Id java.lang.String name;
|
||||
|
@ -737,7 +738,6 @@ class google.registry.model.registry.label.ReservedList$ReservedListEntry {
|
|||
@Id java.lang.String label;
|
||||
google.registry.model.registry.label.ReservationType reservationType;
|
||||
java.lang.String allowedNameservers;
|
||||
java.lang.String authCode;
|
||||
java.lang.String comment;
|
||||
}
|
||||
class google.registry.model.reporting.DomainTransactionRecord {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue