Fix configuration for disabled features throwing errors with disabled dependencies (#17323)

Closes #17322
This commit is contained in:
Cameron James 2023-03-02 18:29:08 +10:00 committed by GitHub
parent 1e4401f521
commit b4050b9fa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -254,7 +254,7 @@ public class Profile {
private static void verifyConfig(Map<Feature, Boolean> features) { private static void verifyConfig(Map<Feature, Boolean> features) {
for (Feature f : features.keySet()) { for (Feature f : features.keySet()) {
if (f.getDependencies() != null) { if (features.get(f) && f.getDependencies() != null) {
for (Feature d : f.getDependencies()) { for (Feature d : f.getDependencies()) {
if (!features.get(d)) { if (!features.get(d)) {
throw new ProfileException("Feature " + f.getKey() + " depends on disabled feature " + d.getKey()); throw new ProfileException("Feature " + f.getKey() + " depends on disabled feature " + d.getKey());

View file

@ -91,6 +91,16 @@ public class ProfileTest {
} }
} }
@Test
public void checkSuccessIfFeatureDisabledWithDisabledDependencies() {
Properties properties = new Properties();
properties.setProperty("keycloak.profile.feature.account2", "disabled");
properties.setProperty("keycloak.profile.feature.account_api", "disabled");
Profile.configure(new PropertiesProfileConfigResolver(properties));
Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2));
Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_API));
}
@Test @Test
public void checkErrorOnBadConfig() { public void checkErrorOnBadConfig() {
Properties properties = new Properties(); Properties properties = new Properties();