Skip to content

Commit edbea73

Browse files
committed
Fix broken OpenLDAP Vagrant QA test
This was broken due to c662565 but the problem didn't get detected as CI builds typically don't run vagrant tests
1 parent b65c586 commit edbea73

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/ldap/LdapTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static LDAPConnection openConnection(String url, String bindDN, String bi
6262

6363
final SSLConfiguration sslConfiguration;
6464
if (useGlobalSSL) {
65-
sslConfiguration = sslService.getSSLConfiguration("_global");
65+
sslConfiguration = sslService.getSSLConfiguration("xpack.ssl");
6666
} else {
6767
sslConfiguration = sslService.getSSLConfiguration("xpack.security.authc.realms.foo.ssl");
6868
}

x-pack/qa/openldap-tests/src/test/java/org/elasticsearch/test/OpenLdapTests.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public void initializeSslSocketFactory() throws Exception {
104104
builder.put("xpack.security.authc.realms." + REALM_NAME + ".ssl.truststore.path", truststore);
105105
mockSecureSettings.setString("xpack.security.authc.realms." + REALM_NAME + ".ssl.truststore.secure_password", "changeit");
106106
builder.put("xpack.security.authc.realms." + REALM_NAME + ".ssl.verification_mode", VerificationMode.CERTIFICATE);
107+
108+
// If not using global ssl, need to set the truststore for the "full verification" realm
109+
builder.put("xpack.security.authc.realms.vmode_full.ssl.truststore.path", truststore);
110+
mockSecureSettings.setString("xpack.security.authc.realms.vmode_full.ssl.truststore.secure_password", "changeit");
107111
}
112+
builder.put("xpack.security.authc.realms.vmode_full.ssl.verification_mode", VerificationMode.FULL);
113+
108114
globalSettings = builder.setSecureSettings(mockSecureSettings).build();
109115
Environment environment = TestEnvironment.newEnvironment(globalSettings);
110116
sslService = new SSLService(globalSettings, environment);
@@ -188,10 +194,10 @@ public void testStandardLdapConnectionHostnameVerificationFailure() throws Excep
188194
Settings settings = Settings.builder()
189195
// The certificate used in the vagrant box is valid for "localhost", but not for "127.0.0.1"
190196
.put(buildLdapSettings(OPEN_LDAP_IP_URL, userTemplate, groupSearchBase, LdapSearchScope.ONE_LEVEL))
191-
.put("ssl.verification_mode", VerificationMode.FULL)
192197
.build();
193198

194-
RealmConfig config = new RealmConfig("oldap-test", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings),
199+
// Pick up the "full" verification mode config
200+
RealmConfig config = new RealmConfig("vmode_full", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings),
195201
new ThreadContext(Settings.EMPTY));
196202
LdapSessionFactory sessionFactory = new LdapSessionFactory(config, sslService, threadPool);
197203

@@ -211,10 +217,10 @@ public void testStandardLdapConnectionHostnameVerificationSuccess() throws Excep
211217
Settings settings = Settings.builder()
212218
// The certificate used in the vagrant box is valid for "localhost" (but not for "127.0.0.1")
213219
.put(buildLdapSettings(OPEN_LDAP_DNS_URL, userTemplate, groupSearchBase, LdapSearchScope.ONE_LEVEL))
214-
.put("ssl.verification_mode", VerificationMode.FULL)
215220
.build();
216221

217-
RealmConfig config = new RealmConfig("oldap-test", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings),
222+
// Pick up the "full" verification mode config
223+
RealmConfig config = new RealmConfig("vmode_full", settings, globalSettings, TestEnvironment.newEnvironment(globalSettings),
218224
new ThreadContext(Settings.EMPTY));
219225
LdapSessionFactory sessionFactory = new LdapSessionFactory(config, sslService, threadPool);
220226

0 commit comments

Comments
 (0)