[Test] add a ldap search to the tcp timeout tests
If tests are run on the same machine as the ldap server a bind may be succesfull. This adds a search to the test which should take longer than 1 millisecond for the server to respond. Original commit: elastic/x-pack-elasticsearch@f37fb912e8
This commit is contained in:
parent
52a2dd4acf
commit
cac922974d
|
@ -84,6 +84,8 @@ public class ActiveDirectorySessionFactoryTests extends ElasticsearchTestCase {
|
|||
ActiveDirectorySessionFactory sessionFactory = new ActiveDirectorySessionFactory(config, clientSSLService);
|
||||
|
||||
try (LdapSession ldap = sessionFactory.open("ironman", SecuredStringTests.build(PASSWORD))) {
|
||||
// In certain cases we may have a successful bind, but a search should take longer and cause a timeout
|
||||
ldap.groups();
|
||||
fail("The TCP connection should timeout before getting groups back");
|
||||
} catch (ActiveDirectoryException e) {
|
||||
assertThat(e.getCause().getMessage(), containsString("A client-side timeout was encountered while waiting"));
|
||||
|
|
|
@ -110,7 +110,9 @@ public class OpenLdapTests extends ElasticsearchTestCase {
|
|||
RealmConfig config = new RealmConfig("oldap-test", settings);
|
||||
LdapSessionFactory sessionFactory = new LdapSessionFactory(config, clientSSLService);
|
||||
|
||||
try (LdapSession ldap = sessionFactory.open("thor", SecuredStringTests.build(PASSWORD))){
|
||||
try (LdapSession ldap = sessionFactory.open("thor", SecuredStringTests.build(PASSWORD))) {
|
||||
// In certain cases we may have a successful bind, but a search should take longer and cause a timeout
|
||||
ldap.groups();
|
||||
fail("The TCP connection should timeout before getting groups back");
|
||||
} catch (ShieldLdapException e) {
|
||||
assertThat(e.getCause().getMessage(), containsString("A client-side timeout was encountered while waiting"));
|
||||
|
|
Loading…
Reference in New Issue