mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Add the ability to require premium fee acking for a registrar
When enabled for a registrar, all EPP operations on premium domains that have costs (e.g. creates, renews, transfers) will fail unless the EPP fee extension is used to explicitly ack the amount of fee as part of the EPP transaction. This ack is required regardless of whether premium fee acking is required at the registry level. No data migration is necessary since false is the desired default for this new attribute. This CL also contains some slight refactoring of static utility methods used to perform fee verification; there was short-circuiting at call-sites in two places when what was really needed was two methods, one implementing additional functionality on top of the other, and calling the inner method in the places where short-circuiting had previously been necessary. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=184229363
This commit is contained in:
parent
6bcd40f18a
commit
98a61b8181
20 changed files with 264 additions and 119 deletions
|
@ -198,64 +198,6 @@ public class DomainTransferRequestFlowTest
|
|||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a successful test. The extraExpectedBillingEvents parameter consists of cancellation
|
||||
* billing event builders that have had all of their attributes set except for the parent history
|
||||
* entry, which is filled in during the execution of this method.
|
||||
*/
|
||||
private void doSuccessfulTest(
|
||||
String commandFilename,
|
||||
String expectedXmlFilename,
|
||||
DateTime expectedExpirationTime,
|
||||
Map<String, String> substitutions,
|
||||
Optional<Money> transferCost,
|
||||
BillingEvent.Cancellation.Builder... extraExpectedBillingEvents)
|
||||
throws Exception {
|
||||
setEppInput(commandFilename, substitutions);
|
||||
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
|
||||
// Replace the ROID in the xml file with the one generated in our test.
|
||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||
// For all of the other transfer flow tests, 'now' corresponds to day 3 of the transfer, but
|
||||
// for the request test we want that same 'now' to be the initial request time, so we shift
|
||||
// the transfer timeline 3 days later by adjusting the implicit transfer time here.
|
||||
Registry registry = Registry.get(domain.getTld());
|
||||
DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength());
|
||||
// Setup done; run the test.
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(loadFile(expectedXmlFilename, substitutions));
|
||||
// Transfer should have been requested.
|
||||
domain = reloadResourceByForeignKey();
|
||||
// Verify that HistoryEntry was created.
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_TRANSFER_REQUEST);
|
||||
final HistoryEntry historyEntryTransferRequest =
|
||||
getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REQUEST);
|
||||
assertAboutHistoryEntries()
|
||||
.that(historyEntryTransferRequest)
|
||||
.hasPeriodYears(1)
|
||||
.and()
|
||||
.hasOtherClientId("TheRegistrar");
|
||||
// Verify correct fields were set.
|
||||
assertTransferRequested(
|
||||
domain, implicitTransferTime, Period.create(1, Unit.YEARS), expectedExpirationTime);
|
||||
|
||||
subordinateHost = reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc());
|
||||
assertAboutHosts().that(subordinateHost).hasNoHistoryEntries();
|
||||
|
||||
assertHistoryEntriesContainBillingEventsAndGracePeriods(
|
||||
expectedExpirationTime,
|
||||
implicitTransferTime,
|
||||
transferCost,
|
||||
originalGracePeriods,
|
||||
/* expectTransferBillingEvent = */ true,
|
||||
extraExpectedBillingEvents);
|
||||
|
||||
assertPollMessagesEmitted(expectedExpirationTime, implicitTransferTime);
|
||||
assertAboutDomainAfterAutomaticTransfer(
|
||||
expectedExpirationTime, implicitTransferTime, Period.create(1, Unit.YEARS));
|
||||
}
|
||||
|
||||
/** Implements the missing Optional.stream function that is added in Java 9. */
|
||||
private static <T> Stream<T> optionalToStream(Optional<T> optional) {
|
||||
return optional.map(Stream::of).orElseGet(Stream::empty);
|
||||
|
@ -484,6 +426,64 @@ public class DomainTransferRequestFlowTest
|
|||
assertThat(afterGracePeriod.getGracePeriods()).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a successful test. The extraExpectedBillingEvents parameter consists of cancellation
|
||||
* billing event builders that have had all of their attributes set except for the parent history
|
||||
* entry, which is filled in during the execution of this method.
|
||||
*/
|
||||
private void doSuccessfulTest(
|
||||
String commandFilename,
|
||||
String expectedXmlFilename,
|
||||
DateTime expectedExpirationTime,
|
||||
Map<String, String> substitutions,
|
||||
Optional<Money> transferCost,
|
||||
BillingEvent.Cancellation.Builder... extraExpectedBillingEvents)
|
||||
throws Exception {
|
||||
setEppInput(commandFilename, substitutions);
|
||||
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
|
||||
// Replace the ROID in the xml file with the one generated in our test.
|
||||
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
|
||||
// For all of the other transfer flow tests, 'now' corresponds to day 3 of the transfer, but
|
||||
// for the request test we want that same 'now' to be the initial request time, so we shift
|
||||
// the transfer timeline 3 days later by adjusting the implicit transfer time here.
|
||||
Registry registry = Registry.get(domain.getTld());
|
||||
DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength());
|
||||
// Setup done; run the test.
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(loadFile(expectedXmlFilename, substitutions));
|
||||
// Transfer should have been requested.
|
||||
domain = reloadResourceByForeignKey();
|
||||
// Verify that HistoryEntry was created.
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_TRANSFER_REQUEST);
|
||||
final HistoryEntry historyEntryTransferRequest =
|
||||
getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REQUEST);
|
||||
assertAboutHistoryEntries()
|
||||
.that(historyEntryTransferRequest)
|
||||
.hasPeriodYears(1)
|
||||
.and()
|
||||
.hasOtherClientId("TheRegistrar");
|
||||
// Verify correct fields were set.
|
||||
assertTransferRequested(
|
||||
domain, implicitTransferTime, Period.create(1, Unit.YEARS), expectedExpirationTime);
|
||||
|
||||
subordinateHost = reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc());
|
||||
assertAboutHosts().that(subordinateHost).hasNoHistoryEntries();
|
||||
|
||||
assertHistoryEntriesContainBillingEventsAndGracePeriods(
|
||||
expectedExpirationTime,
|
||||
implicitTransferTime,
|
||||
transferCost,
|
||||
originalGracePeriods,
|
||||
/* expectTransferBillingEvent = */ true,
|
||||
extraExpectedBillingEvents);
|
||||
|
||||
assertPollMessagesEmitted(expectedExpirationTime, implicitTransferTime);
|
||||
assertAboutDomainAfterAutomaticTransfer(
|
||||
expectedExpirationTime, implicitTransferTime, Period.create(1, Unit.YEARS));
|
||||
}
|
||||
|
||||
private void doSuccessfulTest(
|
||||
String commandFilename,
|
||||
String expectedXmlFilename,
|
||||
|
@ -1202,7 +1202,7 @@ public class DomainTransferRequestFlowTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_feeNotProvidedOnPremiumName() throws Exception {
|
||||
public void testFailure_registryRequiresAcking_feeNotProvidedOnPremiumName() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
EppException thrown =
|
||||
expectThrows(
|
||||
|
@ -1211,6 +1211,20 @@ public class DomainTransferRequestFlowTest
|
|||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_registrarRequiresAcking_feeNotProvidedOnPremiumName() throws Exception {
|
||||
setupDomain("rich", "example");
|
||||
persistResource(Registry.get("example").asBuilder().setPremiumPriceAckRequired(false).build());
|
||||
persistResource(
|
||||
loadRegistrar("NewRegistrar").asBuilder().setPremiumPriceAckRequired(true).build());
|
||||
clock.advanceOneMilli();
|
||||
EppException thrown =
|
||||
expectThrows(
|
||||
FeesRequiredForPremiumNameException.class,
|
||||
() -> doFailingTest("domain_transfer_request_premium.xml"));
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_noAuthInfo() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue