mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add extra flow logic hook for domain allocation
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138679232
This commit is contained in:
parent
218a4b735b
commit
09beacf746
5 changed files with 59 additions and 3 deletions
|
@ -37,6 +37,7 @@ import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||||
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.net.InternetDomainName;
|
import com.google.common.net.InternetDomainName;
|
||||||
|
@ -175,6 +176,7 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
||||||
.setNameservers(command.getNameservers())
|
.setNameservers(command.getNameservers())
|
||||||
.setContacts(command.getContacts())
|
.setContacts(command.getContacts())
|
||||||
.build();
|
.build();
|
||||||
|
handleExtraFlowLogic(registry.getTldStr(), years, historyEntry, newDomain, now);
|
||||||
entitiesToSave.add(
|
entitiesToSave.add(
|
||||||
newDomain,
|
newDomain,
|
||||||
buildApplicationHistory(application, now),
|
buildApplicationHistory(application, now),
|
||||||
|
@ -360,6 +362,22 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
||||||
&& !matchesAnchorTenantReservation(domainName, authInfoToken);
|
&& !matchesAnchorTenantReservation(domainName, authInfoToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleExtraFlowLogic(
|
||||||
|
String tld, int years, HistoryEntry historyEntry, DomainResource newDomain, DateTime now)
|
||||||
|
throws EppException {
|
||||||
|
Optional<RegistryExtraFlowLogic> extraFlowLogic =
|
||||||
|
RegistryExtraFlowLogicProxy.newInstanceForTld(tld);
|
||||||
|
if (extraFlowLogic.isPresent()) {
|
||||||
|
extraFlowLogic.get().performAdditionalDomainAllocateLogic(
|
||||||
|
newDomain,
|
||||||
|
clientId,
|
||||||
|
now,
|
||||||
|
years,
|
||||||
|
eppInput,
|
||||||
|
historyEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void enqueueTasks(AllocateCreateExtension allocateCreate, DomainResource newDomain) {
|
private void enqueueTasks(AllocateCreateExtension allocateCreate, DomainResource newDomain) {
|
||||||
if (newDomain.shouldPublishToDns()) {
|
if (newDomain.shouldPublishToDns()) {
|
||||||
DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
|
DnsQueue.create().addDomainRefreshTask(newDomain.getFullyQualifiedDomainName());
|
||||||
|
|
|
@ -69,6 +69,15 @@ public interface RegistryExtraFlowLogic {
|
||||||
EppInput eppInput,
|
EppInput eppInput,
|
||||||
HistoryEntry historyEntry) throws EppException;
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
|
/** Performs additional tasks required for an allocate command. */
|
||||||
|
public void performAdditionalDomainAllocateLogic(
|
||||||
|
DomainResource domain,
|
||||||
|
String clientId,
|
||||||
|
DateTime asOfDate,
|
||||||
|
int years,
|
||||||
|
EppInput eppInput,
|
||||||
|
HistoryEntry historyEntry) throws EppException;
|
||||||
|
|
||||||
/** Computes the expected creation fee. */
|
/** Computes the expected creation fee. */
|
||||||
public BaseFee getCreateFeeOrCredit(
|
public BaseFee getCreateFeeOrCredit(
|
||||||
String domainName,
|
String domainName,
|
||||||
|
|
|
@ -52,6 +52,8 @@ import google.registry.model.billing.BillingEvent.Reason;
|
||||||
import google.registry.model.domain.DomainApplication;
|
import google.registry.model.domain.DomainApplication;
|
||||||
import google.registry.model.domain.DomainResource;
|
import google.registry.model.domain.DomainResource;
|
||||||
import google.registry.model.domain.GracePeriod;
|
import google.registry.model.domain.GracePeriod;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager;
|
||||||
|
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||||
import google.registry.model.domain.launch.ApplicationStatus;
|
import google.registry.model.domain.launch.ApplicationStatus;
|
||||||
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
import google.registry.model.domain.launch.LaunchInfoResponseExtension;
|
||||||
import google.registry.model.domain.launch.LaunchNotice;
|
import google.registry.model.domain.launch.LaunchNotice;
|
||||||
|
@ -92,7 +94,9 @@ public class DomainAllocateFlowTest
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initAllocateTest() throws Exception {
|
public void initAllocateTest() throws Exception {
|
||||||
setEppInput("domain_allocate.xml", ImmutableMap.of("APPLICATIONID", "2-TLD"));
|
setEppInput(
|
||||||
|
"domain_allocate.xml",
|
||||||
|
ImmutableMap.of("APPLICATIONID", "2-TLD", "DOMAIN", "example-one.tld"));
|
||||||
clock.setTo(APPLICATION_TIME);
|
clock.setTo(APPLICATION_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +382,9 @@ public class DomainAllocateFlowTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSuccess_hexApplicationId() throws Exception {
|
public void testSuccess_hexApplicationId() throws Exception {
|
||||||
setEppInput("domain_allocate.xml", ImmutableMap.of("APPLICATIONID", "A-TLD"));
|
setEppInput(
|
||||||
|
"domain_allocate.xml",
|
||||||
|
ImmutableMap.of("APPLICATIONID", "A-TLD", "DOMAIN", "example-one.tld"));
|
||||||
applicationId = "A-TLD";
|
applicationId = "A-TLD";
|
||||||
// Grab the next 8 ids so that when the application is created it gets dec 10, or hex A.
|
// Grab the next 8 ids so that when the application is created it gets dec 10, or hex A.
|
||||||
// (one additional ID goes to the reserved list created before the application).
|
// (one additional ID goes to the reserved list created before the application).
|
||||||
|
@ -485,4 +491,15 @@ public class DomainAllocateFlowTest
|
||||||
thrown.expect(OnlySuperuserCanAllocateException.class);
|
thrown.expect(OnlySuperuserCanAllocateException.class);
|
||||||
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccess_extra() throws Exception {
|
||||||
|
setEppInput(
|
||||||
|
"domain_allocate.xml",
|
||||||
|
ImmutableMap.of("APPLICATIONID", "2-EXTRA", "DOMAIN", "domain.extra"));
|
||||||
|
setupDomainApplication("extra", TldState.QUIET_PERIOD);
|
||||||
|
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
||||||
|
thrown.expect(TestExtraLogicManagerSuccessException.class, "allocated");
|
||||||
|
runFlowAsSuperuser();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<create>
|
<create>
|
||||||
<domain:create
|
<domain:create
|
||||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
<domain:name>example-one.tld</domain:name>
|
<domain:name>%DOMAIN%</domain:name>
|
||||||
<domain:period unit="y">2</domain:period>
|
<domain:period unit="y">2</domain:period>
|
||||||
<domain:ns>
|
<domain:ns>
|
||||||
<domain:hostObj>ns1.example.net</domain:hostObj>
|
<domain:hostObj>ns1.example.net</domain:hostObj>
|
||||||
|
|
|
@ -165,6 +165,18 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
||||||
return domainNameToFeeOrCredit(domainName);
|
return domainNameToFeeOrCredit(domainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Performs additional tasks required for an allocate command. */
|
||||||
|
@Override
|
||||||
|
public void performAdditionalDomainAllocateLogic(
|
||||||
|
DomainResource domain,
|
||||||
|
String clientId,
|
||||||
|
DateTime asOfDate,
|
||||||
|
int years,
|
||||||
|
EppInput eppInput,
|
||||||
|
HistoryEntry historyEntry) throws EppException {
|
||||||
|
throw new TestExtraLogicManagerSuccessException("allocated");
|
||||||
|
}
|
||||||
|
|
||||||
/** Performs additional tasks required for a create command. */
|
/** Performs additional tasks required for a create command. */
|
||||||
@Override
|
@Override
|
||||||
public void performAdditionalDomainCreateLogic(
|
public void performAdditionalDomainCreateLogic(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue