From 70898c1167c84a5dd782a20cf5f0eaedae26add3 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Tue, 16 Mar 2021 00:41:17 +1100 Subject: [PATCH] [Tests] Handle warning when all realms are disabled --- .../elasticsearch/xpack/security/authc/RealmsTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java index bdd08594574f7..97c6e1af689b3 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/RealmsTests.java @@ -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()); @@ -504,9 +503,11 @@ public void testDisabledRealmsAreNotAdded() throws Exception { } Collections.shuffle(orders, random()); Map 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); @@ -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 iterator = realms.iterator(); Realm realm = iterator.next(); assertThat(realm, is(reservedRealm));