mirror of
https://github.com/google/nomulus.git
synced 2025-05-19 02:39:34 +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.createFeeCreateResponse;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
import static google.registry.flows.domain.DomainFlowUtils.getReservationTypes;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.isAnchorTenant;
|
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.isValidReservedCreate;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
|
import static google.registry.flows.domain.DomainFlowUtils.validateCreateCommandContactsAndNameservers;
|
||||||
import static google.registry.flows.domain.DomainFlowUtils.validateDomainAllowedOnCreateRestrictedTld;
|
import static google.registry.flows.domain.DomainFlowUtils.validateDomainAllowedOnCreateRestrictedTld;
|
||||||
|
@ -320,7 +321,14 @@ public class DomainCreateFlow implements TransactionalFlow {
|
||||||
// Bill for the create.
|
// Bill for the create.
|
||||||
BillingEvent.OneTime createBillingEvent =
|
BillingEvent.OneTime createBillingEvent =
|
||||||
createOneTimeBillingEvent(
|
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.
|
// Create a new autorenew billing event and poll message starting at the expiration time.
|
||||||
BillingEvent.Recurring autorenewBillingEvent =
|
BillingEvent.Recurring autorenewBillingEvent =
|
||||||
createAutorenewBillingEvent(historyEntry, registrationExpirationTime);
|
createAutorenewBillingEvent(historyEntry, registrationExpirationTime);
|
||||||
|
@ -507,6 +515,7 @@ public class DomainCreateFlow implements TransactionalFlow {
|
||||||
Registry registry,
|
Registry registry,
|
||||||
boolean isAnchorTenant,
|
boolean isAnchorTenant,
|
||||||
boolean isSunriseCreate,
|
boolean isSunriseCreate,
|
||||||
|
boolean isReserved,
|
||||||
int years,
|
int years,
|
||||||
FeesAndCredits feesAndCredits,
|
FeesAndCredits feesAndCredits,
|
||||||
HistoryEntry historyEntry,
|
HistoryEntry historyEntry,
|
||||||
|
@ -518,6 +527,10 @@ public class DomainCreateFlow implements TransactionalFlow {
|
||||||
}
|
}
|
||||||
if (isAnchorTenant) {
|
if (isAnchorTenant) {
|
||||||
flagsBuilder.add(Flag.ANCHOR_TENANT);
|
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()
|
return new BillingEvent.OneTime.Builder()
|
||||||
.setReason(Reason.CREATE)
|
.setReason(Reason.CREATE)
|
||||||
|
|
|
@ -453,7 +453,7 @@ public class DomainFlowUtils {
|
||||||
private static final ImmutableSet<ReservationType> RESERVED_TYPES =
|
private static final ImmutableSet<ReservationType> RESERVED_TYPES =
|
||||||
ImmutableSet.of(RESERVED_FOR_SPECIFIC_USE, RESERVED_FOR_ANCHOR_TENANT, FULLY_BLOCKED);
|
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);
|
ImmutableSet<ReservationType> types = getReservationTypes(domainName);
|
||||||
return !Sets.intersection(types, RESERVED_TYPES).isEmpty()
|
return !Sets.intersection(types, RESERVED_TYPES).isEmpty()
|
||||||
|| !(isSunrise || intersection(TYPES_ALLOWED_FOR_CREATE_ONLY_IN_SUNRISE, 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,
|
ANCHOR_TENANT,
|
||||||
AUTO_RENEW,
|
AUTO_RENEW,
|
||||||
LANDRUSH,
|
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,
|
SUNRISE,
|
||||||
/**
|
/**
|
||||||
* This flag will be added to any {@link OneTime} events that are created via, e.g., an
|
* 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();
|
persistContactsAndHosts();
|
||||||
runFlowAssertResponse(
|
runFlowAssertResponse(
|
||||||
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "resdom.tld")));
|
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "resdom.tld")));
|
||||||
assertSuccessfulCreate("tld", ImmutableSet.of());
|
assertSuccessfulCreate("tld", ImmutableSet.of(Flag.RESERVED));
|
||||||
assertNoLordn();
|
assertNoLordn();
|
||||||
AllocationToken reloadedToken = ofy().load().entity(token).now();
|
AllocationToken reloadedToken = ofy().load().entity(token).now();
|
||||||
assertThat(reloadedToken.isRedeemed()).isTrue();
|
assertThat(reloadedToken.isRedeemed()).isTrue();
|
||||||
|
@ -1074,7 +1074,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||||
persistContactsAndHosts();
|
persistContactsAndHosts();
|
||||||
runFlowAssertResponse(
|
runFlowAssertResponse(
|
||||||
CommitMode.LIVE, SUPERUSER, loadFile("domain_create_reserved_response.xml"));
|
CommitMode.LIVE, SUPERUSER, loadFile("domain_create_reserved_response.xml"));
|
||||||
assertSuccessfulCreate("tld", ImmutableSet.of());
|
assertSuccessfulCreate("tld", ImmutableSet.of(Flag.RESERVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,6 +21,7 @@ enum google.registry.model.billing.BillingEvent$Flag {
|
||||||
ANCHOR_TENANT;
|
ANCHOR_TENANT;
|
||||||
AUTO_RENEW;
|
AUTO_RENEW;
|
||||||
LANDRUSH;
|
LANDRUSH;
|
||||||
|
RESERVED;
|
||||||
SUNRISE;
|
SUNRISE;
|
||||||
SYNTHETIC;
|
SYNTHETIC;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue