Don't expect a renewal fee on restores when one isn't due (#637)

* Don't expect a renewal fee on restores when one isn't due

This is a fix on top of #632 so that domain restore commands don't require
acking an illusory renewal fee for 1 year when that isn't actually happening
(i.e. if the domain isn't yet past its original expiration).

Unfortunately, there's still a problem remaining wherein the restore fee on a
domain check will always include the additional year even if it's not
necessary. We don't have a good solution to that. Also note that in versions of
the fee extension more recent than 0.6, the fee extension cannot be passed on a
domain info command at all, so the domain check command is the only way you have
to determine what the restore fee should be. So we definitely do want to get
that right so that the apparent restore fee on a check is the same as the actual
restore fee when running the restore command. We're not quite there yet though
and it's hard to say how we will get there, since we don't load domains during a
domain check command for performance reasons yet we would need to do so in order
to know the expiration date and thus whether the additional year of renewal
should be charged.

A problem for a future PR.
This commit is contained in:
Ben McIlwain 2020-06-22 15:24:36 -04:00 committed by GitHub
parent a8a235c5f0
commit ec9ca23507
14 changed files with 269 additions and 34 deletions

View file

@ -659,6 +659,39 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
doSuccessfulTest("domain_info_fee_restore_response.xml", false);
}
@Test
public void testFeeExtension_restoreCommand_pendingDelete_noRenewal() throws Exception {
setEppInput(
"domain_info_fee.xml",
updateSubstitutions(SUBSTITUTION_BASE, "COMMAND", "restore", "PERIOD", "1"));
persistTestEntities(false);
persistResource(
domain
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
doSuccessfulTest("domain_info_fee_restore_response_no_renewal.xml", false);
}
@Test
public void testFeeExtension_restoreCommand_pendingDelete_withRenewal() throws Exception {
createTld("example");
setEppInput(
"domain_info_fee.xml",
updateSubstitutions(
SUBSTITUTION_BASE, "NAME", "rich.example", "COMMAND", "restore", "PERIOD", "1"));
persistTestEntities("rich.example", false);
persistResource(
domain
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
doSuccessfulTest("domain_info_fee_restore_response_with_renewal.xml", false);
}
/** Test create command on a premium label. */
@Test
public void testFeeExtension_createCommandPremium() throws Exception {

View file

@ -94,7 +94,8 @@ public class DomainRestoreRequestFlowTest
}
void persistPendingDeleteDomain() throws Exception {
persistPendingDeleteDomain(clock.nowUtc().plusYears(5).plusDays(45));
// The domain is now past what had been its expiration date at the time of deletion.
persistPendingDeleteDomain(clock.nowUtc().minusDays(5));
}
void persistPendingDeleteDomain(DateTime expirationTime) throws Exception {
@ -285,6 +286,14 @@ public class DomainRestoreRequestFlowTest
runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_06_MAP));
}
@Test
public void testSuccess_fee_v06_noRenewal() throws Exception {
setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP);
persistPendingDeleteDomain(clock.nowUtc().plusMonths(6));
runFlowAssertResponse(
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_06_MAP));
}
@Test
public void testSuccess_fee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee.xml", FEE_11_MAP);
@ -410,6 +419,15 @@ public class DomainRestoreRequestFlowTest
runFlowAssertResponse(loadFile("domain_update_restore_request_response_premium.xml"));
}
@Test
public void testSuccess_premiumNotBlocked_andNoRenewal() throws Exception {
createTld("example");
setEppInput("domain_update_restore_request_premium_no_renewal.xml");
persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
runFlowAssertResponse(
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_12_MAP));
}
@Test
public void testSuccess_superuserOverridesReservedList() throws Exception {
persistResource(