mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 00:12:11 +02:00
Add extra flow logic hooks for application delete and update
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138393251
This commit is contained in:
parent
cef07f6bc5
commit
baaaacd4f5
10 changed files with 234 additions and 33 deletions
|
@ -25,6 +25,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomainApplica
|
|||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
|
@ -39,6 +40,8 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException
|
|||
import google.registry.model.EppResource;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.TestExtraLogicManager;
|
||||
import google.registry.model.domain.TestExtraLogicManager.TestExtraLogicManagerSuccessException;
|
||||
import google.registry.model.domain.launch.LaunchPhase;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
|
@ -58,6 +61,8 @@ public class DomainApplicationDeleteFlowTest
|
|||
@Before
|
||||
public void setUp() {
|
||||
createTld("tld", TldState.SUNRUSH);
|
||||
createTld("extra", TldState.LANDRUSH);
|
||||
RegistryExtraFlowLogicProxy.setOverride("extra", TestExtraLogicManager.class);
|
||||
}
|
||||
|
||||
public void doSuccessfulTest() throws Exception {
|
||||
|
@ -172,7 +177,7 @@ public class DomainApplicationDeleteFlowTest
|
|||
@Test
|
||||
public void testFailure_sunriseDuringLandrush() throws Exception {
|
||||
createTld("tld", TldState.LANDRUSH);
|
||||
setEppInput("domain_delete_application_landrush.xml");
|
||||
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistResource(newDomainApplication("example.tld")
|
||||
.asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
|
@ -185,7 +190,7 @@ public class DomainApplicationDeleteFlowTest
|
|||
@Test
|
||||
public void testSuccess_superuserSunriseDuringLandrush() throws Exception {
|
||||
createTld("tld", TldState.LANDRUSH);
|
||||
setEppInput("domain_delete_application_landrush.xml");
|
||||
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistResource(newDomainApplication("example.tld")
|
||||
.asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
|
@ -199,7 +204,7 @@ public class DomainApplicationDeleteFlowTest
|
|||
@Test
|
||||
public void testSuccess_sunrushDuringLandrush() throws Exception {
|
||||
createTld("tld", TldState.LANDRUSH);
|
||||
setEppInput("domain_delete_application_landrush.xml");
|
||||
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistResource(newDomainApplication("example.tld")
|
||||
.asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
|
@ -222,7 +227,7 @@ public class DomainApplicationDeleteFlowTest
|
|||
|
||||
@Test
|
||||
public void testFailure_mismatchedPhase() throws Exception {
|
||||
setEppInput("domain_delete_application_landrush.xml");
|
||||
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
persistResource(
|
||||
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
|
||||
thrown.expect(LaunchPhaseMismatchException.class);
|
||||
|
@ -301,4 +306,17 @@ public class DomainApplicationDeleteFlowTest
|
|||
thrown.expect(ApplicationDomainNameMismatchException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_extraLogic() throws Exception {
|
||||
persistResource(newDomainApplication("example.extra")
|
||||
.asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
.setPhase(LaunchPhase.LANDRUSH)
|
||||
.build());
|
||||
setEppInput(
|
||||
"domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.extra"));
|
||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "application deleted");
|
||||
runFlow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
|
@ -40,6 +41,7 @@ import google.registry.flows.domain.DomainApplicationUpdateFlow.ApplicationStatu
|
|||
import google.registry.flows.domain.DomainFlowUtils.ApplicationDomainNameMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.DuplicateContactForRoleException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.EmptySecDnsUpdateException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.FeesMismatchException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.LinkedResourcesDoNotExistException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MaxSigLifeChangeNotSupportedException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.MissingAdminContactException;
|
||||
|
@ -59,6 +61,8 @@ import google.registry.model.domain.DesignatedContact;
|
|||
import google.registry.model.domain.DesignatedContact.Type;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainApplication.Builder;
|
||||
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.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
|
@ -89,6 +93,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
@Before
|
||||
public void setUp() {
|
||||
createTld("tld", TldState.SUNRUSH);
|
||||
createTld("flags", TldState.SUNRISE);
|
||||
RegistryExtraFlowLogicProxy.setOverride("flags", TestExtraLogicManager.class);
|
||||
}
|
||||
|
||||
private void persistReferencedEntities() {
|
||||
|
@ -668,4 +674,26 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistApplication();
|
||||
doSuccessfulTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_flags_feeMismatch() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainApplication("update-42.flags").asBuilder().setRepoId("1-ROID").build());
|
||||
setEppInput("domain_update_sunrise_flags.xml", ImmutableMap.of("FEE", "12"));
|
||||
clock.advanceOneMilli();
|
||||
thrown.expect(FeesMismatchException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_flags() throws Exception {
|
||||
persistReferencedEntities();
|
||||
persistResource(
|
||||
newDomainApplication("update-42.flags").asBuilder().setRepoId("1-ROID").build());
|
||||
setEppInput("domain_update_sunrise_flags.xml", ImmutableMap.of("FEE", "42"));
|
||||
clock.advanceOneMilli();
|
||||
thrown.expect(TestExtraLogicManagerSuccessException.class, "add:flag1;remove:flag2");
|
||||
runFlow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<delete>
|
||||
<domain:delete
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>example.tld</domain:name>
|
||||
<domain:name>%DOMAIN%</domain:name>
|
||||
</domain:delete>
|
||||
</delete>
|
||||
<extension>
|
||||
|
|
39
javatests/google/registry/flows/domain/testdata/domain_update_sunrise_flags.xml
vendored
Normal file
39
javatests/google/registry/flows/domain/testdata/domain_update_sunrise_flags.xml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name>update-42.flags</domain:name>
|
||||
<domain:add>
|
||||
<domain:ns>
|
||||
<domain:hostObj>ns2.example.tld</domain:hostObj>
|
||||
</domain:ns>
|
||||
</domain:add>
|
||||
<domain:rem>
|
||||
<domain:ns>
|
||||
<domain:hostObj>ns1.example.tld</domain:hostObj>
|
||||
</domain:ns>
|
||||
</domain:rem>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<launch:update xmlns:launch="urn:ietf:params:xml:ns:launch-1.0">
|
||||
<launch:phase name="landrush">sunrise</launch:phase>
|
||||
<launch:applicationID>1-ROID</launch:applicationID>
|
||||
</launch:update>
|
||||
<fee:update xmlns:fee="urn:ietf:params:xml:ns:fee-0.6">
|
||||
<fee:currency>USD</fee:currency>
|
||||
<fee:fee>%FEE%</fee:fee>
|
||||
</fee:update>
|
||||
<flags:update xmlns:flags="urn:google:params:xml:ns:flags-0.1">
|
||||
<flags:add>
|
||||
<flags:flag>flag1</flags:flag>
|
||||
</flags:add>
|
||||
<flags:rem>
|
||||
<flags:flag>flag2</flags:flag>
|
||||
</flags:rem>
|
||||
</flags:update>
|
||||
</extension>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
</command>
|
||||
</epp>
|
|
@ -96,10 +96,7 @@ 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.
|
||||
*/
|
||||
/** Performs additional tasks required for an application create command. */
|
||||
@Override
|
||||
public void performAdditionalApplicationCreateLogic(
|
||||
DomainApplication application,
|
||||
|
@ -116,6 +113,47 @@ public class TestExtraLogicManager implements RegistryExtraFlowLogic {
|
|||
throw new TestExtraLogicManagerSuccessException(Joiner.on(',').join(flags.getFlags()));
|
||||
}
|
||||
|
||||
/** Performs additional tasks required for an application create command. */
|
||||
@Override
|
||||
public void performAdditionalApplicationDeleteLogic(
|
||||
DomainApplication application,
|
||||
String clientId,
|
||||
DateTime asOfDate,
|
||||
EppInput eppInput,
|
||||
HistoryEntry historyEntry) throws EppException {
|
||||
throw new TestExtraLogicManagerSuccessException("application deleted");
|
||||
}
|
||||
|
||||
/** Computes the expected application update cost, for use in fee challenges and the like. */
|
||||
@Override
|
||||
public BaseFee getApplicationUpdateFeeOrCredit(
|
||||
DomainApplication application,
|
||||
String clientId,
|
||||
DateTime asOfDate,
|
||||
EppInput eppInput) throws EppException {
|
||||
return domainNameToFeeOrCredit(application.getFullyQualifiedDomainName());
|
||||
}
|
||||
|
||||
/** Performs additional tasks required for an application update command. */
|
||||
@Override
|
||||
public void performAdditionalApplicationUpdateLogic(
|
||||
DomainApplication application,
|
||||
String clientId,
|
||||
DateTime asOfDate,
|
||||
EppInput eppInput,
|
||||
HistoryEntry historyEntry) throws EppException {
|
||||
FlagsUpdateCommandExtension flags =
|
||||
eppInput.getSingleExtension(FlagsUpdateCommandExtension.class);
|
||||
if (flags == null) {
|
||||
return;
|
||||
}
|
||||
throw new TestExtraLogicManagerSuccessException(
|
||||
"add:"
|
||||
+ Joiner.on(',').join(flags.getAddFlags().getFlags())
|
||||
+ ";remove:"
|
||||
+ Joiner.on(',').join(flags.getRemoveFlags().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