mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 02:36:03 +02:00
Check for default tokens in the renew flow (#1978)
* Check for default tokens in the renew flow * Remove extra check * Add allowed action
This commit is contained in:
parent
f8a820ba38
commit
33b43c05e7
3 changed files with 429 additions and 5 deletions
|
@ -275,7 +275,7 @@ public final class DomainCreateFlow implements TransactionalFlow {
|
||||||
now,
|
now,
|
||||||
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
||||||
boolean defaultTokenUsed = false;
|
boolean defaultTokenUsed = false;
|
||||||
if (!allocationToken.isPresent() && !registry.getDefaultPromoTokens().isEmpty()) {
|
if (!allocationToken.isPresent()) {
|
||||||
allocationToken =
|
allocationToken =
|
||||||
DomainFlowUtils.checkForDefaultToken(
|
DomainFlowUtils.checkForDefaultToken(
|
||||||
registry, command.getDomainName(), CommandName.CREATE, registrarId, now);
|
registry, command.getDomainName(), CommandName.CREATE, registrarId, now);
|
||||||
|
|
|
@ -173,14 +173,25 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
Renew command = (Renew) resourceCommand;
|
Renew command = (Renew) resourceCommand;
|
||||||
// Loads the target resource if it exists
|
// Loads the target resource if it exists
|
||||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||||
|
String tld = existingDomain.getTld();
|
||||||
|
Registry registry = Registry.get(tld);
|
||||||
Optional<AllocationToken> allocationToken =
|
Optional<AllocationToken> allocationToken =
|
||||||
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
allocationTokenFlowUtils.verifyAllocationTokenIfPresent(
|
||||||
existingDomain,
|
existingDomain,
|
||||||
Registry.get(existingDomain.getTld()),
|
registry,
|
||||||
registrarId,
|
registrarId,
|
||||||
now,
|
now,
|
||||||
CommandName.RENEW,
|
CommandName.RENEW,
|
||||||
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
eppInput.getSingleExtension(AllocationTokenExtension.class));
|
||||||
|
boolean defaultTokenUsed = false;
|
||||||
|
if (!allocationToken.isPresent()) {
|
||||||
|
allocationToken =
|
||||||
|
DomainFlowUtils.checkForDefaultToken(
|
||||||
|
registry, existingDomain.getDomainName(), CommandName.RENEW, registrarId, now);
|
||||||
|
if (allocationToken.isPresent()) {
|
||||||
|
defaultTokenUsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
verifyRenewAllowed(authInfo, existingDomain, command, allocationToken);
|
verifyRenewAllowed(authInfo, existingDomain, command, allocationToken);
|
||||||
|
|
||||||
// If client passed an applicable static token this updates the domain
|
// If client passed an applicable static token this updates the domain
|
||||||
|
@ -202,7 +213,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
years,
|
years,
|
||||||
existingRecurringBillingEvent,
|
existingRecurringBillingEvent,
|
||||||
allocationToken);
|
allocationToken);
|
||||||
validateFeeChallenge(feeRenew, feesAndCredits, false);
|
validateFeeChallenge(feeRenew, feesAndCredits, defaultTokenUsed);
|
||||||
flowCustomLogic.afterValidation(
|
flowCustomLogic.afterValidation(
|
||||||
AfterValidationParameters.newBuilder()
|
AfterValidationParameters.newBuilder()
|
||||||
.setExistingDomain(existingDomain)
|
.setExistingDomain(existingDomain)
|
||||||
|
@ -211,7 +222,6 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
.build());
|
.build());
|
||||||
HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain);
|
HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain);
|
||||||
historyBuilder.setRevisionId(domainHistoryId.getRevisionId());
|
historyBuilder.setRevisionId(domainHistoryId.getRevisionId());
|
||||||
String tld = existingDomain.getTld();
|
|
||||||
// Bill for this explicit renew itself.
|
// Bill for this explicit renew itself.
|
||||||
BillingEvent.OneTime explicitRenewEvent =
|
BillingEvent.OneTime explicitRenewEvent =
|
||||||
createRenewBillingEvent(
|
createRenewBillingEvent(
|
||||||
|
@ -244,7 +254,6 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
||||||
GracePeriod.forBillingEvent(
|
GracePeriod.forBillingEvent(
|
||||||
GracePeriodStatus.RENEW, existingDomain.getRepoId(), explicitRenewEvent))
|
GracePeriodStatus.RENEW, existingDomain.getRepoId(), explicitRenewEvent))
|
||||||
.build();
|
.build();
|
||||||
Registry registry = Registry.get(existingDomain.getTld());
|
|
||||||
DomainHistory domainHistory =
|
DomainHistory domainHistory =
|
||||||
buildDomainHistory(
|
buildDomainHistory(
|
||||||
newDomain, now, command.getPeriod(), registry.getRenewGracePeriodLength());
|
newDomain, now, command.getPeriod(), registry.getRenewGracePeriodLength());
|
||||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWit
|
||||||
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT;
|
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT;
|
||||||
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.NONPREMIUM;
|
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.NONPREMIUM;
|
||||||
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SPECIFIED;
|
import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SPECIFIED;
|
||||||
|
import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO;
|
||||||
import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE;
|
import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE;
|
||||||
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
|
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.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
|
||||||
|
@ -46,6 +47,7 @@ import static org.joda.money.CurrencyUnit.JPY;
|
||||||
import static org.joda.money.CurrencyUnit.USD;
|
import static org.joda.money.CurrencyUnit.USD;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
|
@ -85,6 +87,7 @@ import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||||
import google.registry.model.domain.Domain;
|
import google.registry.model.domain.Domain;
|
||||||
import google.registry.model.domain.DomainHistory;
|
import google.registry.model.domain.DomainHistory;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
|
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||||
import google.registry.model.domain.token.AllocationToken;
|
import google.registry.model.domain.token.AllocationToken;
|
||||||
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||||
|
@ -1374,4 +1377,416 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||||
"domain_renew_response.xml",
|
"domain_renew_response.xml",
|
||||||
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_usesDefaultToken() throws Exception {
|
||||||
|
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken2 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("bbbbb")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.75)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(
|
||||||
|
ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
|
BillingEvent.OneTime billingEvent =
|
||||||
|
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.OneTime.class));
|
||||||
|
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||||
|
assertThat(billingEvent.getAllocationToken().get().getKey())
|
||||||
|
.isEqualTo(defaultToken1.getToken());
|
||||||
|
// Price is 50% off the first year only. Non-discounted price is $11.
|
||||||
|
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 16.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_doesNotUseDefaultTokenWhenTokenPassedIn() throws Exception {
|
||||||
|
setEppInput(
|
||||||
|
"domain_renew_allocationtoken.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2", "TOKEN", "abc123"));
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken allocationToken =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("abc123")
|
||||||
|
.setTokenType(SINGLE_USE)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.25)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken2 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("bbbbb")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.75)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(
|
||||||
|
ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
|
BillingEvent.OneTime billingEvent =
|
||||||
|
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.OneTime.class));
|
||||||
|
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||||
|
assertThat(billingEvent.getAllocationToken().get().getKey())
|
||||||
|
.isEqualTo(allocationToken.getToken());
|
||||||
|
// Price is 50% off the first year only. Non-discounted price is $11.
|
||||||
|
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 16.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_noValidDefaultToken() throws Exception {
|
||||||
|
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedRegistrarIds(ImmutableSet.of("OtherRegistrar"))
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken2 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("bbbbb")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.75)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedRegistrarIds(ImmutableSet.of("OtherRegistrar"))
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(
|
||||||
|
ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
|
BillingEvent.OneTime billingEvent =
|
||||||
|
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.OneTime.class));
|
||||||
|
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||||
|
assertThat(billingEvent.getAllocationToken()).isEmpty();
|
||||||
|
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 22));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_onlyUsesFirstValidToken() throws Exception {
|
||||||
|
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.25)
|
||||||
|
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken2 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("bbbbb")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken3 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("ccccc")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.75)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(
|
||||||
|
ImmutableList.of(
|
||||||
|
defaultToken1.createVKey(),
|
||||||
|
defaultToken2.createVKey(),
|
||||||
|
defaultToken3.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
|
BillingEvent.OneTime billingEvent =
|
||||||
|
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.OneTime.class));
|
||||||
|
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||||
|
assertThat(billingEvent.getAllocationToken().get().getKey())
|
||||||
|
.isEqualTo(defaultToken2.getToken());
|
||||||
|
// Price is 50% off the first year only. Non-discounted price is $11.
|
||||||
|
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 16.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_registryHasDeletedDefaultToken() throws Exception {
|
||||||
|
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
AllocationToken defaultToken2 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("bbbbb")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.75)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(
|
||||||
|
ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey()))
|
||||||
|
.build());
|
||||||
|
DatabaseHelper.deleteResource(defaultToken1);
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response.xml",
|
||||||
|
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2002-04-03T22:00:00.0Z")));
|
||||||
|
BillingEvent.OneTime billingEvent =
|
||||||
|
Iterables.getOnlyElement(DatabaseHelper.loadAllOf(BillingEvent.OneTime.class));
|
||||||
|
assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
|
||||||
|
assertThat(billingEvent.getAllocationToken().get().getKey())
|
||||||
|
.isEqualTo(defaultToken2.getToken());
|
||||||
|
// Price is 75% off the first year only. Non-discounted price is $11.
|
||||||
|
assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, 13.75));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_wrongFeeAmountTooHigh_defaultToken_v06() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response_fee.xml",
|
||||||
|
ImmutableMap.of(
|
||||||
|
"NAME",
|
||||||
|
"example.tld",
|
||||||
|
"PERIOD",
|
||||||
|
"5",
|
||||||
|
"EX_DATE",
|
||||||
|
"2005-04-03T22:00:00.0Z",
|
||||||
|
"FEE",
|
||||||
|
"49.50",
|
||||||
|
"CURRENCY",
|
||||||
|
"USD",
|
||||||
|
"FEE_VERSION",
|
||||||
|
"0.6",
|
||||||
|
"FEE_NS",
|
||||||
|
"fee")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFailure_wrongFeeAmountTooLow_defaultToken_v06() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||||
|
.build());
|
||||||
|
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_wrongFeeAmountTooHigh_defaultToken_v11() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response_fee.xml",
|
||||||
|
ImmutableMap.of(
|
||||||
|
"NAME",
|
||||||
|
"example.tld",
|
||||||
|
"PERIOD",
|
||||||
|
"5",
|
||||||
|
"EX_DATE",
|
||||||
|
"2005-04-03T22:00:00.0Z",
|
||||||
|
"FEE",
|
||||||
|
"49.50",
|
||||||
|
"CURRENCY",
|
||||||
|
"USD",
|
||||||
|
"FEE_VERSION",
|
||||||
|
"0.11",
|
||||||
|
"FEE_NS",
|
||||||
|
"fee")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFailure_wrongFeeAmountTooLow_defaultToken_v11() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_11_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||||
|
.build());
|
||||||
|
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSuccess_wrongFeeAmountTooHigh_defaultToken_v12() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_12_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.build());
|
||||||
|
runFlowAssertResponse(
|
||||||
|
loadFile(
|
||||||
|
"domain_renew_response_fee.xml",
|
||||||
|
ImmutableMap.of(
|
||||||
|
"NAME",
|
||||||
|
"example.tld",
|
||||||
|
"PERIOD",
|
||||||
|
"5",
|
||||||
|
"EX_DATE",
|
||||||
|
"2005-04-03T22:00:00.0Z",
|
||||||
|
"FEE",
|
||||||
|
"49.50",
|
||||||
|
"CURRENCY",
|
||||||
|
"USD",
|
||||||
|
"FEE_VERSION",
|
||||||
|
"0.12",
|
||||||
|
"FEE_NS",
|
||||||
|
"fee")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFailure_wrongFeeAmountTooLow_defaultToken_v12() throws Exception {
|
||||||
|
setEppInput("domain_renew_fee.xml", FEE_06_MAP);
|
||||||
|
persistDomain();
|
||||||
|
AllocationToken defaultToken1 =
|
||||||
|
persistResource(
|
||||||
|
new AllocationToken.Builder()
|
||||||
|
.setToken("aaaaa")
|
||||||
|
.setTokenType(DEFAULT_PROMO)
|
||||||
|
.setDiscountFraction(0.5)
|
||||||
|
.setDiscountYears(1)
|
||||||
|
.setAllowedTlds(ImmutableSet.of("tld"))
|
||||||
|
.build());
|
||||||
|
persistResource(
|
||||||
|
Registry.get("tld")
|
||||||
|
.asBuilder()
|
||||||
|
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||||
|
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||||
|
.build());
|
||||||
|
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||||
|
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue