-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes multiple Active Directory related tests that run against the samba fixture. Some were failing since we changed the realm settings format in 7.0 and a few were slightly broken in other ways. We can move to cleanup the tests in a follow up but this work fits better to be done with or after we move the tests from a Samba based fixture to a real(-ish) Microsoft Active Directory based fixture. Resolves: #33425, #35738
- Loading branch information
Showing
11 changed files
with
129 additions
and
170 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/samba4.crt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDoDCCAoigAwIBAgIUMVGoHuyNTjTFaoRmqFELz75jzDEwDQYJKoZIhvcNAQEL | ||
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l | ||
cmF0ZWQgQ0EwHhcNMTgwMjE1MTc0OTExWhcNMjEwMjE0MTc0OTExWjARMQ8wDQYD | ||
VQQDEwZzYW1iYTQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtGBwa | ||
n+7JN2vweSUsYh4zPmh8RPIE+nEVjK1lx/rADUBY7UVjfTYC+MVKKiezZe7gYCNT | ||
7JNKazPpgVI9e3ZFKw/UxomLqRuuvn5bTh+1tMs3afY5+GGzi7oPmEbBO3ceg0Hi | ||
rNSTDa1rfroZnRYK8uIeSZacQnAW90plITI7rBBt9jq+W9albFbDybfDgNv+yS/C | ||
rzIsofm4rbFC3SMRYfrT6HvwDhjOmmYKZci5x7tsn0T+3tSiR44Bw5/DgiN5kX3m | ||
/kl9qg1eoYWbCUy1dKmQlb4Nb4uNcxrIugLB3zjBkfhMZ0OHoveKh/lJASTWik9k | ||
xQ9rEYbpsRbuXpsHAgMBAAGjgcwwgckwHQYDVR0OBBYEFJOLa7UXKtLPibgKeFh7 | ||
Kq1+rS0/MG8GA1UdIwRoMGaAFGaNmN5mi9jaMW25MEWYgt+5OkDBoTikNjA0MTIw | ||
MAYDVQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBD | ||
QYIUdwsnIxjgSneHNVKT6JNCCsrQ3T0wLAYDVR0RBCUwI4IJbG9jYWxob3N0hwR/ | ||
AAABhxAAAAAAAAAAAAAAAAAAAAABMAkGA1UdEwQCMAAwDQYJKoZIhvcNAQELBQAD | ||
ggEBAEHqT1WHkcF8DuOgyIBx7wKcUVQ5H1qYYlJ1xgMGrKFFZLUzouLcON7oadEu | ||
HLIJ4Z3AKD3bqWpcls5XJ9MTECGR48tou67x9cXqTV7jR3Rh0H/VGwzwhR85vbpu | ||
o8ielOPL8XAQOfnAFESJii5sfCU4ZwLg+3evmGZdKfhU6rqQtLimgG/Gm96vOJne | ||
y0a/TZTWrfAarithkOHHXSSAhEI5SdW5SlZAytF4AmYqFvafwxe1+NyFwfCRy0Xl | ||
H40WgVsq+z84psU+WyORb3THX5rgB4au9nuMXOqFKAtrJSI/uApncYraaqU28rqB | ||
gYd8XrtjhKOLw+6viqAKu8l7/cs= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
package org.elasticsearch.xpack.security.authc.ldap; | ||
|
||
import org.elasticsearch.action.support.PlainActionFuture; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
|
@@ -15,10 +14,8 @@ | |
import org.elasticsearch.threadpool.TestThreadPool; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.xpack.core.security.authc.RealmConfig; | ||
import org.elasticsearch.xpack.core.security.authc.ldap.support.LdapSearchScope; | ||
import org.elasticsearch.xpack.core.ssl.SSLService; | ||
import org.elasticsearch.xpack.security.authc.ldap.support.LdapSession; | ||
import org.elasticsearch.xpack.security.authc.ldap.support.LdapTestCase; | ||
import org.elasticsearch.xpack.security.authc.ldap.support.SessionFactory; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
|
@@ -49,7 +46,7 @@ public void init() throws Exception { | |
|
||
globalSettings = Settings.builder() | ||
.put("path.home", createTempDir()) | ||
.put("xpack.security.authc.realms.active_directory.ad.ssl.certificate_authorities", certPath) | ||
.put("xpack.security.authc.realms.ldap.ad-as-ldap-test.ssl.certificate_authorities", certPath) | ||
.build(); | ||
sslService = new SSLService(globalSettings, env); | ||
threadPool = new TestThreadPool("ADLdapUserSearchSessionFactoryTests"); | ||
|
@@ -60,15 +57,12 @@ public void shutdown() { | |
terminate(threadPool); | ||
} | ||
|
||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35738") | ||
public void testUserSearchWithActiveDirectory() throws Exception { | ||
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com"; | ||
String userSearchBase = "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com"; | ||
Settings settings = Settings.builder() | ||
.put(LdapTestCase.buildLdapSettings( | ||
new String[] { ActiveDirectorySessionFactoryTests.AD_LDAP_URL }, | ||
Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE, null, | ||
true)) | ||
.put("url", ActiveDirectorySessionFactoryTests.AD_LDAP_URL) | ||
.put("group_search.base_dn", groupSearchBase) | ||
.put("user_search.base_dn", userSearchBase) | ||
.put("bind_dn", "[email protected]") | ||
.put("bind_password", ActiveDirectorySessionFactoryTests.PASSWORD) | ||
|
@@ -79,13 +73,13 @@ public void testUserSearchWithActiveDirectory() throws Exception { | |
Settings.Builder builder = Settings.builder() | ||
.put(globalSettings); | ||
settings.keySet().forEach(k -> { | ||
builder.copy("xpack.security.authc.realms.ad-as-ldap-test." + k, k, settings); | ||
builder.copy("xpack.security.authc.realms.ldap.ad-as-ldap-test." + k, k, settings); | ||
|
||
}); | ||
Settings fullSettings = builder.build(); | ||
sslService = new SSLService(fullSettings, TestEnvironment.newEnvironment(fullSettings)); | ||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("ad", "ad-as-ldap-test"), globalSettings, | ||
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)); | ||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", "ad-as-ldap-test"), fullSettings, | ||
TestEnvironment.newEnvironment(fullSettings), new ThreadContext(fullSettings)); | ||
LdapUserSearchSessionFactory sessionFactory = getLdapUserSearchSessionFactory(config, sslService, threadPool); | ||
|
||
String user = "Bruce Banner"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.