From cac922974d64257665a10ad2909e4e38d86de42b Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 18 Feb 2015 18:20:59 -0500 Subject: [PATCH] [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@f37fb912e876a2aac131466a55f0344ac1b85e13 --- .../activedirectory/ActiveDirectorySessionFactoryTests.java | 2 ++ .../org/elasticsearch/shield/authc/ldap/OpenLdapTests.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectorySessionFactoryTests.java b/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectorySessionFactoryTests.java index 0b0879ea6d6..cab96e95b6d 100644 --- a/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectorySessionFactoryTests.java +++ b/src/test/java/org/elasticsearch/shield/authc/activedirectory/ActiveDirectorySessionFactoryTests.java @@ -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")); diff --git a/src/test/java/org/elasticsearch/shield/authc/ldap/OpenLdapTests.java b/src/test/java/org/elasticsearch/shield/authc/ldap/OpenLdapTests.java index 1b20315aac0..4373150a005 100644 --- a/src/test/java/org/elasticsearch/shield/authc/ldap/OpenLdapTests.java +++ b/src/test/java/org/elasticsearch/shield/authc/ldap/OpenLdapTests.java @@ -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"));