mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Add FlowMetadata (containing isSuperuser) to custom flow logic
This also bypasses signed mark validation during domain creation if the flow is being executed as superuser. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145435268
This commit is contained in:
parent
d5160213e5
commit
f3388326d6
21 changed files with 213 additions and 74 deletions
|
@ -308,6 +308,11 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
return runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
|
||||
}
|
||||
|
||||
/** Shortcut to call {@link #runFlow(CommitMode, UserPrivileges)} as super user and live run. */
|
||||
public EppOutput runFlowAsSuperuser() throws Exception {
|
||||
return runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
|
||||
}
|
||||
|
||||
/** Run a flow, marshal the result to EPP, and assert that the output is as expected. */
|
||||
public EppOutput runFlowAssertResponse(
|
||||
CommitMode commitMode, UserPrivileges userPrivileges, String xml, String... ignoredPaths)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.custom;
|
||||
|
||||
import google.registry.flows.FlowMetadata;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
|
||||
|
@ -22,13 +23,13 @@ public class TestCustomLogicFactory extends CustomLogicFactory {
|
|||
|
||||
@Override
|
||||
public DomainCreateFlowCustomLogic forDomainCreateFlow(
|
||||
EppInput eppInput, SessionMetadata sessionMetadata) {
|
||||
return new TestDomainCreateFlowCustomLogic(eppInput, sessionMetadata);
|
||||
EppInput eppInput, SessionMetadata sessionMetadata, FlowMetadata flowMetadata) {
|
||||
return new TestDomainCreateFlowCustomLogic(eppInput, sessionMetadata, flowMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainPricingCustomLogic forDomainPricing(
|
||||
EppInput eppInput, SessionMetadata sessionMetadata) {
|
||||
return new TestDomainPricingCustomLogic(eppInput, sessionMetadata);
|
||||
EppInput eppInput, SessionMetadata sessionMetadata, FlowMetadata flowMetadata) {
|
||||
return new TestDomainPricingCustomLogic(eppInput, sessionMetadata, flowMetadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.flows.custom;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.FlowMetadata;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
|
@ -24,8 +25,9 @@ import google.registry.model.poll.PollMessage;
|
|||
/** A class to customize {@link DomainCreateFlowCustomLogic} for testing. */
|
||||
public class TestDomainCreateFlowCustomLogic extends DomainCreateFlowCustomLogic {
|
||||
|
||||
protected TestDomainCreateFlowCustomLogic(EppInput eppInput, SessionMetadata sessionMetadata) {
|
||||
super(eppInput, sessionMetadata);
|
||||
protected TestDomainCreateFlowCustomLogic(
|
||||
EppInput eppInput, SessionMetadata sessionMetadata, FlowMetadata flowMetadata) {
|
||||
super(eppInput, sessionMetadata, flowMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
package google.registry.flows.custom;
|
||||
|
||||
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.FlowMetadata;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
import google.registry.flows.domain.DomainPricingLogic;
|
||||
import google.registry.flows.domain.FeesAndCredits;
|
||||
|
@ -32,8 +32,9 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic {
|
|||
|
||||
private static final BigDecimal ONE_HUNDRED_BUCKS = Money.of(CurrencyUnit.USD, 100).getAmount();
|
||||
|
||||
protected TestDomainPricingCustomLogic(EppInput eppInput, SessionMetadata sessionMetadata) {
|
||||
super(eppInput, sessionMetadata);
|
||||
protected TestDomainPricingCustomLogic(
|
||||
EppInput eppInput, SessionMetadata sessionMetadata, FlowMetadata flowMetadata) {
|
||||
super(eppInput, sessionMetadata, flowMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -213,11 +213,6 @@ public class DomainAllocateFlowTest
|
|||
}
|
||||
}
|
||||
|
||||
private void runFlowAsSuperuser() throws Exception {
|
||||
assertTransactionalFlow(true);
|
||||
runFlow(CommitMode.LIVE, UserPrivileges.SUPERUSER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess() throws Exception {
|
||||
setupDomainApplication("tld", TldState.QUIET_PERIOD);
|
||||
|
|
|
@ -436,6 +436,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
assertNoLordn("0000001761376042759136-65535", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_generalAvailability_ignoresEncodedSignedMarkMismatch() throws Exception {
|
||||
createTld("tld", TldState.GENERAL_AVAILABILITY);
|
||||
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
|
||||
setEppInput("domain_create_registration_encoded_signed_mark_mismatched_label.xml");
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAsSuperuser();
|
||||
assertSuccessfulCreate("tld", true);
|
||||
assertNoLordn();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_fee_v06() throws Exception {
|
||||
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue