mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Add a RESERVED billing event flag for creates of reserved domains
This is an additional signal we can use for the billing/invoicing pipeline that will be helfpul in targeting invoice rows that may need adjustment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217524250
This commit is contained in:
parent
3cfde5d4a1
commit
f43125bb04
5 changed files with 26 additions and 4 deletions
|
@ -23,6 +23,7 @@ import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReference
|
|||
import static google.registry.flows.domain.DomainFlowUtils.createFeeCreateResponse;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.isAnchorTenant;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.isReserved;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.isValidReservedCreate;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainAllowedOnCreateRestrictedTld;
|
||||
|
@ -320,7 +321,14 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
// Bill for the create.
|
||||
BillingEvent.OneTime createBillingEvent =
|
||||
createOneTimeBillingEvent(
|
||||
registry, isAnchorTenant, isSunriseCreate, years, feesAndCredits, historyEntry, now);
|
||||
registry,
|
||||
isAnchorTenant,
|
||||
isSunriseCreate,
|
||||
isReserved(domainName, isSunriseCreate),
|
||||
years,
|
||||
feesAndCredits,
|
||||
historyEntry,
|
||||
now);
|
||||
// Create a new autorenew billing event and poll message starting at the expiration time.
|
||||
BillingEvent.Recurring autorenewBillingEvent =
|
||||
createAutorenewBillingEvent(historyEntry, registrationExpirationTime);
|
||||
|
@ -507,6 +515,7 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
Registry registry,
|
||||
boolean isAnchorTenant,
|
||||
boolean isSunriseCreate,
|
||||
boolean isReserved,
|
||||
int years,
|
||||
FeesAndCredits feesAndCredits,
|
||||
HistoryEntry historyEntry,
|
||||
|
@ -518,6 +527,10 @@ public class DomainCreateFlow implements TransactionalFlow {
|
|||
}
|
||||
if (isAnchorTenant) {
|
||||
flagsBuilder.add(Flag.ANCHOR_TENANT);
|
||||
} else if (isReserved) {
|
||||
// Don't add this flag if the domain is an anchor tenant (which are also reserved); only add
|
||||
// it if it's reserved for other reasons.
|
||||
flagsBuilder.add(Flag.RESERVED);
|
||||
}
|
||||
return new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
|
|
|
@ -453,7 +453,7 @@ public class DomainFlowUtils {
|
|||
private static final ImmutableSet<ReservationType> RESERVED_TYPES =
|
||||
ImmutableSet.of(RESERVED_FOR_SPECIFIC_USE, RESERVED_FOR_ANCHOR_TENANT, FULLY_BLOCKED);
|
||||
|
||||
private static boolean isReserved(InternetDomainName domainName, boolean isSunrise) {
|
||||
static boolean isReserved(InternetDomainName domainName, boolean isSunrise) {
|
||||
ImmutableSet<ReservationType> types = getReservationTypes(domainName);
|
||||
return !Sets.intersection(types, RESERVED_TYPES).isEmpty()
|
||||
|| !(isSunrise || intersection(TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE, types).isEmpty());
|
||||
|
|
|
@ -71,6 +71,14 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
ANCHOR_TENANT,
|
||||
AUTO_RENEW,
|
||||
LANDRUSH,
|
||||
/**
|
||||
* This flag is used on create {@link OneTime} billing events for domains that were reserved.
|
||||
*
|
||||
* <p>This can happen when allocation tokens are used or superusers override a domain
|
||||
* reservation. These cases can need special handling in billing/invoicing. Anchor tenants will
|
||||
* never have this flag applied; they will have ANCHOR_TENANT instead.
|
||||
*/
|
||||
RESERVED,
|
||||
SUNRISE,
|
||||
/**
|
||||
* This flag will be added to any {@link OneTime} events that are created via, e.g., an
|
||||
|
|
|
@ -1060,7 +1060,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "resdom.tld")));
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of());
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(Flag.RESERVED));
|
||||
assertNoLordn();
|
||||
AllocationToken reloadedToken = ofy().load().entity(token).now();
|
||||
assertThat(reloadedToken.isRedeemed()).isTrue();
|
||||
|
@ -1074,7 +1074,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(
|
||||
CommitMode.LIVE, SUPERUSER, loadFile("domain_create_reserved_response.xml"));
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of());
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(Flag.RESERVED));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,6 +21,7 @@ enum google.registry.model.billing.BillingEvent$Flag {
|
|||
ANCHOR_TENANT;
|
||||
AUTO_RENEW;
|
||||
LANDRUSH;
|
||||
RESERVED;
|
||||
SUNRISE;
|
||||
SYNTHETIC;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue