Fix configuration for disabled features throwing errors with disabled dependencies (#17323)
Closes #17322
This commit is contained in:
parent
1e4401f521
commit
b4050b9fa8
2 changed files with 11 additions and 1 deletions
|
@ -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());
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue