Simplified calling of AuthenticationManagementResource.getExecutions()
This commit is contained in:
parent
f6a718f10a
commit
afcdce6b71
6 changed files with 22 additions and 67 deletions
|
@ -100,7 +100,7 @@ public interface AuthenticationManagementResource {
|
||||||
@Path("/flows/{flowAlias}/executions")
|
@Path("/flows/{flowAlias}/executions")
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
Response getExecutions(@PathParam("flowAlias") String flowAlias);
|
List<AuthenticationExecutionInfoRepresentation> getExecutions(@PathParam("flowAlias") String flowAlias);
|
||||||
|
|
||||||
@Path("/flows/{flowAlias}/executions")
|
@Path("/flows/{flowAlias}/executions")
|
||||||
@PUT
|
@PUT
|
||||||
|
|
|
@ -56,14 +56,8 @@ public abstract class AbstractCustomAccountManagementTest extends AbstractAccoun
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AuthenticationExecutionInfoRepresentation getExecution(String flowAlias, String provider) {
|
protected AuthenticationExecutionInfoRepresentation getExecution(String flowAlias, String provider) {
|
||||||
Response response = authMgmtResource.getExecutions(flowAlias);
|
List<AuthenticationExecutionInfoRepresentation> executionReps = authMgmtResource.getExecutions(flowAlias);
|
||||||
|
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = response.readEntity(
|
|
||||||
new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
response.close();
|
|
||||||
|
|
||||||
for (AuthenticationExecutionInfoRepresentation exec : executionReps) {
|
for (AuthenticationExecutionInfoRepresentation exec : executionReps) {
|
||||||
if (provider.equals(exec.getProviderId())) {
|
if (provider.equals(exec.getProviderId())) {
|
||||||
return exec;
|
return exec;
|
||||||
|
|
|
@ -348,14 +348,8 @@ public class UserFederationTest extends AbstractAdminTest {
|
||||||
|
|
||||||
private AuthenticationExecutionInfoRepresentation findKerberosExecution() {
|
private AuthenticationExecutionInfoRepresentation findKerberosExecution() {
|
||||||
AuthenticationExecutionInfoRepresentation kerberosExecution = null;
|
AuthenticationExecutionInfoRepresentation kerberosExecution = null;
|
||||||
Response response = realm.flows().getExecutions("browser");
|
List<AuthenticationExecutionInfoRepresentation> executionReps = realm.flows().getExecutions("browser");
|
||||||
try {
|
kerberosExecution = AbstractAuthenticationTest.findExecutionByProvider("auth-spnego", executionReps);
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
kerberosExecution = AbstractAuthenticationTest.findExecutionByProvider("auth-spnego", executionReps);
|
|
||||||
} finally {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertNotNull(kerberosExecution);
|
Assert.assertNotNull(kerberosExecution);
|
||||||
return kerberosExecution;
|
return kerberosExecution;
|
||||||
|
|
|
@ -68,20 +68,12 @@ public class ExecutionTest extends AbstractAuthenticationTest {
|
||||||
authMgmtResource.addExecution("Copy of browser", params);
|
authMgmtResource.addExecution("Copy of browser", params);
|
||||||
|
|
||||||
// check execution was added
|
// check execution was added
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
List<AuthenticationExecutionInfoRepresentation> executionReps = authMgmtResource.getExecutions("Copy of browser");
|
||||||
AuthenticationExecutionInfoRepresentation exec;
|
AuthenticationExecutionInfoRepresentation exec = findExecutionByProvider("idp-review-profile", executionReps);
|
||||||
AuthenticationExecutionInfoRepresentation authCookieExec;
|
Assert.assertNotNull("idp-review-profile added", exec);
|
||||||
try {
|
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
exec = findExecutionByProvider("idp-review-profile", executionReps);
|
|
||||||
Assert.assertNotNull("idp-review-profile added", exec);
|
|
||||||
|
|
||||||
// we'll need auth-cookie later
|
// we'll need auth-cookie later
|
||||||
authCookieExec = findExecutionByProvider("auth-cookie", executionReps);
|
AuthenticationExecutionInfoRepresentation authCookieExec = findExecutionByProvider("auth-cookie", executionReps);
|
||||||
} finally {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
compareExecution(newExecInfo("Review Profile", "idp-review-profile", true, 0, 3, DISABLED, null, new String[]{REQUIRED, DISABLED}), exec);
|
compareExecution(newExecInfo("Review Profile", "idp-review-profile", true, 0, 3, DISABLED, null, new String[]{REQUIRED, DISABLED}), exec);
|
||||||
|
|
||||||
|
@ -89,15 +81,9 @@ public class ExecutionTest extends AbstractAuthenticationTest {
|
||||||
authMgmtResource.removeExecution(exec.getId());
|
authMgmtResource.removeExecution(exec.getId());
|
||||||
|
|
||||||
// check execution was removed
|
// check execution was removed
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
executionReps = authMgmtResource.getExecutions("Copy of browser");
|
||||||
try {
|
exec = findExecutionByProvider("idp-review-profile", executionReps);
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
Assert.assertNull("idp-review-profile removed", exec);
|
||||||
});
|
|
||||||
exec = findExecutionByProvider("idp-review-profile", executionReps);
|
|
||||||
Assert.assertNull("idp-review-profile removed", exec);
|
|
||||||
} finally {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// now add the execution again using a different method and representation
|
// now add the execution again using a different method and representation
|
||||||
|
|
||||||
|
@ -130,16 +116,9 @@ public class ExecutionTest extends AbstractAuthenticationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check execution was added
|
// check execution was added
|
||||||
List<AuthenticationExecutionInfoRepresentation> executions;
|
List<AuthenticationExecutionInfoRepresentation> executions = authMgmtResource.getExecutions("Copy of browser");
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
exec = findExecutionByProvider("auth-cookie", executions);
|
||||||
try {
|
Assert.assertNotNull("auth-cookie added", exec);
|
||||||
executions = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
exec = findExecutionByProvider("auth-cookie", executions);
|
|
||||||
Assert.assertNotNull("auth-cookie added", exec);
|
|
||||||
} finally {
|
|
||||||
response.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: there is no checking in addExecution if requirement is one of requirementChoices
|
// Note: there is no checking in addExecution if requirement is one of requirementChoices
|
||||||
// Thus we can have OPTIONAL which is neither ALTERNATIVE, nor DISABLED
|
// Thus we can have OPTIONAL which is neither ALTERNATIVE, nor DISABLED
|
||||||
|
@ -150,10 +129,7 @@ public class ExecutionTest extends AbstractAuthenticationTest {
|
||||||
public void testUpdateExecution() {
|
public void testUpdateExecution() {
|
||||||
|
|
||||||
// get current auth-cookie execution
|
// get current auth-cookie execution
|
||||||
Response response = authMgmtResource.getExecutions("browser");
|
List<AuthenticationExecutionInfoRepresentation> executionReps = authMgmtResource.getExecutions("browser");
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = response.readEntity(
|
|
||||||
new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
AuthenticationExecutionInfoRepresentation exec = findExecutionByProvider("auth-cookie", executionReps);
|
AuthenticationExecutionInfoRepresentation exec = findExecutionByProvider("auth-cookie", executionReps);
|
||||||
|
|
||||||
Assert.assertEquals("auth-cookie set to ALTERNATIVE", ALTERNATIVE, exec.getRequirement());
|
Assert.assertEquals("auth-cookie set to ALTERNATIVE", ALTERNATIVE, exec.getRequirement());
|
||||||
|
@ -163,8 +139,7 @@ public class ExecutionTest extends AbstractAuthenticationTest {
|
||||||
authMgmtResource.updateExecutions("browser", exec);
|
authMgmtResource.updateExecutions("browser", exec);
|
||||||
|
|
||||||
// make sure the change is visible
|
// make sure the change is visible
|
||||||
response = authMgmtResource.getExecutions("browser");
|
executionReps = authMgmtResource.getExecutions("browser");
|
||||||
executionReps = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {});
|
|
||||||
|
|
||||||
// get current auth-cookie execution
|
// get current auth-cookie execution
|
||||||
AuthenticationExecutionInfoRepresentation exec2 = findExecutionByProvider("auth-cookie", executionReps);
|
AuthenticationExecutionInfoRepresentation exec2 = findExecutionByProvider("auth-cookie", executionReps);
|
||||||
|
|
|
@ -55,9 +55,7 @@ public class InitialFlowsTest extends AbstractAuthenticationTest {
|
||||||
List<AuthenticationFlowRepresentation> flows = authMgmtResource.getFlows();
|
List<AuthenticationFlowRepresentation> flows = authMgmtResource.getFlows();
|
||||||
for (AuthenticationFlowRepresentation flow : flows) {
|
for (AuthenticationFlowRepresentation flow : flows) {
|
||||||
// get all executions for flow
|
// get all executions for flow
|
||||||
Response executions = authMgmtResource.getExecutions(flow.getAlias());
|
List<AuthenticationExecutionInfoRepresentation> executionReps = authMgmtResource.getExecutions(flow.getAlias());
|
||||||
List<AuthenticationExecutionInfoRepresentation> executionReps = executions.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
for (AuthenticationExecutionInfoRepresentation exec : executionReps) {
|
for (AuthenticationExecutionInfoRepresentation exec : executionReps) {
|
||||||
// separately load referenced configurations
|
// separately load referenced configurations
|
||||||
|
|
|
@ -45,9 +45,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get executions
|
// get executions
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
List<AuthenticationExecutionInfoRepresentation> executions = authMgmtResource.getExecutions("Copy of browser");
|
||||||
List<AuthenticationExecutionInfoRepresentation> executions = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
AuthenticationExecutionInfoRepresentation last = executions.get(executions.size() - 1);
|
AuthenticationExecutionInfoRepresentation last = executions.get(executions.size() - 1);
|
||||||
AuthenticationExecutionInfoRepresentation oneButLast = executions.get(executions.size() - 2);
|
AuthenticationExecutionInfoRepresentation oneButLast = executions.get(executions.size() - 2);
|
||||||
|
@ -55,9 +53,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest {
|
||||||
// shift last execution up
|
// shift last execution up
|
||||||
authMgmtResource.raisePriority(last.getId());
|
authMgmtResource.raisePriority(last.getId());
|
||||||
|
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
List<AuthenticationExecutionInfoRepresentation> executions2 = authMgmtResource.getExecutions("Copy of browser");
|
||||||
List<AuthenticationExecutionInfoRepresentation> executions2 = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
AuthenticationExecutionInfoRepresentation last2 = executions2.get(executions.size() - 1);
|
AuthenticationExecutionInfoRepresentation last2 = executions2.get(executions.size() - 1);
|
||||||
AuthenticationExecutionInfoRepresentation oneButLast2 = executions2.get(executions.size() - 2);
|
AuthenticationExecutionInfoRepresentation oneButLast2 = executions2.get(executions.size() - 2);
|
||||||
|
@ -68,9 +64,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest {
|
||||||
// shift one before last down
|
// shift one before last down
|
||||||
authMgmtResource.lowerPriority(oneButLast2.getId());
|
authMgmtResource.lowerPriority(oneButLast2.getId());
|
||||||
|
|
||||||
response = authMgmtResource.getExecutions("Copy of browser");
|
executions2 = authMgmtResource.getExecutions("Copy of browser");
|
||||||
executions2 = response.readEntity(new GenericType<List<AuthenticationExecutionInfoRepresentation>>() {
|
|
||||||
});
|
|
||||||
|
|
||||||
last2 = executions2.get(executions.size() - 1);
|
last2 = executions2.get(executions.size() - 1);
|
||||||
oneButLast2 = executions2.get(executions.size() - 2);
|
oneButLast2 = executions2.get(executions.size() - 2);
|
||||||
|
|
Loading…
Reference in a new issue