Add domain lifecycle test for renew with total term >10 years

Also some minor cleanup to make renewal testdata files easier to reuse.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187508329
This commit is contained in:
mcilwain 2018-03-01 11:36:03 -08:00 committed by jianglai
parent 27894df45f
commit ef26dabf32
6 changed files with 79 additions and 24 deletions

View file

@ -817,6 +817,21 @@ public class EppLifecycleDomainTest extends EppTestCase {
assertCommandAndResponse("logout.xml", "logout_response.xml"); assertCommandAndResponse("logout.xml", "logout_response.xml");
} }
@Test
public void testRenewalFails_whenTotalTermExceeds10Years() throws Exception {
assertCommandAndResponse("login_valid.xml", "login_response.xml");
// Creates domain with 2 year expiration.
createFakesite();
// Attempt to renew for 9 years, adding up to a total greater than the allowed max of 10 years.
assertCommandAndResponse(
"domain_renew.xml",
ImmutableMap.of("DOMAIN", "fakesite.example", "EXPDATE", "2002-06-01", "YEARS", "9"),
"domain_renew_response_exceeds_max_years.xml",
ImmutableMap.of(),
DateTime.parse("2000-06-07T00:00:00Z"));
assertCommandAndResponse("logout.xml", "logout_response.xml");
}
@Test @Test
public void testDomainDeletionCancelsPendingTransfer() throws Exception { public void testDomainDeletionCancelsPendingTransfer() throws Exception {
// Register the domain as the first registrar. // Register the domain as the first registrar.

View file

@ -83,14 +83,11 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z"); final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
public DomainRenewFlowTest() {
clock.setTo(expirationTime.minusMillis(2));
setEppInput("domain_renew.xml");
}
@Before @Before
public void initDomainTest() { public void initDomainTest() {
createTld("tld"); createTld("tld");
clock.setTo(expirationTime.minusMillis(2));
setEppInput("domain_renew.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "5"));
} }
private void persistDomain(StatusValue... statusValues) throws Exception { private void persistDomain(StatusValue... statusValues) throws Exception {
@ -122,7 +119,6 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setMsg("Domain was auto-renewed.") .setMsg("Domain was auto-renewed.")
.setParent(historyEntryDomainCreate) .setParent(historyEntryDomainCreate)
.build()); .build());
domain =
persistResource( persistResource(
domain domain
.asBuilder() .asBuilder()
@ -228,13 +224,19 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
@Test @Test
public void testDryRun() throws Exception { public void testDryRun() throws Exception {
persistDomain(); persistDomain();
dryRunFlowAssertResponse(loadFile("domain_renew_response.xml")); dryRunFlowAssertResponse(
loadFile(
"domain_renew_response.xml",
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
} }
@Test @Test
public void testSuccess() throws Exception { public void testSuccess() throws Exception {
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response.xml", 5); doSuccessfulTest(
"domain_renew_response.xml",
5,
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z"));
} }
@Test @Test
@ -380,7 +382,10 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setRenewGracePeriodLength(Duration.standardMinutes(9)) .setRenewGracePeriodLength(Duration.standardMinutes(9))
.build()); .build());
persistDomain(); persistDomain();
doSuccessfulTest("domain_renew_response.xml", 5); doSuccessfulTest(
"domain_renew_response.xml",
5,
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z"));
} }
@Test @Test
@ -402,7 +407,10 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.asBuilder() .asBuilder()
.setEventTime(expirationTime.minusYears(1)) .setEventTime(expirationTime.minusYears(1))
.build()); .build());
runFlowAssertResponse(loadFile("domain_renew_response.xml")); runFlowAssertResponse(
loadFile(
"domain_renew_response.xml",
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
HistoryEntry historyEntryDomainRenew = HistoryEntry historyEntryDomainRenew =
getOnlyHistoryEntryOfType(reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_RENEW); getOnlyHistoryEntryOfType(reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_RENEW);
assertPollMessages( assertPollMessages(
@ -644,7 +652,11 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
sessionMetadata.setClientId("NewRegistrar"); sessionMetadata.setClientId("NewRegistrar");
persistDomain(); persistDomain();
runFlowAssertResponse( runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_renew_response.xml")); CommitMode.LIVE,
UserPrivileges.SUPERUSER,
loadFile(
"domain_renew_response.xml",
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
} }
@Test @Test
@ -662,7 +674,11 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistDomain(); persistDomain();
runFlowAssertResponse( runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_renew_response.xml")); CommitMode.LIVE,
UserPrivileges.SUPERUSER,
loadFile(
"domain_renew_response.xml",
ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z")));
} }
@Test @Test

View file

@ -3,9 +3,9 @@
<renew> <renew>
<domain:renew <domain:renew
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name> <domain:name>%DOMAIN%</domain:name>
<domain:curExpDate>2000-04-03</domain:curExpDate> <domain:curExpDate>2000-04-03</domain:curExpDate>
<domain:period unit="y">5</domain:period> <domain:period unit="y">%YEARS%</domain:period>
</domain:renew> </domain:renew>
</renew> </renew>
<clTRID>ABC-12345</clTRID> <clTRID>ABC-12345</clTRID>

View file

@ -6,8 +6,8 @@
<resData> <resData>
<domain:renData <domain:renData
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"> xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name> <domain:name>%DOMAIN%</domain:name>
<domain:exDate>2005-04-03T22:00:00.0Z</domain:exDate> <domain:exDate>%EXDATE%</domain:exDate>
</domain:renData> </domain:renData>
</resData> </resData>
<trID> <trID>

View file

@ -0,0 +1,13 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<renew>
<domain:renew
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>%DOMAIN%</domain:name>
<domain:curExpDate>%EXPDATE%</domain:curExpDate>
<domain:period unit="y">%YEARS%</domain:period>
</domain:renew>
</renew>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,11 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<response>
<result code="2004">
<msg>New registration period exceeds maximum number of years (10)</msg>
</result>
<trID>
<clTRID>ABC-12345</clTRID>
<svTRID>server-trid</svTRID>
</trID>
</response>
</epp>