diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/ProfileAssume.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/ProfileAssume.java index f0e79d27b3..c5e7a212af 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/ProfileAssume.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/ProfileAssume.java @@ -36,7 +36,7 @@ public class ProfileAssume { private static Set disabledFeatures; private static String profile; - static { + private static void updateProfile() { String host = System.getProperty("auth.server.host", "localhost"); String port = System.getProperty("auth.server.http.port", "8180"); boolean adapterCompatTesting = Boolean.parseBoolean(System.getProperty("testsuite.adapter.compat.testing")); @@ -53,18 +53,22 @@ public class ProfileAssume { } public static void assumeFeatureEnabled(Profile.Feature feature) { + updateProfile(); Assume.assumeTrue("Ignoring test as feature " + feature.name() + " is not enabled", isFeatureEnabled(feature)); } public static void assumePreview() { + updateProfile(); Assume.assumeTrue("Ignoring test as community/preview profile is not enabled", !profile.equals("product")); } public static void assumePreviewDisabled() { + updateProfile(); Assume.assumeFalse("Ignoring test as community/preview profile is enabled", !profile.equals("product")); } public static void assumeCommunity() { + updateProfile(); Assume.assumeTrue("Ignoring test as community profile is not enabled", profile.equals("community")); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/RulesPolicyManagementTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/RulesPolicyManagementTest.java index dfdcbfc21f..29fcff0015 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/RulesPolicyManagementTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization/RulesPolicyManagementTest.java @@ -16,14 +16,7 @@ */ package org.keycloak.testsuite.admin.client.authorization; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.Collections; - -import javax.ws.rs.NotFoundException; -import javax.ws.rs.core.Response; - +import org.junit.BeforeClass; import org.junit.Test; import org.keycloak.admin.client.resource.AuthorizationResource; import org.keycloak.admin.client.resource.RulePoliciesResource; @@ -33,21 +26,33 @@ import org.keycloak.representations.idm.authorization.DecisionStrategy; import org.keycloak.representations.idm.authorization.Logic; import org.keycloak.representations.idm.authorization.RulePolicyRepresentation; import org.keycloak.testsuite.ProfileAssume; +import org.keycloak.testsuite.arquillian.annotation.RestartContainer; + +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.Response; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * @author Pedro Igor */ +@RestartContainer(enableFeatures = Profile.Feature.AUTHZ_DROOLS_POLICY) public class RulesPolicyManagementTest extends AbstractPolicyManagementTest { + @BeforeClass + public static void verifyEnvironment() { + ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHZ_DROOLS_POLICY); + } + @Test public void testCreate() { - ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHZ_DROOLS_POLICY); assertCreated(getClient().authorization(), createDefaultRepresentation("Rule Policy")); } @Test public void testUpdate() { - ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHZ_DROOLS_POLICY); AuthorizationResource authorization = getClient().authorization(); RulePolicyRepresentation representation = createDefaultRepresentation("Update Rule Policy"); @@ -72,7 +77,6 @@ public class RulesPolicyManagementTest extends AbstractPolicyManagementTest { @Test public void testDelete() { - ProfileAssume.assumeFeatureEnabled(Profile.Feature.AUTHZ_DROOLS_POLICY); AuthorizationResource authorization = getClient().authorization(); RulePolicyRepresentation representation = createDefaultRepresentation("Delete Rule Policy"); @@ -124,7 +128,7 @@ public class RulesPolicyManagementTest extends AbstractPolicyManagementTest { private void assertRepresentation(RulePolicyRepresentation expected, RulePolicyResource policy) { RulePolicyRepresentation actual = policy.toRepresentation(); - assertRepresentation(expected, actual, () -> policy.resources(), () -> Collections.emptyList(), () -> policy.associatedPolicies()); + assertRepresentation(expected, actual, policy::resources, Collections::emptyList, policy::associatedPolicies); assertEquals(expected.getName(), actual.getName()); assertEquals(expected.getDescription(), actual.getDescription()); assertEquals(expected.getLogic(), actual.getLogic());