Return Timeout Error Code for timeout during LDAP operations. With test
and special test conf.
Change-Id: Id661ea7df66fdef317934b416ffe58d8c9b9f30f
diff --git a/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java b/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
index 0580bba..dfdeb1c 100644
--- a/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
+++ b/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
@@ -25,6 +25,8 @@
public static final String TEST_LDAPS_CONF = "src/test/resources/test-ldaps.conf";
+ public static final String TEST_LDAP_TIMEOUT_CONF = "src/test/resources/test-ldap-timeout.conf";
+
public static final String TEST_LDAPS_TS_CONF = "src/test/resources/test-ldaps-with-truststore.conf";
public static final String TEST_LDAP_USERS_LDIF = "src/test/resources/test-ldap-users.ldif";
@@ -69,6 +71,17 @@
}
@Test
+ public void loginWithTimeout () throws LDAPException
+ {
+ // To trigger a timeout inside login(), we load TEST_LDAP_TIMEOUT_CONF which:
+ // - sets a timeout for LDAP operations to the lowest value possible = 1ms;
+ // - sets the host to be on the network, not localhost, to obtain a response time > 1ms.
+
+ assertEquals(LDAP_AUTH_RTIMEOUT,
+ LdapAuth3.login("testuser123", "password", TEST_LDAP_TIMEOUT_CONF));
+ }
+
+ @Test
public void loginWithExtraProfileNameWorks () throws LDAPException {
assertEquals(LDAP_AUTH_ROK,
LdapAuth3.login("testuser123", "password", TEST_LDAP_CONF));
diff --git a/src/test/resources/test-ldap-timeout.conf b/src/test/resources/test-ldap-timeout.conf
new file mode 100644
index 0000000..9fa23c6
--- /dev/null
+++ b/src/test/resources/test-ldap-timeout.conf
@@ -0,0 +1,9 @@
+host=korap.ids-mannheim.de
+port=3268
+searchBase=dc=example,dc=com
+sLoginDN=cn=admin,dc=example,dc=com
+pwd=adminpassword
+searchFilter=(&(|(uid=${login})(mail=${login})(extraProfile=${login}))(|(userPassword=${password})(extraPassword=${password})))
+authFilter=(registered=TRUE)
+userNotBlockedFilter=(|(userStatus=0)(userStatus=1)(!(userStatus=*)))
+ldapTimeout=1