features = new ArrayList<>();
for (Profile.Feature value : Profile.Feature.values()) {
- features.add(value.name().toLowerCase().replace('_', '-'));
+ features.add(value.getKey());
}
- features.add(Profile.Type.PREVIEW.name().toLowerCase());
+ features.add(Profile.Feature.Type.PREVIEW.name().toLowerCase());
+
+ Collections.sort(features);
return features;
}
diff --git a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ConfigBuildItem.java b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ConfigBuildItem.java
new file mode 100644
index 0000000000..e2fa616a1e
--- /dev/null
+++ b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ConfigBuildItem.java
@@ -0,0 +1,6 @@
+package org.keycloak.quarkus.deployment;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+
+public final class ConfigBuildItem extends SimpleBuildItem {
+}
diff --git a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java
index 92ec803e6e..8c509952b4 100644
--- a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java
+++ b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java
@@ -94,6 +94,8 @@ import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.keycloak.Config;
import org.keycloak.common.crypto.FipsMode;
+import org.keycloak.common.profile.PropertiesFileProfileConfigResolver;
+import org.keycloak.common.profile.PropertiesProfileConfigResolver;
import org.keycloak.config.SecurityOptions;
import org.keycloak.config.StorageOptions;
import org.keycloak.config.TransactionOptions;
@@ -101,7 +103,7 @@ import org.keycloak.connections.jpa.JpaConnectionProvider;
import org.keycloak.connections.jpa.JpaConnectionSpi;
import org.keycloak.models.map.storage.jpa.JpaMapStorageProviderFactory;
import org.keycloak.protocol.saml.mappers.DeployedScriptSAMLProtocolMapper;
-import org.keycloak.quarkus.runtime.QuarkusProfile;
+import org.keycloak.quarkus.runtime.QuarkusProfileConfigResolver;
import org.keycloak.quarkus.runtime.configuration.PersistedConfigSource;
import org.keycloak.quarkus.runtime.configuration.QuarkusPropertiesConfigSource;
import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper;
@@ -207,6 +209,26 @@ class KeycloakProcessor {
return new FeatureBuildItem("keycloak");
}
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ ConfigBuildItem initConfig(KeycloakRecorder recorder) {
+ Config.init(new MicroProfileConfigProvider());
+ recorder.initConfig();
+ return new ConfigBuildItem();
+ }
+
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ @Consume(ConfigBuildItem.class)
+ ProfileBuildItem configureProfile(KeycloakRecorder recorder) {
+ Profile profile = Profile.configure(
+ new QuarkusProfileConfigResolver(),
+ new PropertiesFileProfileConfigResolver()); // Need profile.properties for now as testsuite relies on it
+ recorder.configureProfile(profile.getName(), profile.getFeatures());
+
+ return new ProfileBuildItem();
+ }
+
/**
* Configures the persistence unit for Quarkus.
*
@@ -331,8 +353,8 @@ class KeycloakProcessor {
*/
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
+ @Consume(ProfileBuildItem.class)
KeycloakSessionFactoryPreInitBuildItem configureKeycloakSessionFactory(KeycloakRecorder recorder, List descriptors) {
- Profile.setInstance(new QuarkusProfile());
Map, Map>>> factories = new HashMap<>();
Map, String> defaultProviders = new HashMap<>();
Map preConfiguredProviders = new HashMap<>();
diff --git a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ProfileBuildItem.java b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ProfileBuildItem.java
new file mode 100644
index 0000000000..7b497608fb
--- /dev/null
+++ b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/ProfileBuildItem.java
@@ -0,0 +1,6 @@
+package org.keycloak.quarkus.deployment;
+
+import io.quarkus.builder.item.SimpleBuildItem;
+
+public final class ProfileBuildItem extends SimpleBuildItem {
+}
diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakRecorder.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakRecorder.java
index d5b08030d0..c7d887d902 100644
--- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakRecorder.java
+++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/KeycloakRecorder.java
@@ -64,6 +64,14 @@ public class KeycloakRecorder {
public static final String DEFAULT_HEALTH_ENDPOINT = "/health";
public static final String DEFAULT_METRICS_ENDPOINT = "/metrics";
+ public void initConfig() {
+ Config.init(new MicroProfileConfigProvider());
+ }
+
+ public void configureProfile(Profile.ProfileName profileName, Map features) {
+ Profile.init(profileName, features);
+ }
+
public void configureLiquibase(Map> services) {
ServiceLocator locator = Scope.getCurrentScope().getServiceLocator();
if (locator instanceof FastServiceLocator)
@@ -75,8 +83,6 @@ public class KeycloakRecorder {
Map, String> defaultProviders,
Map preConfiguredProviders,
List themes, boolean reaugmented) {
- Config.init(new MicroProfileConfigProvider());
- Profile.setInstance(new QuarkusProfile());
QuarkusKeycloakSessionFactory.setInstance(new QuarkusKeycloakSessionFactory(factories, defaultProviders, preConfiguredProviders, themes, reaugmented));
}
diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfile.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfile.java
deleted file mode 100644
index a8e64a1b18..0000000000
--- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfile.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2021 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.keycloak.quarkus.runtime;
-
-import static org.keycloak.quarkus.runtime.configuration.Configuration.getRawPersistedProperty;
-
-import org.keycloak.common.Profile;
-import org.keycloak.quarkus.runtime.configuration.Configuration;
-
-public class QuarkusProfile extends Profile {
-
- public QuarkusProfile() {
- super(new DefaultPropertyResolver());
- }
-
- private static class DefaultPropertyResolver implements PropertyResolver {
-
- @Override
- public String resolve(String key) {
- if (isFeaturePresent(key, getCurrentValue("kc.features"))) {
- if (isPreviewProfileKey(key)) {
- return Profile.Type.PREVIEW.name();
- }
-
- return "enabled";
- }
-
- if (isFeaturePresent(key, getCurrentValue("kc.features-disabled"))) {
- if (!isPreviewProfileKey(key)) {
- return "disabled";
- }
- }
-
- return null;
- }
-
- private boolean isFeaturePresent(String key, String features) {
- if (features == null) {
- return false;
- }
-
- for (String feature : features.split(",")) {
- if (isPreviewProfileKey(key)) {
- try {
- Profile.Type profileType = Profile.Type.valueOf(feature);
-
- if (Profile.Type.PREVIEW.equals(profileType)) {
- return true;
- }
- } catch (IllegalArgumentException ignore) {
- }
-
- return false;
- }
-
- if (key.substring(key.lastIndexOf('.') + 1).toUpperCase().equals(feature)) {
- return true;
- }
- }
-
- return false;
- }
-
- private boolean isPreviewProfileKey(String key) {
- return key.equals("keycloak.profile");
- }
-
- private String getCurrentValue(String name) {
- String enabledFeatures = getRawPersistedProperty(name).orElse(null);
-
- if (enabledFeatures == null) {
- enabledFeatures = Configuration.getRawValue(name);
- }
-
- if (enabledFeatures == null) {
- return null;
- }
-
- return enabledFeatures.toUpperCase().replace('-', '_');
- }
- }
-}
diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfileConfigResolver.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfileConfigResolver.java
new file mode 100644
index 0000000000..f1319577a1
--- /dev/null
+++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/QuarkusProfileConfigResolver.java
@@ -0,0 +1,17 @@
+package org.keycloak.quarkus.runtime;
+
+import org.keycloak.common.profile.CommaSeparatedListProfileConfigResolver;
+import org.keycloak.quarkus.runtime.configuration.Configuration;
+
+public class QuarkusProfileConfigResolver extends CommaSeparatedListProfileConfigResolver {
+
+ public QuarkusProfileConfigResolver() {
+ super(getConfig("kc.features"), getConfig("kc.features-disabled"));
+ }
+
+ private static String getConfig(String key) {
+ return Configuration.getRawPersistedProperty(key)
+ .orElse(Configuration.getRawValue(key));
+ }
+
+}
diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/FeaturePropertyMappers.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/FeaturePropertyMappers.java
index c50087be10..5b9cd8a2bd 100644
--- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/FeaturePropertyMappers.java
+++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/FeaturePropertyMappers.java
@@ -2,9 +2,7 @@ package org.keycloak.quarkus.runtime.configuration.mappers;
import org.keycloak.common.Profile;
import org.keycloak.config.FeatureOptions;
-import org.keycloak.config.StorageOptions;
import org.keycloak.quarkus.runtime.configuration.Configuration;
-import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
import static java.util.Optional.of;
import static org.keycloak.config.StorageOptions.STORAGE;
@@ -42,7 +40,7 @@ final class FeaturePropertyMappers {
Set featureSet = new HashSet<>(List.of(features.orElse("").split(",")));
- featureSet.add(Profile.Feature.MAP_STORAGE.name().replace('_', '-'));
+ featureSet.add(Profile.Feature.MAP_STORAGE.getKey());
return of(String.join(",", featureSet));
}
diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/FeaturesDistTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/FeaturesDistTest.java
index c3149a137b..260890995d 100644
--- a/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/FeaturesDistTest.java
+++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/cli/dist/FeaturesDistTest.java
@@ -52,10 +52,18 @@ public class FeaturesDistTest {
@Test
@Launch({StartDev.NAME, "--features=preview", "--features-disabled=token-exchange"})
+ public void testPreviewFeatureDisabledInPreviewMode(LaunchResult result) {
+ CLIResult cliResult = (CLIResult) result;
+ cliResult.assertStartedDevMode();
+ assertFalse(cliResult.getOutput().contains("token-exchange"));
+ }
+
+ @Test
+ @Launch({StartDev.NAME, "--features=token-exchange", "--features-disabled=token-exchange"})
public void testEnablePrecedenceOverDisable(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
cliResult.assertStartedDevMode();
- assertPreviewFeaturesEnabled((CLIResult) result);
+ assertThat(cliResult.getOutput(), containsString("Preview features enabled: token-exchange"));
}
@Test
@@ -65,8 +73,7 @@ public class FeaturesDistTest {
CLIResult cliResult = (CLIResult) result;
cliResult.assertStartedDevMode();
assertThat(cliResult.getOutput(), CoreMatchers.allOf(
- containsString("Preview feature enabled: admin_fine_grained_authz"),
- containsString("Preview feature enabled: token_exchange")));
+ containsString("Preview features enabled: admin-fine-grained-authz, token-exchange")));
assertFalse(cliResult.getOutput().contains("declarative-user-profile"));
}
@@ -77,17 +84,12 @@ public class FeaturesDistTest {
CLIResult cliResult = (CLIResult) result;
cliResult.assertStartedDevMode();
assertThat(cliResult.getOutput(), CoreMatchers.allOf(
- containsString("Preview feature enabled: admin_fine_grained_authz"),
- containsString("Preview feature enabled: token_exchange")));
+ containsString("Preview features enabled: admin-fine-grained-authz, token-exchange")));
assertFalse(cliResult.getOutput().contains("declarative-user-profile"));
}
private void assertPreviewFeaturesEnabled(CLIResult result) {
assertThat(result.getOutput(), CoreMatchers.allOf(
- containsString("Preview feature enabled: admin_fine_grained_authz"),
- containsString("Preview feature enabled: openshift_integration"),
- containsString("Preview feature enabled: scripts"),
- containsString("Preview feature enabled: token_exchange"),
- containsString("Preview feature enabled: declarative_user_profile")));
+ containsString("Preview features enabled: admin-fine-grained-authz, client-secret-rotation, declarative-user-profile, openshift-integration, recovery-codes, scripts, token-exchange, update-email")));
}
}
diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/ChmStorageDistTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/ChmStorageDistTest.java
index 8a19b4b682..3739bc98fd 100644
--- a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/ChmStorageDistTest.java
+++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/ChmStorageDistTest.java
@@ -48,7 +48,7 @@ public class ChmStorageDistTest {
}
private void assertExpectedMessages(CLIResult cliResult, RawDistRootPath distPath) {
- cliResult.assertMessage("Experimental feature enabled: map_storage");
+ cliResult.assertMessage("Experimental features enabled: map-storage");
cliResult.assertMessage("Hibernate ORM is disabled because no JPA entities were found");
Assert.assertFalse(distPath.getDistRootPath().resolve("data").resolve("h2").toFile().exists());
}
diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/HotRodStoreDistTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/HotRodStoreDistTest.java
index 16e75f4a01..320ffe6fe4 100644
--- a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/HotRodStoreDistTest.java
+++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/HotRodStoreDistTest.java
@@ -32,7 +32,7 @@ public class HotRodStoreDistTest {
@Launch({ "start", "--optimized", "--http-enabled=true", "--hostname-strict=false" })
void testSuccessful(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
- cliResult.assertMessage("Experimental feature enabled: map_storage");
+ cliResult.assertMessage("Experimental features enabled: map-storage");
cliResult.assertMessage("[org.keycloak.models.map.storage.hotRod.connections.DefaultHotRodConnectionProviderFactory] (main) HotRod client configuration was successful.");
cliResult.assertStarted();
}
diff --git a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/JPAStoreDistTest.java b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/JPAStoreDistTest.java
index 274adc92a8..3cd1cde040 100644
--- a/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/JPAStoreDistTest.java
+++ b/quarkus/tests/integration/src/test/java/org/keycloak/it/storage/map/JPAStoreDistTest.java
@@ -33,7 +33,7 @@ public class JPAStoreDistTest {
@Launch({ "start", "--optimized", "--http-enabled=true", "--hostname-strict=false" })
void testSuccessful(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
- cliResult.assertMessage("Experimental feature enabled: map_storage");
+ cliResult.assertMessage("Experimental features enabled: map-storage");
cliResult.assertMessage("[org.keycloak.models.map.storage.jpa.liquibase.updater.MapJpaLiquibaseUpdaterProvider] (main) Initializing database schema. Using changelog META-INF/jpa-realms-changelog.xml");
cliResult.assertStarted();
}
diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testBuildHelp.unix.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testBuildHelp.unix.approved.txt
index 5b405bcb3a..cfefb3a758 100644
--- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testBuildHelp.unix.approved.txt
+++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testBuildHelp.unix.approved.txt
@@ -43,19 +43,19 @@ Transaction:
Feature:
---features Enables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+--features Enables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
--features-disabled
- Disables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+ Disables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
HTTP/TLS:
@@ -104,4 +104,4 @@ Examples:
Change the relative path:
- $ kc.sh build --http-relative-path=/auth
\ No newline at end of file
+ $ kc.sh build --http-relative-path=/auth
diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelp.unix.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelp.unix.approved.txt
index b3074df076..05243edaa6 100644
--- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelp.unix.approved.txt
+++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelp.unix.approved.txt
@@ -66,19 +66,19 @@ Transaction:
Feature:
---features Enables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+--features Enables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
--features-disabled
- Disables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+ Disables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
Hostname:
@@ -221,4 +221,4 @@ Logging:
Do NOT start the server using this command when deploying to production.
Use 'kc.sh start-dev --help-all' to list all available options, including build
-options.
\ No newline at end of file
+options.
diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelpAll.unix.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelpAll.unix.approved.txt
index 2b35d521b8..5cf437cec3 100644
--- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelpAll.unix.approved.txt
+++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartDevHelpAll.unix.approved.txt
@@ -124,19 +124,19 @@ Transaction:
Feature:
---features Enables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+--features Enables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
--features-disabled
- Disables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+ Disables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
Hostname:
@@ -285,4 +285,4 @@ Security (Experimental):
Do NOT start the server using this command when deploying to production.
Use 'kc.sh start-dev --help-all' to list all available options, including build
-options.
\ No newline at end of file
+options.
diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelp.unix.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelp.unix.approved.txt
index 9c44c129b5..c49e939ee2 100644
--- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelp.unix.approved.txt
+++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelp.unix.approved.txt
@@ -72,19 +72,19 @@ Transaction:
Feature:
---features Enables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+--features Enables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
--features-disabled
- Disables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+ Disables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
Hostname:
@@ -231,4 +231,4 @@ By default, this command tries to update the server configuration by running a
$ kc.sh start '--optimized'
By doing that, the server should start faster based on any previous
-configuration you have set when manually running the 'build' command.
\ No newline at end of file
+configuration you have set when manually running the 'build' command.
diff --git a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelpAll.unix.approved.txt b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelpAll.unix.approved.txt
index 98ccbd8c43..9d4f3c6f5b 100644
--- a/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelpAll.unix.approved.txt
+++ b/quarkus/tests/integration/src/test/resources/org/keycloak/it/cli/approvals/cli/help/HelpCommandTest.testStartHelpAll.unix.approved.txt
@@ -130,19 +130,19 @@ Transaction:
Feature:
---features Enables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+--features Enables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
--features-disabled
- Disables a set of one or more features. Possible values are: authorization,
- account2, account-api, admin-fine-grained-authz, admin-api, admin, admin2,
- docker, impersonation, openshift-integration, scripts, token-exchange,
- web-authn, client-policies, ciba, map-storage, par,
- declarative-user-profile, dynamic-scopes, client-secret-rotation,
- step-up-authentication, recovery-codes, update-email, js-adapter, preview.
+ Disables a set of one or more features. Possible values are: account-api,
+ account2, admin, admin-api, admin-fine-grained-authz, admin2, authorization,
+ ciba, client-policies, client-secret-rotation, declarative-user-profile,
+ docker, dynamic-scopes, impersonation, js-adapter, map-storage,
+ openshift-integration, par, preview, recovery-codes, scripts,
+ step-up-authentication, token-exchange, update-email, web-authn.
Hostname:
@@ -295,4 +295,4 @@ By default, this command tries to update the server configuration by running a
$ kc.sh start '--optimized'
By doing that, the server should start faster based on any previous
-configuration you have set when manually running the 'build' command.
\ No newline at end of file
+configuration you have set when manually running the 'build' command.
diff --git a/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocolFactory.java b/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocolFactory.java
index 23a959e552..0adc9e623a 100755
--- a/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocolFactory.java
+++ b/services/src/main/java/org/keycloak/protocol/oidc/OIDCLoginProtocolFactory.java
@@ -110,6 +110,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
@Override
public void init(Config.Scope config) {
+ initBuiltIns();
this.providerConfig = new OIDCProviderConfig(config);
if (providerConfig.isLegacyLogoutRedirectUri()) {
logger.warnf("Deprecated switch '%s' is enabled. Please try to disable it and update your clients to use OpenID Connect compliant way for RP-initiated logout.", CONFIG_LEGACY_LOGOUT_REDIRECT_URI);
@@ -129,9 +130,9 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
return builtins;
}
- static Map builtins = new HashMap<>();
+ private Map builtins = new HashMap<>();
- static {
+ void initBuiltIns() {
ProtocolMapperModel model;
model = UserPropertyMapper.createClaimMapper(USERNAME,
"username",
@@ -218,7 +219,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
}
}
- private static void createUserAttributeMapper(String name, String attrName, String claimName, String type) {
+ private void createUserAttributeMapper(String name, String attrName, String claimName, String type) {
ProtocolMapperModel model = UserAttributeMapper.createClaimMapper(name,
attrName,
claimName, type,
@@ -297,7 +298,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
}
- public static ClientScopeModel addRolesClientScope(RealmModel newRealm) {
+ public ClientScopeModel addRolesClientScope(RealmModel newRealm) {
ClientScopeModel rolesScope = KeycloakModelUtils.getClientScopeByName(newRealm, ROLES_SCOPE);
if (rolesScope == null) {
rolesScope = newRealm.addClientScope(ROLES_SCOPE);
@@ -320,7 +321,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
}
- public static ClientScopeModel addWebOriginsClientScope(RealmModel newRealm) {
+ public ClientScopeModel addWebOriginsClientScope(RealmModel newRealm) {
ClientScopeModel originsScope = KeycloakModelUtils.getClientScopeByName(newRealm, WEB_ORIGINS_SCOPE);
if (originsScope == null) {
originsScope = newRealm.addClientScope(WEB_ORIGINS_SCOPE);
@@ -347,7 +348,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
* @param newRealm the realm to which the {@code microprofile-jwt} scope is to be added.
* @return a reference to the {@code microprofile-jwt} client scope that was either created or already exists in the realm.
*/
- public static ClientScopeModel addMicroprofileJWTClientScope(RealmModel newRealm) {
+ public ClientScopeModel addMicroprofileJWTClientScope(RealmModel newRealm) {
ClientScopeModel microprofileScope = KeycloakModelUtils.getClientScopeByName(newRealm, MICROPROFILE_JWT_SCOPE);
if (microprofileScope == null) {
microprofileScope = newRealm.addClientScope(MICROPROFILE_JWT_SCOPE);
@@ -366,7 +367,7 @@ public class OIDCLoginProtocolFactory extends AbstractLoginProtocolFactory {
}
- public static void addAcrClientScope(RealmModel newRealm) {
+ public void addAcrClientScope(RealmModel newRealm) {
if (Profile.isFeatureEnabled(Profile.Feature.STEP_UP_AUTHENTICATION)) {
ClientScopeModel acrScope = KeycloakModelUtils.getClientScopeByName(newRealm, ACR_SCOPE);
if (acrScope == null) {
diff --git a/services/src/main/java/org/keycloak/services/migration/DefaultMigrationProvider.java b/services/src/main/java/org/keycloak/services/migration/DefaultMigrationProvider.java
index f16afcf4af..74a8d5b0b2 100755
--- a/services/src/main/java/org/keycloak/services/migration/DefaultMigrationProvider.java
+++ b/services/src/main/java/org/keycloak/services/migration/DefaultMigrationProvider.java
@@ -23,17 +23,15 @@ import org.keycloak.models.ClientScopeModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.ProtocolMapperModel;
import org.keycloak.models.RealmModel;
-import org.keycloak.models.utils.ModelToRepresentation;
import org.keycloak.protocol.LoginProtocol;
import org.keycloak.protocol.LoginProtocolFactory;
+import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.OIDCLoginProtocolFactory;
-import org.keycloak.provider.ProviderFactory;
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
import org.keycloak.services.managers.RealmManager;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -84,26 +82,29 @@ public class DefaultMigrationProvider implements MigrationProvider {
new RealmManager(session).setupAdminCli(realm);
}
+ private OIDCLoginProtocolFactory getOIDCLoginProtocolFactory() {
+ return (OIDCLoginProtocolFactory) session.getKeycloakSessionFactory().getProviderFactory(LoginProtocol.class, OIDCLoginProtocol.LOGIN_PROTOCOL);
+ }
@Override
public ClientScopeModel addOIDCRolesClientScope(RealmModel realm) {
- return OIDCLoginProtocolFactory.addRolesClientScope(realm);
+ return getOIDCLoginProtocolFactory().addRolesClientScope(realm);
}
@Override
public ClientScopeModel addOIDCWebOriginsClientScope(RealmModel realm) {
- return OIDCLoginProtocolFactory.addWebOriginsClientScope(realm);
+ return getOIDCLoginProtocolFactory().addWebOriginsClientScope(realm);
}
@Override
public ClientScopeModel addOIDCMicroprofileJWTClientScope(RealmModel realm) {
- return OIDCLoginProtocolFactory.addMicroprofileJWTClientScope(realm);
+ return getOIDCLoginProtocolFactory().addMicroprofileJWTClientScope(realm);
}
@Override
public void addOIDCAcrClientScope(RealmModel realm) {
- OIDCLoginProtocolFactory.addAcrClientScope(realm);
+ getOIDCLoginProtocolFactory().addAcrClientScope(realm);
}
@Override
diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/rest/TestingResourceProvider.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/rest/TestingResourceProvider.java
index f586674f16..36fdf2afda 100644
--- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/rest/TestingResourceProvider.java
+++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/rest/TestingResourceProvider.java
@@ -112,6 +112,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.UUID;
@@ -890,89 +891,66 @@ public class TestingResourceProvider implements RealmResourceProvider {
}
}
+ @GET
+ @Path("/list-disabled-features")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Set listDisabledFeatures() {
+ return Profile.getInstance().getDisabledFeatures();
+ }
+
@POST
@Path("/enable-feature/{feature}")
@Consumes(MediaType.APPLICATION_JSON)
- public Response enableFeature(@PathParam("feature") String feature) {
- Profile.Feature featureProfile;
-
- try {
- featureProfile = Profile.Feature.valueOf(feature);
- } catch (IllegalArgumentException e) {
- System.err.printf("Feature '%s' doesn't exist!!\n", feature);
- return Response.status(Response.Status.NOT_FOUND).build();
- }
-
- if (Profile.isFeatureEnabled(featureProfile))
- return Response.noContent().build();
-
- FeatureDeployerUtil.initBeforeChangeFeature(featureProfile);
-
- System.setProperty("keycloak.profile.feature." + featureProfile.toString().toLowerCase(), "enabled");
-
- String jbossServerConfigDir = System.getProperty("jboss.server.config.dir");
- // If we are in jboss-based container, we need to write profile.properties file, otherwise the change in system property will disappear after restart
- if (jbossServerConfigDir != null) {
- setFeatureInProfileFile(new File(jbossServerConfigDir, "profile.properties"), featureProfile, "enabled");
- }
-
- Profile.init();
-
- FeatureDeployerUtil.deployFactoriesAfterFeatureEnabled(featureProfile);
-
- if (Profile.isFeatureEnabled(featureProfile))
- return Response.noContent().build();
- else
- return Response.status(Response.Status.NOT_FOUND).build();
+ @Produces(MediaType.APPLICATION_JSON)
+ public Set enableFeature(@PathParam("feature") String feature) {
+ return updateFeature(feature, true);
}
@POST
@Path("/disable-feature/{feature}")
@Consumes(MediaType.APPLICATION_JSON)
- public Response disableFeature(@PathParam("feature") String feature) {
- Profile.Feature featureProfile;
+ @Produces(MediaType.APPLICATION_JSON)
+ public Set disableFeature(@PathParam("feature") String feature) {
+ return updateFeature(feature, false);
+ }
+
+ private Set updateFeature(String featureKey, boolean shouldEnable) {
+ Profile.Feature feature;
try {
- featureProfile = Profile.Feature.valueOf(feature);
+ feature = Profile.Feature.valueOf(featureKey);
} catch (IllegalArgumentException e) {
- System.err.printf("Feature '%s' doesn't exist!!\n", feature);
- return Response.status(Response.Status.NOT_FOUND).build();
+ System.err.printf("Feature '%s' doesn't exist!!\n", featureKey);
+ throw new BadRequestException();
}
- if (!Profile.isFeatureEnabled(featureProfile))
- return Response.noContent().build();
+ if (Profile.getInstance().getFeatures().get(feature) != shouldEnable) {
+ FeatureDeployerUtil.initBeforeChangeFeature(feature);
- FeatureDeployerUtil.initBeforeChangeFeature(featureProfile);
+ String jbossServerConfigDir = System.getProperty("jboss.server.config.dir");
+ // If we are in jboss-based container, we need to write profile.properties file, otherwise the change in system property will disappear after restart
+ if (jbossServerConfigDir != null) {
+ setFeatureInProfileFile(new File(jbossServerConfigDir, "profile.properties"), feature, shouldEnable ? "enabled" : "disabled");
+ }
- disableFeatureProperties(featureProfile);
+ Profile current = Profile.getInstance();
- String jbossServerConfigDir = System.getProperty("jboss.server.config.dir");
- // If we are in jboss-based container, we need to write profile.properties file, otherwise the change in system property will disappear after restart
- if (jbossServerConfigDir != null) {
- setFeatureInProfileFile(new File(jbossServerConfigDir, "profile.properties"), featureProfile, "disabled");
+ Map updatedFeatures = new HashMap<>();
+ updatedFeatures.putAll(current.getFeatures());
+ updatedFeatures.put(feature, shouldEnable);
+
+ Profile.init(current.getName(), updatedFeatures);
+
+ if (shouldEnable) {
+ FeatureDeployerUtil.deployFactoriesAfterFeatureEnabled(feature);
+ } else {
+ FeatureDeployerUtil.undeployFactoriesAfterFeatureDisabled(feature);
+ }
}
- Profile.init();
-
- FeatureDeployerUtil.undeployFactoriesAfterFeatureDisabled(featureProfile);
-
- if (!Profile.isFeatureEnabled(featureProfile))
- return Response.noContent().build();
- else
- return Response.status(Response.Status.NOT_FOUND).build();
+ return Profile.getInstance().getDisabledFeatures();
}
- /**
- * KEYCLOAK-12958
- */
- private void disableFeatureProperties(Profile.Feature feature) {
- Profile.Type type = feature.getType();
- if (type.equals(Profile.Type.DEFAULT)) {
- System.setProperty("keycloak.profile.feature." + feature.toString().toLowerCase(), "disabled");
- } else {
- System.getProperties().remove("keycloak.profile.feature." + feature.toString().toLowerCase());
- }
- }
@GET
@Path("/set-system-property")
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 5aad6bd10b..f5a184189a 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
@@ -18,14 +18,9 @@
package org.keycloak.testsuite;
import org.junit.Assume;
-import org.keycloak.admin.client.Keycloak;
import org.keycloak.common.Profile;
-import org.keycloak.representations.info.ProfileInfoRepresentation;
-import org.keycloak.testsuite.util.AdminClientUtil;
+import org.keycloak.testsuite.arquillian.TestContext;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
import java.util.Set;
/**
@@ -33,51 +28,34 @@ import java.util.Set;
*/
public class ProfileAssume {
- private static Set disabledFeatures;
- private static String profile;
+ private static Set DISABLED_FEATURES;
+ private static TestContext TEST_CONTEXT;
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"));
-
- String authServerContextRoot = "http://" + host + ":" + port;
- try (Keycloak adminClient = AdminClientUtil.createAdminClient(adapterCompatTesting, authServerContextRoot)) {
- ProfileInfoRepresentation profileInfo = adminClient.serverInfo().getInfo().getProfileInfo();
- profile = profileInfo.getName();
- List disabled = profileInfo.getDisabledFeatures();
- disabledFeatures = Collections.unmodifiableSet(new HashSet<>(disabled));
- } catch (Exception e) {
- throw new RuntimeException("Failed to obtain profile / features info from serverinfo endpoint of " + authServerContextRoot, e);
+ if (DISABLED_FEATURES == null) {
+ DISABLED_FEATURES = TEST_CONTEXT.getTestingClient().testing().listDisabledFeatures();
}
}
public static void assumeFeatureEnabled(Profile.Feature feature) {
updateProfile();
- Assume.assumeTrue("Ignoring test as feature " + feature.name() + " is not enabled", isFeatureEnabled(feature));
+ Assume.assumeTrue("Ignoring test as feature " + feature.getKey() + " is not enabled", isFeatureEnabled(feature));
}
public static void assumeFeatureDisabled(Profile.Feature feature) {
- Assume.assumeTrue("Ignoring test as feature " + feature.name() + " is 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"));
+ Assume.assumeTrue("Ignoring test as feature " + feature.getKey() + " is enabled", !isFeatureEnabled(feature));
}
public static boolean isFeatureEnabled(Profile.Feature feature) {
updateProfile();
- return !disabledFeatures.contains(feature.name());
+ return !DISABLED_FEATURES.contains(feature);
+ }
+
+ public static void updateDisabledFeatures(Set disabledFeatures) {
+ DISABLED_FEATURES = disabledFeatures;
+ }
+
+ public static void setTestContext(TestContext testContext) {
+ TEST_CONTEXT = testContext;
}
}
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AuthServerTestEnricher.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AuthServerTestEnricher.java
index 97e7131670..572002beb7 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AuthServerTestEnricher.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/AuthServerTestEnricher.java
@@ -43,6 +43,7 @@ import org.keycloak.admin.client.Keycloak;
import org.keycloak.common.util.StringPropertyReplacer;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.error.KeycloakErrorHandler;
+import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.arquillian.annotation.SetDefaultProvider;
import org.keycloak.testsuite.arquillian.annotation.UncaughtServerErrorExpected;
import org.keycloak.testsuite.arquillian.annotation.EnableVault;
@@ -462,6 +463,7 @@ public class AuthServerTestEnricher {
public void initializeTestContext(@Observes(precedence = 2) BeforeClass event) throws Exception {
TestContext testContext = new TestContext(suiteContext, event.getTestClass().getJavaClass());
testContextProducer.set(testContext);
+ ProfileAssume.setTestContext(testContext);
boolean wasUpdated = false;
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ModelTestExecutor.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ModelTestExecutor.java
index 68766f503b..4c73d9f49c 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ModelTestExecutor.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/ModelTestExecutor.java
@@ -28,6 +28,7 @@ import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.test.spi.TestResult;
import org.keycloak.common.Profile;
import org.keycloak.common.util.reflections.Reflections;
+import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.arquillian.annotation.ModelTest;
import org.keycloak.testsuite.client.KeycloakTestingClient;
@@ -50,7 +51,7 @@ public class ModelTestExecutor extends LocalTestExecuter {
super.execute(event);
} else {
TestResult result = new TestResult();
- if (annotation.skipForMapStorage() && Profile.isFeatureEnabled(Profile.Feature.MAP_STORAGE)) {
+ if (annotation.skipForMapStorage() && ProfileAssume.isFeatureEnabled(Profile.Feature.MAP_STORAGE)) {
result = TestResult.skipped();
}
else {
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/DisableFeature.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/DisableFeature.java
index 9088ac87fb..41ae3a6a6f 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/DisableFeature.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/DisableFeature.java
@@ -27,11 +27,6 @@ public @interface DisableFeature {
*/
boolean skipRestart() default false;
- /**
- * The feature will be disabled only if the `product` profile is activated
- */
- boolean onlyForProduct() default false;
-
/**
* Feature disable should be the last action in @Before context.
* If the test halted, the feature is returned to the previous state.
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/EnableFeature.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/EnableFeature.java
index fd587025da..ebd54161b7 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/EnableFeature.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/annotation/EnableFeature.java
@@ -27,11 +27,6 @@ public @interface EnableFeature {
*/
boolean skipRestart() default false;
- /**
- * The feature will be enabled only if the `product` profile is activated
- */
- boolean onlyForProduct() default false;
-
/**
* Feature enable should be the last action in @Before context.
* If the test halted, the feature is returned to the previous state.
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/KeycloakContainerFeaturesController.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/KeycloakContainerFeaturesController.java
index 0427cdc304..3c3c43ac1c 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/KeycloakContainerFeaturesController.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/KeycloakContainerFeaturesController.java
@@ -71,21 +71,18 @@ public class KeycloakContainerFeaturesController {
private Profile.Feature feature;
private boolean skipRestart;
private FeatureAction action;
- private boolean onlyForProduct;
private final AnnotatedElement annotatedElement;
- public UpdateFeature(Profile.Feature feature, boolean skipRestart, FeatureAction action, boolean onlyForProduct
- , AnnotatedElement annotatedElement) {
+ public UpdateFeature(Profile.Feature feature, boolean skipRestart, FeatureAction action, AnnotatedElement annotatedElement) {
this.feature = feature;
this.skipRestart = skipRestart;
this.action = action;
- this.onlyForProduct = onlyForProduct;
this.annotatedElement = annotatedElement;
}
private void assertPerformed() {
assertThat("An annotation requested to " + action.name() +
- " feature " + feature.name() + ", however after performing this operation " +
+ " feature " + feature.getKey() + ", however after performing this operation " +
"the feature is not in desired state" ,
ProfileAssume.isFeatureEnabled(feature),
is(action == FeatureAction.ENABLE));
@@ -122,10 +119,6 @@ public class KeycloakContainerFeaturesController {
return action;
}
- public boolean isOnlyForProduct() {
- return onlyForProduct;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -147,7 +140,6 @@ public class KeycloakContainerFeaturesController {
private void updateFeatures(Set updateFeatures) throws Exception {
updateFeatures = updateFeatures.stream()
- .filter(this::skipForProduct)
.collect(Collectors.toSet());
updateFeatures.forEach(UpdateFeature::performAction);
@@ -160,11 +152,6 @@ public class KeycloakContainerFeaturesController {
updateFeatures.forEach(UpdateFeature::assertPerformed);
}
- // KEYCLOAK-12958 WebAuthn profile product/project
- private boolean skipForProduct(UpdateFeature feature) {
- return !feature.onlyForProduct || Profile.getName().equals("product");
- }
-
private void checkAnnotatedElementForFeatureAnnotations(AnnotatedElement annotatedElement, State state) throws Exception {
Set updateFeatureSet = new HashSet<>();
@@ -191,13 +178,12 @@ public class KeycloakContainerFeaturesController {
ret.addAll(Arrays.stream(annotatedElement.getAnnotationsByType(EnableFeature.class))
.map(annotation -> new UpdateFeature(annotation.value(), annotation.skipRestart(),
- state == State.BEFORE ? FeatureAction.ENABLE : FeatureAction.DISABLE, annotation.onlyForProduct(), annotatedElement))
+ state == State.BEFORE ? FeatureAction.ENABLE : FeatureAction.DISABLE, annotatedElement))
.collect(Collectors.toSet()));
ret.addAll(Arrays.stream(annotatedElement.getAnnotationsByType(DisableFeature.class))
.map(annotation -> new UpdateFeature(annotation.value(), annotation.skipRestart(),
- state == State.BEFORE ? FeatureAction.DISABLE : FeatureAction.ENABLE, annotation.onlyForProduct(),
- annotatedElement))
+ state == State.BEFORE ? FeatureAction.DISABLE : FeatureAction.ENABLE, annotatedElement))
.collect(Collectors.toSet()));
return ret;
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/KeycloakTestingClient.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/KeycloakTestingClient.java
index a4f998919d..cb9194839e 100755
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/KeycloakTestingClient.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/KeycloakTestingClient.java
@@ -22,7 +22,9 @@ import javax.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
+import org.junit.Assert;
import org.keycloak.common.Profile;
+import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.client.resources.TestApplicationResource;
import org.keycloak.testsuite.client.resources.TestExampleCompanyResource;
import org.keycloak.testsuite.client.resources.TestSamlApplicationResource;
@@ -31,6 +33,9 @@ import org.keycloak.testsuite.runonserver.*;
import org.keycloak.testsuite.util.AdminClientUtil;
import org.keycloak.util.JsonSerialization;
+import java.util.List;
+import java.util.Set;
+
import static org.junit.Assert.assertEquals;
/**
@@ -74,15 +79,15 @@ public class KeycloakTestingClient implements AutoCloseable {
}
public void enableFeature(Profile.Feature feature) {
- try (Response response = testing().enableFeature(feature.toString())) {
- assertEquals(204, response.getStatus());
- }
+ Set disabledFeatures = testing().enableFeature(feature.toString());
+ Assert.assertFalse(disabledFeatures.contains(feature));
+ ProfileAssume.updateDisabledFeatures(disabledFeatures);
}
public void disableFeature(Profile.Feature feature) {
- try (Response response = testing().disableFeature(feature.toString())) {
- assertEquals(204, response.getStatus());
- }
+ Set disabledFeatures = testing().disableFeature(feature.toString());
+ Assert.assertTrue(disabledFeatures.contains(feature));
+ ProfileAssume.updateDisabledFeatures(disabledFeatures);
}
public TestApplicationResource testApp() { return target.proxy(TestApplicationResource.class); }
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/resources/TestingResource.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/resources/TestingResource.java
index 75841a5ec1..08ff3c5f66 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/resources/TestingResource.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/client/resources/TestingResource.java
@@ -18,6 +18,7 @@
package org.keycloak.testsuite.client.resources;
import org.jboss.resteasy.annotations.cache.NoCache;
+import org.keycloak.common.Profile;
import org.keycloak.representations.idm.AdminEventRepresentation;
import org.keycloak.representations.idm.AuthenticationFlowRepresentation;
import org.keycloak.representations.idm.EventRepresentation;
@@ -38,6 +39,8 @@ import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import org.infinispan.commons.time.TimeService;
/**
@@ -332,15 +335,22 @@ public interface TestingResource {
@Produces(MediaType.TEXT_HTML_UTF_8)
String getJavascriptTestingEnvironment();
+ @GET
+ @Path("/list-disabled-features")
+ @Produces(MediaType.APPLICATION_JSON)
+ Set listDisabledFeatures();
+
@POST
@Path("/enable-feature/{feature}")
@Consumes(MediaType.APPLICATION_JSON)
- Response enableFeature(@PathParam("feature") String feature);
+ @Produces(MediaType.APPLICATION_JSON)
+ Set enableFeature(@PathParam("feature") String feature);
@POST
@Path("/disable-feature/{feature}")
@Consumes(MediaType.APPLICATION_JSON)
- Response disableFeature(@PathParam("feature") String feature);
+ @Produces(MediaType.APPLICATION_JSON)
+ Set disableFeature(@PathParam("feature") String feature);
/**
* If property-value is null, the system property will be unset (removed) on the server
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoServletsAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoServletsAdapterTest.java
index fd41baa9cd..98baf0f13c 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoServletsAdapterTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/servlet/DemoServletsAdapterTest.java
@@ -879,8 +879,6 @@ public class DemoServletsAdapterTest extends AbstractServletsAdapterTest {
@Test
public void testOIDCUiLocalesParamForwarding() {
- ProfileAssume.assumeCommunity();
-
RealmRepresentation demoRealmRep = testRealmResource().toRepresentation();
boolean enabled = demoRealmRep.isInternationalizationEnabled();
String defaultLocale = demoRealmRep.getDefaultLocale();
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ProvidersTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ProvidersTest.java
index f064b3c243..f6459d05c8 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ProvidersTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ProvidersTest.java
@@ -23,6 +23,7 @@ import org.keycloak.common.Profile;
import org.keycloak.representations.idm.AuthenticatorConfigInfoRepresentation;
import org.keycloak.representations.idm.ConfigPropertyRepresentation;
import org.keycloak.testsuite.Assert;
+import org.keycloak.testsuite.ProfileAssume;
import javax.ws.rs.NotFoundException;
import java.util.ArrayList;
@@ -141,7 +142,7 @@ public class ProvidersTest extends AbstractAuthenticationTest {
"Validates a OTP on a separate OTP form. Only shown if required based on the configured conditions.");
addProviderInfo(result, "auth-cookie", "Cookie", "Validates the SSO cookie set by the auth server.");
addProviderInfo(result, "auth-otp-form", "OTP Form", "Validates a OTP on a separate OTP form.");
- if (Profile.isFeatureEnabled(Profile.Feature.SCRIPTS)) {
+ if (ProfileAssume.isFeatureEnabled(Profile.Feature.SCRIPTS)) {
addProviderInfo(result, "auth-script-based", "Script", "Script based authentication. Allows to define custom authentication logic via JavaScript.");
}
addProviderInfo(result, "auth-spnego", "Kerberos", "Initiates the SPNEGO protocol. Most often used with Kerberos.");
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ScriptBasedAuthenticatorTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ScriptBasedAuthenticatorTest.java
deleted file mode 100644
index 3466928a90..0000000000
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/ScriptBasedAuthenticatorTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.keycloak.testsuite.admin.authentication;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.keycloak.testsuite.ProfileAssume;
-
-import javax.ws.rs.BadRequestException;
-import java.util.HashMap;
-
-/**
- * @author mhajas
- */
-public class ScriptBasedAuthenticatorTest extends AbstractAuthenticationTest {
-
- @Test
- public void checkIfTurnedOffWithProductProfile() throws InterruptedException {
- ProfileAssume.assumePreviewDisabled();
-
- HashMap params = new HashMap<>();
- params.put("newName", "Copy-of-browser");
- authMgmtResource.copy("browser", params);
-
- params.put("provider", "auth-script-based");
- try {
- authMgmtResource.addExecution("Copy-of-browser", params);
- Assert.fail("Adding script based authenticator should fail with product profile");
- } catch (BadRequestException ex) {
- //Expected
- }
- }
-}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java
index 9db51feb27..60fc23eeac 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/SocialLoginTest.java
@@ -604,10 +604,8 @@ public class SocialLoginTest extends AbstractKeycloakTest {
String username = users.get(0).getUsername();
checkFeature(501, username);
- Response tokenResp = testingClient.testing().enableFeature(Profile.Feature.TOKEN_EXCHANGE.toString());
- assertEquals(200, tokenResp.getStatus());
+ testingClient.enableFeature(Profile.Feature.TOKEN_EXCHANGE);
- ProfileAssume.assumeFeatureEnabled(Profile.Feature.TOKEN_EXCHANGE);
Client httpClient = AdminClientUtil.createResteasyClient();
try {
@@ -690,8 +688,7 @@ public class SocialLoginTest extends AbstractKeycloakTest {
adminClient.realm(REALM).identityProviders().get(idp.getAlias()).update(idp);
} finally {
httpClient.close();
- tokenResp = testingClient.testing().disableFeature(Profile.Feature.TOKEN_EXCHANGE.toString());
- assertEquals(200, tokenResp.getStatus());
+ testingClient.disableFeature(Profile.Feature.TOKEN_EXCHANGE);
checkFeature(501, username);
}
}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/crossdc/ActionTokenCrossDCTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/crossdc/ActionTokenCrossDCTest.java
index 73ef39a64a..d74efb3ffd 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/crossdc/ActionTokenCrossDCTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/crossdc/ActionTokenCrossDCTest.java
@@ -16,6 +16,7 @@
*/
package org.keycloak.testsuite.crossdc;
+import org.junit.Ignore;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.common.Profile;
@@ -86,6 +87,10 @@ public class ActionTokenCrossDCTest extends AbstractAdminCrossDCTest {
@Test
@InitialDcState(authServers = ServerSetup.ALL_NODES_IN_FIRST_DC_FIRST_NODE_IN_SECOND_DC)
+ // KEYCLOAK-17584: Temporarily disable the test for 'community' profile till KEYCLOAK-17628 isn't fixed. In other words till:
+ // * The test is either rewritten to start using the new Wildfly subsystem for base metrics introduced in Wildfly 22,
+ // * Or Keycloak is able to load the Eclipse MicroProfile Metrics subsystem from the microprofile Galleon feature-pack
+ @Ignore
public void sendResetPasswordEmailSuccessWorksInCrossDc(
@JmxInfinispanCacheStatistics(dc=DC.FIRST, dcNodeIndex=0, cacheName=InfinispanConnectionProvider.ACTION_TOKEN_CACHE) InfinispanStatistics cacheDc0Node0Statistics,
@JmxInfinispanCacheStatistics(dc=DC.FIRST, dcNodeIndex=1, cacheName=InfinispanConnectionProvider.ACTION_TOKEN_CACHE) InfinispanStatistics cacheDc0Node1Statistics,
@@ -93,11 +98,6 @@ public class ActionTokenCrossDCTest extends AbstractAdminCrossDCTest {
@JmxInfinispanChannelStatistics() InfinispanStatistics channelStatisticsCrossDc) throws Exception {
log.debug("--DC: START sendResetPasswordEmailSuccessWorksInCrossDc");
- // KEYCLOAK-17584: Temporarily disable the test for 'community' profile till KEYCLOAK-17628 isn't fixed. In other words till:
- // * The test is either rewritten to start using the new Wildfly subsystem for base metrics introduced in Wildfly 22,
- // * Or Keycloak is able to load the Eclipse MicroProfile Metrics subsystem from the microprofile Galleon feature-pack
- Assume.assumeTrue("Ignoring test as product profile is not enabled", Profile.getName().equals("product"));
-
cacheDc0Node1Statistics.waitToBecomeAvailable(10, TimeUnit.SECONDS);
Comparable originalNumberOfEntries = cacheDc0Node0Statistics.getSingleStatistics(Constants.STAT_CACHE_NUMBER_OF_ENTRIES_IN_MEMORY);
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/LevelOfAssuranceFlowTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/LevelOfAssuranceFlowTest.java
index 3390363f75..eb50142456 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/LevelOfAssuranceFlowTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/forms/LevelOfAssuranceFlowTest.java
@@ -717,4 +717,4 @@ public class LevelOfAssuranceFlowTest extends AbstractTestRealmKeycloakTest {
Assert.assertEquals(expectedError, errorPage.getError());
events.clear();
}
-}
\ No newline at end of file
+}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/AccountPageTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/AccountPageTest.java
index 0e649fde6e..d7cbc38296 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/AccountPageTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/AccountPageTest.java
@@ -60,8 +60,6 @@ public class AccountPageTest extends AbstractI18NTest {
@Test
public void testLocalizedReferrerLinkContent() {
- ProfileAssume.assumeCommunity();
-
RealmResource testRealm = testRealm();
List foundClients = testRealm.clients().findByClientId("var-named-test-app");
if (foundClients.isEmpty()) {
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/EmailTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/EmailTest.java
index 51a32b7a26..e65da22483 100755
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/EmailTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/EmailTest.java
@@ -97,8 +97,6 @@ public class EmailTest extends AbstractI18NTest {
@Test
public void restPasswordEmailGerman() throws IOException, MessagingException {
- ProfileAssume.assumeCommunity();
-
changeUserLocale("de");
loginPage.open();
@@ -118,8 +116,6 @@ public class EmailTest extends AbstractI18NTest {
//KEYCLOAK-7478
@Test
public void changeLocaleOnInfoPage() throws InterruptedException, IOException, MessagingException {
- ProfileAssume.assumeCommunity();
-
UserResource testUser = ApiUtil.findUserByUsernameId(testRealm(), "login-test");
testUser.executeActionsEmail(Arrays.asList(UserModel.RequiredAction.UPDATE_PASSWORD.toString()));
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/LoginPageTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/LoginPageTest.java
index 591575db99..767940db7f 100755
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/LoginPageTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/LoginPageTest.java
@@ -88,8 +88,6 @@ public class LoginPageTest extends AbstractI18NTest {
@Test
public void languageDropdown() {
- ProfileAssume.assumeCommunity();
-
loginPage.open();
Assert.assertEquals("English", loginPage.getLanguageDropdownText());
@@ -123,8 +121,6 @@ public class LoginPageTest extends AbstractI18NTest {
@Test
public void acceptLanguageHeader() throws IOException {
- ProfileAssume.assumeCommunity();
-
try(CloseableHttpClient httpClient = (CloseableHttpClient) new HttpClientBuilder().build()) {
ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(httpClient);
ResteasyClient client = ((ResteasyClientBuilder) ResteasyClientBuilder.newBuilder()).httpEngine(engine).build();
@@ -156,8 +152,6 @@ public class LoginPageTest extends AbstractI18NTest {
// KEYCLOAK-3887
@Test
public void languageChangeRequiredActions() {
- ProfileAssume.assumeCommunity();
-
UserResource user = ApiUtil.findUserByUsernameId(testRealm(), "test-user@localhost");
UserRepresentation userRep = user.toRepresentation();
userRep.setRequiredActions(Arrays.asList(UserModel.RequiredAction.UPDATE_PASSWORD.toString()));
@@ -183,8 +177,6 @@ public class LoginPageTest extends AbstractI18NTest {
// KEYCLOAK-3887
@Test
public void languageChangeConsentScreen() {
- ProfileAssume.assumeCommunity();
-
// Set client, which requires consent
oauth.clientId("third-party");
@@ -210,8 +202,6 @@ public class LoginPageTest extends AbstractI18NTest {
@Test
public void languageUserUpdates() {
- ProfileAssume.assumeCommunity();
-
loginPage.open();
loginPage.openLanguage("Deutsch");
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/x509/X509BrowserLoginTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/x509/X509BrowserLoginTest.java
index f909e10664..57f78a86ce 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/x509/X509BrowserLoginTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/x509/X509BrowserLoginTest.java
@@ -516,8 +516,6 @@ public class X509BrowserLoginTest extends AbstractX509AuthenticationTest {
// KEYCLOAK-6866
@Test
public void changeLocaleOnX509InfoPage() {
- ProfileAssume.assumeCommunity();
-
AuthenticatorConfigRepresentation cfg = newConfig("x509-browser-config", createLoginSubjectEmail2UsernameOrEmailConfig().getConfig());
String cfgId = createConfig(browserExecution.getId(), cfg);
Assert.assertNotNull(cfgId);
diff --git a/testsuite/model/src/test/java/org/keycloak/testsuite/model/KeycloakModelTest.java b/testsuite/model/src/test/java/org/keycloak/testsuite/model/KeycloakModelTest.java
index c2e3224523..e2f4b8fe4e 100644
--- a/testsuite/model/src/test/java/org/keycloak/testsuite/model/KeycloakModelTest.java
+++ b/testsuite/model/src/test/java/org/keycloak/testsuite/model/KeycloakModelTest.java
@@ -24,6 +24,8 @@ import org.keycloak.authorization.policy.provider.PolicyProviderFactory;
import org.keycloak.authorization.policy.provider.PolicySpi;
import org.keycloak.authorization.store.StoreFactorySpi;
import org.keycloak.cluster.ClusterSpi;
+import org.keycloak.common.Profile;
+import org.keycloak.common.profile.PropertiesProfileConfigResolver;
import org.keycloak.common.util.Time;
import org.keycloak.component.ComponentFactoryProviderFactory;
import org.keycloak.component.ComponentFactorySpi;
@@ -60,6 +62,7 @@ import java.lang.management.LockInfo;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -290,6 +293,13 @@ public abstract class KeycloakModelTest {
LOG.debugf("Creating factory %d in %s using the following configuration:\n %s", factoryIndex, threadName, CONFIG);
DefaultKeycloakSessionFactory res = new DefaultKeycloakSessionFactory() {
+
+ @Override
+ public void init() {
+ Profile.configure(new PropertiesProfileConfigResolver(System.getProperties()));
+ super.init();
+ }
+
@Override
protected boolean isEnabled(ProviderFactory factory, Scope scope) {
return super.isEnabled(factory, scope) && isFactoryAllowed(factory);
diff --git a/testsuite/utils/src/main/java/org/keycloak/testsuite/TestPlatform.java b/testsuite/utils/src/main/java/org/keycloak/testsuite/TestPlatform.java
index 544b13f853..81d034f5fc 100644
--- a/testsuite/utils/src/main/java/org/keycloak/testsuite/TestPlatform.java
+++ b/testsuite/utils/src/main/java/org/keycloak/testsuite/TestPlatform.java
@@ -23,6 +23,9 @@ import java.nio.file.Files;
import org.jboss.logging.Logger;
import org.keycloak.Config;
+import org.keycloak.common.Profile;
+import org.keycloak.common.profile.PropertiesFileProfileConfigResolver;
+import org.keycloak.common.profile.PropertiesProfileConfigResolver;
import org.keycloak.platform.PlatformProvider;
public class TestPlatform implements PlatformProvider {
@@ -31,6 +34,13 @@ public class TestPlatform implements PlatformProvider {
private File tmpDir;
+ public TestPlatform() {
+ Profile.configure(
+ new PropertiesProfileConfigResolver(System.getProperties()),
+ new PropertiesFileProfileConfigResolver()
+ );
+ }
+
@Override
public void onStartup(Runnable startupHook) {
startupHook.run();