mirror of
https://github.com/google/nomulus.git
synced 2025-05-28 16:30:12 +02:00
Decouple superuser from SessionMetadata
Superuser should only be settable via the tool (see [] which is merged in here but not diffbased, and which removes the implicit superuser for CharlestonRoad). It is a property of the request, not of the session (there are no sessions in the tool). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125204707
This commit is contained in:
parent
e359ab5f52
commit
fd6c4888db
44 changed files with 80 additions and 136 deletions
|
@ -89,7 +89,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
|
||||
protected EppLoader eppLoader;
|
||||
protected Class<? extends Flow> flowClass;
|
||||
protected TestSessionMetadata sessionMetadata;
|
||||
protected SessionMetadata sessionMetadata;
|
||||
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
protected TransportCredentials credentials = new PasswordOnlyTransportCredentials();
|
||||
|
||||
|
@ -121,7 +121,8 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
}
|
||||
|
||||
/** Load a flow from an epp object. */
|
||||
private FlowRunner getFlowRunner(CommitMode commitMode) throws Exception {
|
||||
private FlowRunner getFlowRunner(CommitMode commitMode, UserPrivileges userPrivileges)
|
||||
throws Exception {
|
||||
EppInput eppInput = eppLoader.getEpp();
|
||||
flowClass = firstNonNull(flowClass, FlowPicker.getFlowClass(eppInput));
|
||||
Class<?> expectedFlowClass = new TypeInstantiator<F>(getClass()){}.getExactType();
|
||||
|
@ -133,6 +134,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
sessionMetadata,
|
||||
credentials,
|
||||
commitMode.equals(CommitMode.DRY_RUN),
|
||||
userPrivileges.equals(UserPrivileges.SUPERUSER),
|
||||
"<xml></xml>".getBytes(),
|
||||
null,
|
||||
clock);
|
||||
|
@ -153,7 +155,8 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
}
|
||||
|
||||
public void assertTransactionalFlow(boolean isTransactional) throws Exception {
|
||||
assertThat(getFlowRunner(CommitMode.LIVE).isTransactional()).isEqualTo(isTransactional);
|
||||
assertThat(getFlowRunner(CommitMode.LIVE, UserPrivileges.NORMAL).isTransactional())
|
||||
.isEqualTo(isTransactional);
|
||||
}
|
||||
|
||||
public void assertNoHistory() throws Exception {
|
||||
|
@ -271,8 +274,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
|
||||
/** Run a flow, and attempt to marshal the result to EPP or throw if it doesn't validate. */
|
||||
public EppOutput runFlow(CommitMode commitMode, UserPrivileges userPrivileges) throws Exception {
|
||||
sessionMetadata.setSuperuser(userPrivileges.equals(UserPrivileges.SUPERUSER));
|
||||
EppOutput output = getFlowRunner(commitMode).run();
|
||||
EppOutput output = getFlowRunner(commitMode, userPrivileges).run();
|
||||
marshal(output, ValidationMode.STRICT);
|
||||
return output;
|
||||
}
|
||||
|
@ -284,8 +286,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
public void runFlowAssertResponse(
|
||||
CommitMode commitMode, UserPrivileges userPrivileges, String xml, String... ignoredPaths)
|
||||
throws Exception {
|
||||
sessionMetadata.setSuperuser(userPrivileges.equals(UserPrivileges.SUPERUSER));
|
||||
EppOutput eppOutput = getFlowRunner(commitMode).run();
|
||||
EppOutput eppOutput = getFlowRunner(commitMode, userPrivileges).run();
|
||||
if (eppOutput.isResponse()) {
|
||||
assertThat(eppOutput.isSuccess()).isTrue();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue