Bypass EAP fees for anchor tenants

Note that the check flow does not yet handle any kind of allocation token
handling at all. Step 2 will be to add allocation token handling there, so a
RESERVED_FOR_ANCHOR_TENANT or RESERVED_FOR_SPECIFIC_USE domain will show as
available instead of reserved if the right token is specified using the
extension. Then once that's done, we can use that information to adjust the
price accordingly as well.

Right now the behavior with a domain check is that reserved domains always show
as reserved, even if they're anchor tenants.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215599350
This commit is contained in:
mcilwain 2018-10-03 11:49:25 -07:00 committed by Ben McIlwain
parent ce5bbe4bfa
commit 1586813398
6 changed files with 55 additions and 136 deletions

View file

@ -270,7 +270,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
new ImmutableSet.Builder<BillingEvent>().add(createBillingEvent).add(renewBillingEvent);
// If EAP is applied, a billing event for EAP should be present.
if (!eapFee.isZero()) {
// EAP fees are bypassed for anchor tenant domains.
if (!isAnchorTenant && !eapFee.isZero()) {
BillingEvent.OneTime eapBillingEvent =
new BillingEvent.OneTime.Builder()
.setReason(Reason.FEE_EARLY_ACCESS)
@ -1012,6 +1013,22 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.isEqualTo(Key.create(getHistoryEntries(reloadResourceByForeignKey()).get(0)));
}
@Test
public void testSuccess_anchorTenant_bypassesEapFees() throws Exception {
setEapForTld("tld");
// This XML file does not contain EAP fees.
setEppInput("domain_create_anchor_allocationtoken.xml");
persistContactsAndHosts();
runFlowAssertResponse(loadFile("domain_create_anchor_response.xml"));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT));
assertNoLordn();
AllocationToken reloadedToken =
ofy().load().key(Key.create(AllocationToken.class, "abcDEF23456")).now();
assertThat(reloadedToken.isRedeemed()).isTrue();
assertThat(reloadedToken.getRedemptionHistoryEntry())
.isEqualTo(Key.create(getHistoryEntries(reloadResourceByForeignKey()).get(0)));
}
@Test
public void testSuccess_anchorTenant_viaAuthCode_withClaims() throws Exception {
persistResource(
@ -2242,18 +2259,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_eapFee_combined() {
setEppInput("domain_create_eap_combined_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
EppException thrown = assertThrows(FeeDescriptionParseException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("No fee description");
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -2271,18 +2277,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"DESCRIPTION_2",
"create"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("CREATE");
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -2302,18 +2297,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.put("FEE_3", "55")
.build());
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("expected total of USD 126.00");
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -2333,18 +2317,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.put("FEE_3", "55")
.build());
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("expected fee of USD 100.00");
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -2364,18 +2337,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.put("FEE_3", "45")
.build());
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
}
@ -2392,18 +2354,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"DESCRIPTION_2",
"Early Access Period, fee expires: 2022-03-01T00:00:00.000Z"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
}
@ -2415,18 +2366,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
ImmutableMap.of(
"FEE_VERSION", "0.6", "DESCRIPTION_1", "create", "DESCRIPTION_2", "renew transfer"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
EppException thrown = assertThrows(FeeDescriptionMultipleMatchesException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("RENEW, TRANSFER");
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -2444,18 +2384,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"DESCRIPTION_2",
"Early Access Period"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
}
@ -2472,18 +2401,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"DESCRIPTION_2",
"Early Access Period"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
}
@ -2500,18 +2418,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"DESCRIPTION_2",
"Early Access Period"));
persistContactsAndHosts();
persistResource(
Registry.get("tld")
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
setEapForTld("tld");
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
}
@ -2519,8 +2426,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test
public void testFailure_domainInEap_failsWithoutFeeExtension() {
persistContactsAndHosts();
setEapForTld("tld");
Exception e = assertThrows(FeesRequiredDuringEarlyAccessProgramException.class, this::runFlow);
assertThat(e)
.hasMessageThat()
.isEqualTo(
"Fees must be explicitly acknowledged when creating domains "
+ "during the Early Access Program. The EAP fee is: USD 100.00");
}
private void setEapForTld(String tld) {
persistResource(
Registry.get("tld")
Registry.get(tld)
.asBuilder()
.setEapFeeSchedule(
ImmutableSortedMap.of(
@ -2531,12 +2448,6 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.nowUtc().plusDays(1),
Money.of(USD, 0)))
.build());
Exception e = assertThrows(FeesRequiredDuringEarlyAccessProgramException.class, this::runFlow);
assertThat(e)
.hasMessageThat()
.isEqualTo(
"Fees must be explicitly acknowledged when creating domains "
+ "during the Early Access Program. The EAP fee is: USD 100.00");
}
@Test