Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Handle warning when all realms are disabled #70392

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ public void testUnlicensedWithNonStandardRealms() throws Exception {
assertThat(realm.name(), equalTo("foo"));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/70378")
public void testDisabledRealmsAreNotAdded() throws Exception {
Settings.Builder builder = Settings.builder()
.put("path.home", createTempDir());
Expand All @@ -504,9 +503,11 @@ public void testDisabledRealmsAreNotAdded() throws Exception {
}
Collections.shuffle(orders, random());
Map<Integer, Integer> orderToIndex = new HashMap<>();
boolean anyEnabled = false;
for (int i = 0; i < randomRealmTypesCount; i++) {
builder.put("xpack.security.authc.realms.type_" + i + ".realm_" + i + ".order", orders.get(i));
boolean enabled = randomBoolean();
anyEnabled = anyEnabled || enabled;
builder.put("xpack.security.authc.realms.type_" + i + ".realm_" + i + ".enabled", enabled);
if (enabled) {
orderToIndex.put(orders.get(i), i);
Expand All @@ -516,6 +517,11 @@ public void testDisabledRealmsAreNotAdded() throws Exception {
Settings settings = builder.build();
Environment env = TestEnvironment.newEnvironment(settings);
Realms realms = new Realms(settings, env, factories, licenseState, threadContext, reservedRealm);
if (false == anyEnabled) {
assertWarnings("Found explicitly disabled basic realms: [file,native]. " +
"But they will be enabled because no other realms are configured or enabled. " +
"In next major release, explicitly disabled basic realms will remain disabled.");
}
Iterator<Realm> iterator = realms.iterator();
Realm realm = iterator.next();
assertThat(realm, is(reservedRealm));
Expand Down