LdapAuth3: Test all combinations of 3 alternative login names and 2 pws
Change-Id: Ie8f6f2fc0d180ac894e2c22e6d40531d9269608e
diff --git a/full/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java b/full/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
index 6f3edc4..48d5c88 100644
--- a/full/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
+++ b/full/src/test/java/de/ids_mannheim/korap/authentication/LdapAuth3Test.java
@@ -78,6 +78,16 @@
}
@Test
+ public void testAllLoginPwCombinations() throws LDAPException {
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("uid", "userPassword", TEST_LDAP_CONF));
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("uid", "extraPassword", TEST_LDAP_CONF));
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("mail@example.org", "userPassword", TEST_LDAP_CONF));
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("mail@example.org", "extraPassword", TEST_LDAP_CONF));
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("extraProfile", "userPassword", TEST_LDAP_CONF));
+ assertEquals(LDAP_AUTH_ROK, LdapAuth3.login("extraProfile", "extraPassword", TEST_LDAP_CONF));
+ }
+
+ @Test
public void testFailingLoginWithWrongEmail() throws LDAPException {
assertEquals(LDAP_AUTH_RNAUTH, LdapAuth3.login("notestuser@example.com", "topsecret", TEST_LDAP_CONF));
}
diff --git a/full/src/test/resources/test-ldap-users.ldif b/full/src/test/resources/test-ldap-users.ldif
index 9a143f4..af687a8 100644
--- a/full/src/test/resources/test-ldap-users.ldif
+++ b/full/src/test/resources/test-ldap-users.ldif
@@ -15,10 +15,10 @@
mail: testuser@example.com
userPassword: cGFzc3dvcmQ=
displayName: Dr. Peter Testuser
-idsC2: TRUE
-idsC2Profile: testuser
-idsC2Password: topsecret
-idsC2News: TRUE
+extra: TRUE
+extraProfile: testuser
+extraPassword: topsecret
+extraNews: TRUE
title: Herr
uid: testuser
@@ -29,10 +29,10 @@
mail: test@example.com
userPassword: top*ecret
displayName: Dr. Peter Test
-idsC2: TRUE
+extra: TRUE
idsStatus: 1
-idsC2Profile: test
-idsC2Password: top*ecret
+extraProfile: test
+extraPassword: top*ecret
uid: test
dn: uid=doe,ou=people,dc=example,dc=com
@@ -43,10 +43,10 @@
userPassword: cGFzc3dvcmQ=
displayName: Dr. John Doe
idsStatus: 0
-idsC2: FALSE
-idsC2Profile: doe
-idsC2Password: topsecret
-idsC2News: TRUE
+extra: FALSE
+extraProfile: doe
+extraPassword: topsecret
+extraNews: TRUE
title: Herr
uid: doe
@@ -58,10 +58,10 @@
userPassword: cGFzc3dvcmQ=
displayName: berserk
idsStatus: 2
-idsC2: TRUE
-idsC2Profile: doe
-idsC2Password: topsecret
-idsC2News: TRUE
+extra: TRUE
+extraProfile: doe
+extraPassword: topsecret
+extraNews: TRUE
title: Herr
uid: berserk
@@ -73,9 +73,17 @@
userPassword: cGFzc3dvcmQ=
displayName: Dr. Peter Testuser
idsStatus: 0
-idsC2: TRUE
-idsC2Profile: testuser2
-idsC2Password: topsecret
-idsC2News: TRUE
+extra: TRUE
+extraProfile: testuser2
+extraPassword: topsecret
+extraNews: TRUE
title: Herr
uid: testuser2
+
+dn: uid=uid,ou=people,dc=example,dc=com
+mail: mail@example.org
+userPassword: userPassword
+extra: TRUE
+extraProfile: extraProfile
+extraPassword: extraPassword
+uid: uid
diff --git a/full/src/test/resources/test-ldap.conf b/full/src/test/resources/test-ldap.conf
index eb97168..1bccb3b 100644
--- a/full/src/test/resources/test-ldap.conf
+++ b/full/src/test/resources/test-ldap.conf
@@ -3,4 +3,4 @@
searchBase=dc=example,dc=com
sLoginDN=cn=admin,dc=example,dc=com
pwd=adminpassword
-searchFilter=(&(|(&(|(uid=${login})(mail=${login}))(userPassword=${password}))(&(idsC2Profile=${login})(idsC2Password=${password})))(&(idsC2=TRUE)(|(idsStatus=1)(|(idsStatus=0)(!(idsStatus=*))))))
+searchFilter=(&(|(uid=${login})(mail=${login})(extraProfile=${login}))(|(userPassword=${password})(extraPassword=${password}))(extra=TRUE)(|(idsStatus=0)(idsStatus=1)(!(idsStatus=*))))
diff --git a/full/src/test/resources/test-ldaps-with-truststore.conf b/full/src/test/resources/test-ldaps-with-truststore.conf
index 0e58b65..788de73 100644
--- a/full/src/test/resources/test-ldaps-with-truststore.conf
+++ b/full/src/test/resources/test-ldaps-with-truststore.conf
@@ -5,4 +5,4 @@
searchBase=dc=example,dc=com
sLoginDN=cn=admin,dc=example,dc=com
pwd=adminpassword
-searchFilter=(&(|(&(|(uid=${login})(mail=${login}))(userPassword=${password}))(&(idsC2Profile=${login})(idsC2Password=${password})))(&(idsC2=TRUE)(|(idsStatus=1)(|(idsStatus=0)(!(idsStatus=*))))))
+searchFilter=(&(|(uid=${login})(mail=${login})(extraProfile=${login}))(|(userPassword=${password})(extraPassword=${password}))(extra=TRUE)(|(idsStatus=0)(idsStatus=1)(!(idsStatus=*))))
diff --git a/full/src/test/resources/test-ldaps.conf b/full/src/test/resources/test-ldaps.conf
index 2189432..9b414be 100644
--- a/full/src/test/resources/test-ldaps.conf
+++ b/full/src/test/resources/test-ldaps.conf
@@ -5,4 +5,4 @@
searchBase=dc=example,dc=com
sLoginDN=cn=admin,dc=example,dc=com
pwd=adminpassword
-searchFilter=(&(|(&(|(uid=${login})(mail=${login}))(userPassword=${password}))(&(idsC2Profile=${login})(idsC2Password=${password})))(&(idsC2=TRUE)(|(idsStatus=1)(|(idsStatus=0)(!(idsStatus=*))))))
+searchFilter=(&(|(uid=${login})(mail=${login})(extraProfile=${login}))(|(userPassword=${password})(extraPassword=${password}))(extra=TRUE)(|(idsStatus=0)(idsStatus=1)(!(idsStatus=*))))