mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 09:21:49 +02:00
Add extra flow logic hook for application create
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137396935
This commit is contained in:
parent
bc0116f3a0
commit
60cb1b4dfb
5 changed files with 113 additions and 0 deletions
|
@ -105,6 +105,8 @@ import google.registry.flows.exceptions.ResourceAlreadyExistsException;
|
|||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.domain.LrpTokenEntity;
|
||||
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.LaunchNotice;
|
||||
import google.registry.model.domain.launch.LaunchPhase;
|
||||
|
@ -155,6 +157,10 @@ public class DomainApplicationCreateFlowTest
|
|||
setEppInput("domain_create_sunrise_encoded_signed_mark.xml");
|
||||
createTld("tld", TldState.SUNRISE);
|
||||
persistResource(Registry.get("tld").asBuilder().setReservedLists(createReservedList()).build());
|
||||
createTld("flags", TldState.LANDRUSH);
|
||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
||||
persistResource(
|
||||
Registry.get("flags").asBuilder().setReservedLists(createReservedList()).build());
|
||||
inject.setStaticField(TmchCertificateAuthority.class, "clock", clock);
|
||||
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
|
||||
}
|
||||
|
@ -1686,4 +1692,20 @@ public class DomainApplicationCreateFlowTest
|
|||
// ❤☀☆☂☻♞☯.tld
|
||||
doFailingDomainNameTest("xn--k3hel9n7bxlu1e.tld", InvalidIdnDomainLabelException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_flags_feeMismatch() throws Exception {
|
||||
persistContactsAndHosts();
|
||||
setEppInput("domain_create_landrush_flags.xml", ImmutableMap.of("FEE", "12"));
|
||||
thrown.expect(FeesMismatchException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_flags() throws Exception {
|
||||
persistContactsAndHosts();
|
||||
setEppInput("domain_create_landrush_flags.xml", ImmutableMap.of("FEE", "42"));
|
||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "flag1,flag2");
|
||||
runFlow();
|
||||
}
|
||||
}
|
||||
|
|
36
javatests/google/registry/flows/domain/testdata/domain_create_landrush_flags.xml
vendored
Normal file
36
javatests/google/registry/flows/domain/testdata/domain_create_landrush_flags.xml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>create-42.flags</domain:name>
|
||||
<domain:ns>
|
||||
<domain:hostObj>ns1.example.net</domain:hostObj>
|
||||
<domain:hostObj>ns2.example.net</domain:hostObj>
|
||||
</domain:ns>
|
||||
<domain:registrant>jd1234</domain:registrant>
|
||||
<domain:contact type="admin">sh8013</domain:contact>
|
||||
<domain:contact type="tech">sh8013</domain:contact>
|
||||
<domain:authInfo>
|
||||
<domain:pw>2fooBAR</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<launch:create
|
||||
xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||
<launch:phase>landrush</launch:phase>
|
||||
</launch:create>
|
||||
<fee:create xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:fee>%FEE%</fee:fee>
|
||||
</fee:create>
|
||||
<flags:create xmlns:flags="urn:google:params:xml:ns:flags-0.1">
|
||||
<flags:flag>flag1</flags:flag>
|
||||
<flags:flag>flag2</flags:flag>
|
||||
</flags:create>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -99,6 +99,26 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs additional tasks required for an application create command. Any changes should not be
|
||||
* persisted to Datastore until commitAdditionalLogicChanges is called.
|
||||
*/
|
||||
@Override
|
||||
public void performAdditionalApplicationCreateLogic(
|
||||
DomainApplication application,
|
||||
String clientId,
|
||||
DateTime asOfDate,
|
||||
int years,
|
||||
EppInput eppInput,
|
||||
HistoryEntry historyEntry) throws EppException {
|
||||
FlagsCreateCommandExtension flags =
|
||||
eppInput.getSingleExtension(FlagsCreateCommandExtension.class);
|
||||
if (flags == null) {
|
||||
return;
|
||||
}
|
||||
messageToThrow = Joiner.on(',').join(flags.getFlags());
|
||||
}
|
||||
|
||||
/** Computes the expected create cost, for use in fee challenges and the like. */
|
||||
@Override
|
||||
public BaseFee getCreateFeeOrCredit(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue