Add EAP fees to domain create flow

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126411200
This commit is contained in:
ctingue 2016-07-01 08:16:31 -07:00 committed by Ben McIlwain
parent d6bd2d56cd
commit 273fc0014d
7 changed files with 118 additions and 18 deletions

View file

@ -161,6 +161,16 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
private void assertSuccessfulCreate(String domainTld, boolean isAnchorTenant) throws Exception {
DomainResource domain = reloadResourceByUniqueId();
// Calculate the total cost.
Money cost = getPricesForDomainName(getUniqueIdFromCommand(), clock.nowUtc()).isPremium()
? Money.of(USD, 200)
: Money.of(USD, 26);
Money eapFee = Registry.get(domainTld).getEapFeeFor(clock.nowUtc()).getCost();
if (!eapFee.isZero()) {
cost = Money.total(cost, eapFee);
}
DateTime billingTime = isAnchorTenant
? clock.nowUtc().plus(Registry.get(domainTld).getAnchorTenantAddGracePeriodLength())
: clock.nowUtc().plus(Registry.get(domainTld).getAddGracePeriodLength());
@ -178,9 +188,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setReason(Reason.CREATE)
.setTargetId(getUniqueIdFromCommand())
.setClientId("TheRegistrar")
.setCost(getPricesForDomainName(getUniqueIdFromCommand(), clock.nowUtc()).isPremium()
? Money.of(USD, 200)
: Money.of(USD, 26))
.setCost(cost)
.setPeriodYears(2)
.setEventTime(clock.nowUtc())
.setBillingTime(billingTime)
@ -1280,4 +1288,41 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistContactsAndHosts();
doSuccessfulTest("tld", "domain_create_response.xml");
}
@Test
public void testSuccess_eapFeeApplied() throws Exception {
setEppInput("domain_create_eap_fee.xml");
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());
doSuccessfulTest("tld", "domain_create_response_eap_fee.xml");
}
@Test
public void testSuccess_eapFee_beforeEntireSchedule() throws Exception {
persistContactsAndHosts();
persistResource(Registry.get("tld").asBuilder()
.setEapFeeSchedule(ImmutableSortedMap.of(
START_OF_TIME, Money.of(USD, 0),
clock.nowUtc().plusDays(1), Money.of(USD, 10),
clock.nowUtc().plusDays(2), Money.of(USD, 0)))
.build());
doSuccessfulTest("tld", "domain_create_response.xml");
}
@Test
public void testSuccess_eapFee_afterEntireSchedule() throws Exception {
persistContactsAndHosts();
persistResource(Registry.get("tld").asBuilder()
.setEapFeeSchedule(ImmutableSortedMap.of(
START_OF_TIME, Money.of(USD, 0),
clock.nowUtc().minusDays(2), Money.of(USD, 100),
clock.nowUtc().minusDays(1), Money.of(USD, 0)))
.build());
doSuccessfulTest("tld", "domain_create_response.xml");
}
}

View file

@ -0,0 +1,29 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:period unit="y">2</domain:period>
<domain:ns>
<domain:hostObj>ns1.example.net</domain:hostObj>
<domain:hostObj>ns2.example.net</domain:hostObj>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
<fee:currency>USD</fee:currency>
<fee:fee>26.00</fee:fee>
<fee:fee description="Early Access Period">100.00</fee:fee>
</fee:create>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,26 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="1000">
<msg>Command completed successfully</msg>
</result>
<resData>
<domain:creData
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:crDate>1999-04-03T22:00:00.0Z</domain:crDate>
<domain:exDate>2001-04-03T22:00:00.0Z</domain:exDate>
</domain:creData>
</resData>
<extension>
<fee:creData xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
<fee:currency>USD</fee:currency>
<fee:fee description="create">26.00</fee:fee>
<fee:fee description="Early Access Period, fee expires: 1999-04-04T22:00:00.000Z">100.00</fee:fee>
</fee:creData>
</extension>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>