mirror of
https://github.com/google/nomulus.git
synced 2025-08-28 20:13:46 +02:00
Add a SQL schema to AllocationToken (#763)
* Add a SQL schema to AllocationToken * Respond to CR - rename field in tests - rename allowed_registrar_ids field - remove unnecessary db load in GATC * Add TODO for HistoryEntry vkeys * Run autoformat * V48 -> V49
This commit is contained in:
parent
a28632dbe1
commit
5c30ef7086
23 changed files with 352 additions and 45 deletions
|
@ -71,6 +71,7 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -162,12 +163,13 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
|||
@Test
|
||||
void testSuccess_oneExists_allocationTokenIsRedeemed() throws Exception {
|
||||
setEppInput("domain_check_allocationtoken.xml");
|
||||
persistActiveDomain("example1.tld");
|
||||
DomainBase domain = persistActiveDomain("example1.tld");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1L);
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
|
||||
.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 1L, historyEntryKey))
|
||||
.build());
|
||||
doCheckTest(
|
||||
create(false, "example1.tld", "In use"),
|
||||
|
@ -417,7 +419,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
|||
.setToken("abc123")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setDiscountFraction(0.5)
|
||||
.setAllowedClientIds(ImmutableSet.of("someOtherClient"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("someOtherClient"))
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
|
||||
|
|
|
@ -162,6 +162,7 @@ import google.registry.model.reporting.DomainTransactionRecord;
|
|||
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
@ -492,11 +493,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
"domain_create_allocationtoken.xml",
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
|
||||
persistContactsAndHosts();
|
||||
DomainBase domain = persistActiveDomain("foo.tld");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 505L);
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 505L))
|
||||
.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 505L, historyEntryKey))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
EppException thrown =
|
||||
|
@ -519,7 +522,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
HistoryEntry historyEntry =
|
||||
ofy().load().type(HistoryEntry.class).ancestor(reloadResourceByForeignKey()).first().now();
|
||||
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry())
|
||||
.hasValue(Key.create(historyEntry));
|
||||
.hasValue(HistoryEntry.createVKey(Key.create(historyEntry)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1263,7 +1266,9 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
ofy().load().key(Key.create(AllocationToken.class, token)).now();
|
||||
assertThat(reloadedToken.isRedeemed()).isTrue();
|
||||
assertThat(reloadedToken.getRedemptionHistoryEntry())
|
||||
.hasValue(Key.create(getHistoryEntries(reloadResourceByForeignKey()).get(0)));
|
||||
.hasValue(
|
||||
HistoryEntry.createVKey(
|
||||
Key.create(getHistoryEntries(reloadResourceByForeignKey()).get(0))));
|
||||
}
|
||||
|
||||
private void assertAllocationTokenWasNotRedeemed(String token) {
|
||||
|
@ -1498,7 +1503,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setAllowedClientIds(ImmutableSet.of("someClientId"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
|
||||
.setDiscountFraction(0.5)
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
|
|
|
@ -22,6 +22,7 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.VAL
|
|||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
@ -42,11 +43,13 @@ import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTok
|
|||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForRegistrarException;
|
||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException;
|
||||
import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.DomainCommand;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -127,7 +130,7 @@ class AllocationTokenFlowUtilsTest {
|
|||
void test_validateToken_invalidForClientId() {
|
||||
persistResource(
|
||||
createOneMonthPromoTokenBuilder(DateTime.now(UTC).minusDays(1))
|
||||
.setAllowedClientIds(ImmutableSet.of("NewRegistrar"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
|
||||
.build());
|
||||
assertValidateThrowsEppException(AllocationTokenNotValidForRegistrarException.class);
|
||||
}
|
||||
|
@ -189,11 +192,13 @@ class AllocationTokenFlowUtilsTest {
|
|||
|
||||
@Test
|
||||
void test_checkDomainsWithToken_showsFailureMessageForRedeemedToken() {
|
||||
DomainBase domain = persistActiveDomain("example.tld");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1051L);
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("tokeN")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 101L))
|
||||
.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 101L, historyEntryKey))
|
||||
.build());
|
||||
assertThat(
|
||||
flowUtils
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.model.domain.token;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.CANCELLED;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.ENDED;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED;
|
||||
|
@ -23,7 +24,9 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.VAL
|
|||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
@ -33,15 +36,21 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link AllocationToken}. */
|
||||
class AllocationTokenTest extends EntityTestCase {
|
||||
public class AllocationTokenTest extends EntityTestCase {
|
||||
|
||||
public AllocationTokenTest() {
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
@ -53,11 +62,11 @@ class AllocationTokenTest extends EntityTestCase {
|
|||
AllocationToken unlimitedUseToken =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setToken("abc123Unlimited")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("dev", "app"))
|
||||
.setAllowedClientIds(ImmutableSet.of("TheRegistrar, NewRegistrar"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar, NewRegistrar"))
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountPremiums(true)
|
||||
.setDiscountYears(3)
|
||||
|
@ -70,26 +79,52 @@ class AllocationTokenTest extends EntityTestCase {
|
|||
.build());
|
||||
assertThat(ofy().load().entity(unlimitedUseToken).now()).isEqualTo(unlimitedUseToken);
|
||||
|
||||
DomainBase domain = persistActiveDomain("example.foo");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1);
|
||||
AllocationToken singleUseToken =
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
|
||||
.setToken("abc123Single")
|
||||
.setRedemptionHistoryEntry(HistoryEntry.createVKey(historyEntryKey))
|
||||
.setDomainName("example.foo")
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
assertThat(ofy().load().entity(singleUseToken).now()).isEqualTo(singleUseToken);
|
||||
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
jpaTm().saveNew(unlimitedUseToken);
|
||||
jpaTm().saveNew(singleUseToken);
|
||||
});
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
assertAboutImmutableObjects()
|
||||
.that(jpaTm().load(VKey.createSql(AllocationToken.class, "abc123Unlimited")))
|
||||
.isEqualExceptFields(
|
||||
unlimitedUseToken,
|
||||
"creationTime",
|
||||
"updateTimestamp",
|
||||
"redemptionHistoryEntry");
|
||||
assertAboutImmutableObjects()
|
||||
.that(jpaTm().load(VKey.createSql(AllocationToken.class, "abc123Single")))
|
||||
.isEqualExceptFields(
|
||||
singleUseToken, "creationTime", "updateTimestamp", "redemptionHistoryEntry");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIndexing() throws Exception {
|
||||
DomainBase domain = persistActiveDomain("blahdomain.foo");
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1);
|
||||
verifyIndexing(
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
|
||||
.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 1L, historyEntryKey))
|
||||
.setDomainName("blahdomain.foo")
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.build()),
|
||||
|
@ -193,7 +228,7 @@ class AllocationTokenTest extends EntityTestCase {
|
|||
new AllocationToken.Builder()
|
||||
.setToken("foobar")
|
||||
.setTokenType(TokenType.UNLIMITED_USE)
|
||||
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, "hi"));
|
||||
.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 1L));
|
||||
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, builder::build);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
// Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.ENDED;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.NOT_STARTED;
|
||||
import static google.registry.model.domain.token.AllocationToken.TokenStatus.VALID;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.common.TimedTransitionProperty;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatusTransition;
|
||||
import google.registry.persistence.transaction.JpaTestRules;
|
||||
import google.registry.persistence.transaction.JpaTestRules.JpaUnitTestExtension;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link AllocationTokenStatusTransitionConverter}. */
|
||||
public class AllocationTokenStatusTransitionConverterTest {
|
||||
|
||||
@RegisterExtension
|
||||
public final JpaUnitTestExtension jpa =
|
||||
new JpaTestRules.Builder()
|
||||
.withInitScript("sql/flyway/V14__load_extension_for_hstore.sql")
|
||||
.withEntityClass(AllocationTokenStatusTransitionConverterTestEntity.class)
|
||||
.buildUnitTestRule();
|
||||
|
||||
private static final ImmutableSortedMap<DateTime, TokenStatus> values =
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
NOT_STARTED,
|
||||
DateTime.parse("2001-01-01T00:00:00.0Z"),
|
||||
VALID,
|
||||
DateTime.parse("2002-01-01T00:00:00.0Z"),
|
||||
ENDED);
|
||||
|
||||
@Test
|
||||
void roundTripConversion_returnsSameTimedTransitionProperty() {
|
||||
TimedTransitionProperty<TokenStatus, TokenStatusTransition> timedTransitionProperty =
|
||||
TimedTransitionProperty.fromValueMap(values, TokenStatusTransition.class);
|
||||
AllocationTokenStatusTransitionConverterTestEntity testEntity =
|
||||
new AllocationTokenStatusTransitionConverterTestEntity(timedTransitionProperty);
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().persist(testEntity));
|
||||
AllocationTokenStatusTransitionConverterTestEntity persisted =
|
||||
jpaTm()
|
||||
.transact(
|
||||
() ->
|
||||
jpaTm()
|
||||
.getEntityManager()
|
||||
.find(AllocationTokenStatusTransitionConverterTestEntity.class, "id"));
|
||||
assertThat(persisted.timedTransitionProperty).containsExactlyEntriesIn(timedTransitionProperty);
|
||||
}
|
||||
|
||||
@Entity
|
||||
private static class AllocationTokenStatusTransitionConverterTestEntity extends ImmutableObject {
|
||||
|
||||
@Id String name = "id";
|
||||
|
||||
TimedTransitionProperty<TokenStatus, TokenStatusTransition> timedTransitionProperty;
|
||||
|
||||
private AllocationTokenStatusTransitionConverterTestEntity() {}
|
||||
|
||||
private AllocationTokenStatusTransitionConverterTestEntity(
|
||||
TimedTransitionProperty<TokenStatus, TokenStatusTransition> timedTransitionProperty) {
|
||||
this.timedTransitionProperty = timedTransitionProperty;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assert_;
|
|||
import google.registry.model.billing.BillingEventTest;
|
||||
import google.registry.model.contact.ContactResourceTest;
|
||||
import google.registry.model.domain.DomainBaseSqlTest;
|
||||
import google.registry.model.domain.token.AllocationTokenTest;
|
||||
import google.registry.model.history.ContactHistoryTest;
|
||||
import google.registry.model.history.DomainHistoryTest;
|
||||
import google.registry.model.history.HostHistoryTest;
|
||||
|
@ -72,6 +73,7 @@ import org.junit.runner.RunWith;
|
|||
@SelectClasses({
|
||||
// BeforeSuiteTest must be the first entry. See class javadoc for details.
|
||||
BeforeSuiteTest.class,
|
||||
AllocationTokenTest.class,
|
||||
BillingEventTest.class,
|
||||
ClaimsListDaoTest.class,
|
||||
ContactHistoryTest.class,
|
||||
|
|
|
@ -18,13 +18,16 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTlds;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -167,12 +170,15 @@ class DeleteAllocationTokensCommandTest extends CommandTestCase<DeleteAllocation
|
|||
.setTokenType(SINGLE_USE)
|
||||
.setDomainName(domainName);
|
||||
if (redeemed) {
|
||||
builder.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1051L));
|
||||
String domainToPersist = domainName != null ? domainName : "example.foo";
|
||||
DomainBase domain = persistActiveDomain(domainToPersist);
|
||||
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1051L);
|
||||
builder.setRedemptionHistoryEntry(VKey.create(HistoryEntry.class, 1051L, historyEntryKey));
|
||||
}
|
||||
return persistResource(builder.build());
|
||||
}
|
||||
|
||||
private static Collection<AllocationToken> reloadTokens(AllocationToken ... tokens) {
|
||||
private static Collection<AllocationToken> reloadTokens(AllocationToken... tokens) {
|
||||
return ofy().load().entities(tokens).values();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.io.Files;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.DeterministicStringGenerator.Rule;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -168,7 +168,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
new AllocationToken.Builder()
|
||||
.setToken("promo123456789ABCDEFG")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setAllowedClientIds(ImmutableSet.of("TheRegistrar", "NewRegistrar"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar", "NewRegistrar"))
|
||||
.setAllowedTlds(ImmutableSet.of("tld", "example"))
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountPremiums(true)
|
||||
|
@ -314,7 +314,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
|||
|
||||
private AllocationToken createToken(
|
||||
String token,
|
||||
@Nullable Key<HistoryEntry> redemptionHistoryEntry,
|
||||
@Nullable VKey<HistoryEntry> redemptionHistoryEntry,
|
||||
@Nullable String domainName) {
|
||||
AllocationToken.Builder builder =
|
||||
new AllocationToken.Builder().setToken(token).setTokenType(SINGLE_USE);
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -83,7 +84,8 @@ class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCo
|
|||
.setToken("foo")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setDomainName("fqqdn.tld")
|
||||
.setRedemptionHistoryEntry(Key.create(createHistoryEntryForEppResource(domain)))
|
||||
.setRedemptionHistoryEntry(
|
||||
HistoryEntry.createVKey(Key.create(createHistoryEntryForEppResource(domain))))
|
||||
.build());
|
||||
runCommand("foo");
|
||||
assertInStdout(
|
||||
|
|
|
@ -55,9 +55,9 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
|
|||
void testUpdateClientIds_setClientIds() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
||||
builderWithPromo().setAllowedRegistrarIds(ImmutableSet.of("toRemove")).build());
|
||||
runCommandForced("--prefix", "token", "--allowed_client_ids", "clientone,clienttwo");
|
||||
assertThat(reloadResource(token).getAllowedClientIds())
|
||||
assertThat(reloadResource(token).getAllowedRegistrarIds())
|
||||
.containsExactly("clientone", "clienttwo");
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,9 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
|
|||
void testUpdateClientIds_clearClientIds() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo().setAllowedClientIds(ImmutableSet.of("toRemove")).build());
|
||||
builderWithPromo().setAllowedRegistrarIds(ImmutableSet.of("toRemove")).build());
|
||||
runCommandForced("--prefix", "token", "--allowed_client_ids", "");
|
||||
assertThat(reloadResource(token).getAllowedClientIds()).isEmpty();
|
||||
assertThat(reloadResource(token).getAllowedRegistrarIds()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -175,14 +175,14 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
|
|||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo()
|
||||
.setAllowedClientIds(ImmutableSet.of("clientid"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("clientid"))
|
||||
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||
.setDiscountFraction(0.15)
|
||||
.build());
|
||||
runCommandForced("--prefix", "token");
|
||||
AllocationToken reloaded = reloadResource(token);
|
||||
assertThat(reloaded.getAllowedTlds()).isEqualTo(token.getAllowedTlds());
|
||||
assertThat(reloaded.getAllowedClientIds()).isEqualTo(token.getAllowedClientIds());
|
||||
assertThat(reloaded.getAllowedRegistrarIds()).isEqualTo(token.getAllowedRegistrarIds());
|
||||
assertThat(reloaded.getDiscountFraction()).isEqualTo(token.getDiscountFraction());
|
||||
}
|
||||
|
||||
|
|
|
@ -233,12 +233,12 @@ class google.registry.model.domain.secdns.DelegationSignerData {
|
|||
class google.registry.model.domain.token.AllocationToken {
|
||||
@Id java.lang.String token;
|
||||
boolean discountPremiums;
|
||||
com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
||||
double discountFraction;
|
||||
google.registry.model.CreateAutoTimestamp creationTime;
|
||||
google.registry.model.UpdateAutoTimestamp updateTimestamp;
|
||||
google.registry.model.common.TimedTransitionProperty<google.registry.model.domain.token.AllocationToken$TokenStatus, google.registry.model.domain.token.AllocationToken$TokenStatusTransition> tokenStatusTransitions;
|
||||
google.registry.model.domain.token.AllocationToken$TokenType tokenType;
|
||||
google.registry.persistence.VKey<google.registry.model.reporting.HistoryEntry> redemptionHistoryEntry;
|
||||
int discountYears;
|
||||
java.lang.String domainName;
|
||||
java.util.Set<java.lang.String> allowedClientIds;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue