Handle missing expected fee type in domain create

Also added a couple of more tests to make sure that we cover all edge cases.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=195872013
This commit is contained in:
jianglai 2018-05-08 14:01:13 -07:00
parent 297b8df6a1
commit e5538cfe35
3 changed files with 146 additions and 8 deletions

View file

@ -2245,6 +2245,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
Money.of(USD, 0)))
.build());
EppException thrown = assertThrows(FeeDescriptionParseException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("No fee description");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -2277,6 +2278,98 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testFailure_eapFee_totalAmountNotMatched() throws Exception {
setEppInput(
"domain_create_extra_fees.xml",
new ImmutableMap.Builder<String, String>()
.put("FEE_VERSION", "0.6")
.put("DESCRIPTION_1", "create")
.put("FEE_1", "26")
.put("DESCRIPTION_2", "Early Access Period")
.put("FEE_2", "100")
.put("DESCRIPTION_3", "renew")
.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());
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("expected total of USD 126.00");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_eapFee_multipleEAPfees_doNotAddToExpectedValue() throws Exception {
setEppInput(
"domain_create_extra_fees.xml",
new ImmutableMap.Builder<String, String>()
.put("FEE_VERSION", "0.6")
.put("DESCRIPTION_1", "create")
.put("FEE_1", "26")
.put("DESCRIPTION_2", "Early Access Period")
.put("FEE_2", "55")
.put("DESCRIPTION_3", "Early Access Period")
.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());
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("expected fee of USD 100.00");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@Test
public void testSuccess_eapFee_multipleEAPfees_addToExpectedValue() throws Exception {
setEppInput(
"domain_create_extra_fees.xml",
new ImmutableMap.Builder<String, String>()
.put("FEE_VERSION", "0.6")
.put("DESCRIPTION_1", "create")
.put("FEE_1", "26")
.put("DESCRIPTION_2", "Early Access Period")
.put("FEE_2", "55")
.put("DESCRIPTION_3", "Early Access Period")
.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());
doSuccessfulTest(
"tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
}
@Test
public void testSuccess_eapFee_fullDescription_includingArbitraryExpiryTime() throws Exception {
setEppInput(