mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 16:32:11 +02:00
Add necessary fields to the AllocationToken schema
See https://docs.google.com/document/d/1SSWrILRpx0Mtr4sdvlYwz9I8wJp5Gu_o4qlml3iJDKI This is just the base for now--we don't actually do anything with it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=243265164
This commit is contained in:
parent
314daff8a1
commit
cfee7e7fd5
11 changed files with 356 additions and 31 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.eppoutput.CheckData.DomainCheck.create;
|
||||
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
|
||||
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
|
||||
|
@ -83,7 +84,11 @@ public class DomainCheckFlowTest
|
|||
|
||||
private ReservedList createReservedList() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setDomainName("anchor.tld").setToken("2fooBAR").build());
|
||||
new AllocationToken.Builder()
|
||||
.setDomainName("anchor.tld")
|
||||
.setToken("2fooBAR")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
return persistReservedList(
|
||||
"tld-reserved",
|
||||
"reserved,FULLY_BLOCKED",
|
||||
|
@ -140,7 +145,8 @@ public class DomainCheckFlowTest
|
|||
public void testSuccess_oneExists_allocationTokenIsValid() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
persistResource(new AllocationToken.Builder().setToken("abc123").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("abc123").setTokenType(SINGLE_USE).build());
|
||||
doCheckTest(
|
||||
create(false, "example1.tld", "In use"),
|
||||
create(true, "example2.tld", null),
|
||||
|
@ -154,6 +160,7 @@ public class DomainCheckFlowTest
|
|||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
|
||||
.build());
|
||||
doCheckTest(
|
||||
|
|
|
@ -21,6 +21,7 @@ import static google.registry.flows.FlowTestCase.UserPrivileges.SUPERUSER;
|
|||
import static google.registry.model.billing.BillingEvent.Flag.ANCHOR_TENANT;
|
||||
import static google.registry.model.billing.BillingEvent.Flag.SUNRISE;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.eppcommon.StatusValue.OK;
|
||||
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
||||
import static google.registry.model.eppcommon.StatusValue.SERVER_HOLD;
|
||||
|
@ -175,7 +176,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
public void initCreateTest() {
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("abcDEF23456").setDomainName("anchor.tld").build());
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abcDEF23456")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setDomainName("anchor.tld")
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
|
@ -423,6 +428,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 505L))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
|
@ -436,7 +442,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
setEppInput("domain_create_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistContactsAndHosts();
|
||||
AllocationToken token =
|
||||
persistResource(new AllocationToken.Builder().setToken("abc123").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("abc123").setTokenType(SINGLE_USE).build());
|
||||
clock.advanceOneMilli();
|
||||
doSuccessfulTest();
|
||||
HistoryEntry historyEntry =
|
||||
|
@ -970,6 +977,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
new AllocationToken.Builder()
|
||||
.setDomainName("example-one.tld")
|
||||
.setToken("abcDEF23456")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -1016,6 +1024,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
new AllocationToken.Builder()
|
||||
.setDomainName("test-validate.tld")
|
||||
.setToken("abcDEF23456")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -1040,7 +1049,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
@Test
|
||||
public void testSuccess_reservedDomain_viaAllocationTokenExtension() throws Exception {
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("abc123").setDomainName("resdom.tld").build());
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setDomainName("resdom.tld")
|
||||
.build());
|
||||
// Despite the domain being FULLY_BLOCKED, the non-superuser create succeeds the domain is also
|
||||
// RESERVED_FOR_SPECIFIC_USE and the correct allocation token is passed.
|
||||
setEppInput("domain_create_allocationtoken.xml", ImmutableMap.of("DOMAIN", "resdom.tld"));
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.domain.token;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
|
@ -57,7 +58,8 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
@Test
|
||||
public void test_verifyToken_successfullyVerifiesValidToken() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(new AllocationToken.Builder().setToken("tokeN").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new AllocationTokenCustomLogic());
|
||||
assertThat(
|
||||
|
@ -89,7 +91,8 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
|
||||
@Test
|
||||
public void test_verifyToken_callsCustomLogic() {
|
||||
persistResource(new AllocationToken.Builder().setToken("tokeN").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new FailingAllocationTokenCustomLogic());
|
||||
Exception thrown =
|
||||
|
@ -107,7 +110,8 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_successfullyVerifiesValidToken() {
|
||||
persistResource(new AllocationToken.Builder().setToken("tokeN").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new AllocationTokenCustomLogic());
|
||||
assertThat(
|
||||
|
@ -128,6 +132,7 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("tokeN")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 101L))
|
||||
.build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
|
@ -150,7 +155,8 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_callsCustomLogic() {
|
||||
persistResource(new AllocationToken.Builder().setToken("tokeN").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new FailingAllocationTokenCustomLogic());
|
||||
Exception thrown =
|
||||
|
@ -168,7 +174,8 @@ public class AllocationTokenFlowUtilsTest extends ShardableTestCase {
|
|||
|
||||
@Test
|
||||
public void test_checkDomainsWithToken_resultsFromCustomLogicAreIntegrated() {
|
||||
persistResource(new AllocationToken.Builder().setToken("tokeN").build());
|
||||
persistResource(
|
||||
new AllocationToken.Builder().setToken("tokeN").setTokenType(SINGLE_USE).build());
|
||||
AllocationTokenFlowUtils flowUtils =
|
||||
new AllocationTokenFlowUtils(new CustomResultAllocationTokenCustomLogic());
|
||||
assertThat(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue