mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Clean up flow validation of registration periods
This tidies up some logic in the flows that checks registration periods, so that in the create flows we're consistently checking that the requested number of years is <= 10 right away (DomainCreateFlow was deferring it until very late, including after custom logic ran, for no good reason I can see). It also refactors the validateRegistrationPeriod() overload used by DomainRenewFlow to take the newExpirationTime directly, and just check to ensure that it's >= to now.plusYears(10) (with leap-safety just in case). This is a much simpler check than before, which recomputed the newExpirationTime separately from the logic used by DomainRenewFlow itself (always dangerous) and did a more convoluted and unnecessary comparison involving extendRegistrationWithCap(). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151002960
This commit is contained in:
parent
bb4a59203a
commit
ec4ffe53f0
5 changed files with 12 additions and 16 deletions
|
@ -133,6 +133,9 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
|||
DomainResource existingDomain = loadAndVerifyExistence(DomainResource.class, targetId, now);
|
||||
verifyRenewAllowed(authInfo, existingDomain, command);
|
||||
int years = command.getPeriod().getValue();
|
||||
DateTime newExpirationTime =
|
||||
leapSafeAddYears(existingDomain.getRegistrationExpirationTime(), years); // Uncapped
|
||||
validateRegistrationPeriod(now, newExpirationTime);
|
||||
FeeRenewCommandExtension feeRenew =
|
||||
eppInput.getSingleExtension(FeeRenewCommandExtension.class);
|
||||
FeesAndCredits feesAndCredits =
|
||||
|
@ -150,9 +153,6 @@ public final class DomainRenewFlow implements TransactionalFlow {
|
|||
.setModificationTime(now)
|
||||
.setParent(Key.create(existingDomain))
|
||||
.build();
|
||||
DateTime oldExpirationTime = existingDomain.getRegistrationExpirationTime();
|
||||
DateTime newExpirationTime = leapSafeAddYears(oldExpirationTime, years); // Uncapped
|
||||
validateRegistrationPeriod(now, oldExpirationTime, years);
|
||||
String tld = existingDomain.getTld();
|
||||
// Bill for this explicit renew itself.
|
||||
BillingEvent.OneTime explicitRenewEvent =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue