From afcdce6b71de4e699606830d8e0a8b017e813c9f Mon Sep 17 00:00:00 2001 From: mposolda Date: Thu, 21 Apr 2016 22:47:55 +0200 Subject: [PATCH] Simplified calling of AuthenticationManagementResource.getExecutions() --- .../AuthenticationManagementResource.java | 2 +- .../AbstractCustomAccountManagementTest.java | 10 +--- .../testsuite/admin/UserFederationTest.java | 10 +--- .../admin/authentication/ExecutionTest.java | 51 +++++-------------- .../authentication/InitialFlowsTest.java | 4 +- .../authentication/ShiftExecutionTest.java | 12 ++--- 6 files changed, 22 insertions(+), 67 deletions(-) diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/AuthenticationManagementResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/AuthenticationManagementResource.java index 197aeb69d9..d5de7be076 100644 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/AuthenticationManagementResource.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/AuthenticationManagementResource.java @@ -100,7 +100,7 @@ public interface AuthenticationManagementResource { @Path("/flows/{flowAlias}/executions") @GET @Produces(MediaType.APPLICATION_JSON) - Response getExecutions(@PathParam("flowAlias") String flowAlias); + List getExecutions(@PathParam("flowAlias") String flowAlias); @Path("/flows/{flowAlias}/executions") @PUT diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/custom/AbstractCustomAccountManagementTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/custom/AbstractCustomAccountManagementTest.java index 36ff0f69bd..c8f6d56638 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/custom/AbstractCustomAccountManagementTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/custom/AbstractCustomAccountManagementTest.java @@ -56,14 +56,8 @@ public abstract class AbstractCustomAccountManagementTest extends AbstractAccoun } protected AuthenticationExecutionInfoRepresentation getExecution(String flowAlias, String provider) { - Response response = authMgmtResource.getExecutions(flowAlias); - - List executionReps = response.readEntity( - new GenericType>() { - }); - - response.close(); - + List executionReps = authMgmtResource.getExecutions(flowAlias); + for (AuthenticationExecutionInfoRepresentation exec : executionReps) { if (provider.equals(exec.getProviderId())) { return exec; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserFederationTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserFederationTest.java index 3ad31a6c9f..0cd3508692 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserFederationTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserFederationTest.java @@ -348,14 +348,8 @@ public class UserFederationTest extends AbstractAdminTest { private AuthenticationExecutionInfoRepresentation findKerberosExecution() { AuthenticationExecutionInfoRepresentation kerberosExecution = null; - Response response = realm.flows().getExecutions("browser"); - try { - List executionReps = response.readEntity(new GenericType>() { - }); - kerberosExecution = AbstractAuthenticationTest.findExecutionByProvider("auth-spnego", executionReps); - } finally { - response.close(); - } + List executionReps = realm.flows().getExecutions("browser"); + kerberosExecution = AbstractAuthenticationTest.findExecutionByProvider("auth-spnego", executionReps); Assert.assertNotNull(kerberosExecution); return kerberosExecution; diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ExecutionTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ExecutionTest.java index afe702f033..7852e22b5f 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ExecutionTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ExecutionTest.java @@ -68,20 +68,12 @@ public class ExecutionTest extends AbstractAuthenticationTest { authMgmtResource.addExecution("Copy of browser", params); // check execution was added - response = authMgmtResource.getExecutions("Copy of browser"); - AuthenticationExecutionInfoRepresentation exec; - AuthenticationExecutionInfoRepresentation authCookieExec; - try { - List executionReps = response.readEntity(new GenericType>() { - }); - exec = findExecutionByProvider("idp-review-profile", executionReps); - Assert.assertNotNull("idp-review-profile added", exec); + List executionReps = authMgmtResource.getExecutions("Copy of browser"); + AuthenticationExecutionInfoRepresentation exec = findExecutionByProvider("idp-review-profile", executionReps); + Assert.assertNotNull("idp-review-profile added", exec); - // we'll need auth-cookie later - authCookieExec = findExecutionByProvider("auth-cookie", executionReps); - } finally { - response.close(); - } + // we'll need auth-cookie later + AuthenticationExecutionInfoRepresentation authCookieExec = findExecutionByProvider("auth-cookie", executionReps); 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()); // check execution was removed - response = authMgmtResource.getExecutions("Copy of browser"); - try { - List executionReps = response.readEntity(new GenericType>() { - }); - exec = findExecutionByProvider("idp-review-profile", executionReps); - Assert.assertNull("idp-review-profile removed", exec); - } finally { - response.close(); - } + executionReps = authMgmtResource.getExecutions("Copy of browser"); + exec = findExecutionByProvider("idp-review-profile", executionReps); + Assert.assertNull("idp-review-profile removed", exec); // now add the execution again using a different method and representation @@ -130,16 +116,9 @@ public class ExecutionTest extends AbstractAuthenticationTest { } // check execution was added - List executions; - response = authMgmtResource.getExecutions("Copy of browser"); - try { - executions = response.readEntity(new GenericType>() { - }); - exec = findExecutionByProvider("auth-cookie", executions); - Assert.assertNotNull("auth-cookie added", exec); - } finally { - response.close(); - } + List executions = authMgmtResource.getExecutions("Copy of browser"); + exec = findExecutionByProvider("auth-cookie", executions); + Assert.assertNotNull("auth-cookie added", exec); // Note: there is no checking in addExecution if requirement is one of requirementChoices // Thus we can have OPTIONAL which is neither ALTERNATIVE, nor DISABLED @@ -150,10 +129,7 @@ public class ExecutionTest extends AbstractAuthenticationTest { public void testUpdateExecution() { // get current auth-cookie execution - Response response = authMgmtResource.getExecutions("browser"); - List executionReps = response.readEntity( - new GenericType>() { - }); + List executionReps = authMgmtResource.getExecutions("browser"); AuthenticationExecutionInfoRepresentation exec = findExecutionByProvider("auth-cookie", executionReps); Assert.assertEquals("auth-cookie set to ALTERNATIVE", ALTERNATIVE, exec.getRequirement()); @@ -163,8 +139,7 @@ public class ExecutionTest extends AbstractAuthenticationTest { authMgmtResource.updateExecutions("browser", exec); // make sure the change is visible - response = authMgmtResource.getExecutions("browser"); - executionReps = response.readEntity(new GenericType>() {}); + executionReps = authMgmtResource.getExecutions("browser"); // get current auth-cookie execution AuthenticationExecutionInfoRepresentation exec2 = findExecutionByProvider("auth-cookie", executionReps); diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java index 45f538fbd3..0f8487b74e 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java @@ -55,9 +55,7 @@ public class InitialFlowsTest extends AbstractAuthenticationTest { List flows = authMgmtResource.getFlows(); for (AuthenticationFlowRepresentation flow : flows) { // get all executions for flow - Response executions = authMgmtResource.getExecutions(flow.getAlias()); - List executionReps = executions.readEntity(new GenericType>() { - }); + List executionReps = authMgmtResource.getExecutions(flow.getAlias()); for (AuthenticationExecutionInfoRepresentation exec : executionReps) { // separately load referenced configurations diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ShiftExecutionTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ShiftExecutionTest.java index b7c3c15c61..f9d4f001bd 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ShiftExecutionTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ShiftExecutionTest.java @@ -45,9 +45,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest { } // get executions - response = authMgmtResource.getExecutions("Copy of browser"); - List executions = response.readEntity(new GenericType>() { - }); + List executions = authMgmtResource.getExecutions("Copy of browser"); AuthenticationExecutionInfoRepresentation last = executions.get(executions.size() - 1); AuthenticationExecutionInfoRepresentation oneButLast = executions.get(executions.size() - 2); @@ -55,9 +53,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest { // shift last execution up authMgmtResource.raisePriority(last.getId()); - response = authMgmtResource.getExecutions("Copy of browser"); - List executions2 = response.readEntity(new GenericType>() { - }); + List executions2 = authMgmtResource.getExecutions("Copy of browser"); AuthenticationExecutionInfoRepresentation last2 = executions2.get(executions.size() - 1); AuthenticationExecutionInfoRepresentation oneButLast2 = executions2.get(executions.size() - 2); @@ -68,9 +64,7 @@ public class ShiftExecutionTest extends AbstractAuthenticationTest { // shift one before last down authMgmtResource.lowerPriority(oneButLast2.getId()); - response = authMgmtResource.getExecutions("Copy of browser"); - executions2 = response.readEntity(new GenericType>() { - }); + executions2 = authMgmtResource.getExecutions("Copy of browser"); last2 = executions2.get(executions.size() - 1); oneButLast2 = executions2.get(executions.size() - 2);