From a74d6756c031929a69388b7390b34108ed13ea37 Mon Sep 17 00:00:00 2001 From: Jani Averbach Date: Mon, 31 Mar 2014 00:53:21 +0300 Subject: [PATCH] LDAP: Added test for binding without special account (e.g. userbased bind) --- .../com/gitblit/tests/LdapAuthenticationTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java b/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java index b037754c..21063d58 100644 --- a/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java +++ b/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java @@ -258,6 +258,19 @@ public class LdapAuthenticationTest extends GitblitUnitTest { assertNull(userThreeModel.getTeam("git_admins")); assertTrue(userThreeModel.canAdmin); } + + @Test + public void testBindWithUser() { + settings.put(Keys.realm.ldap.bindpattern, "CN=${username},OU=US,OU=Users,OU=UserControl,OU=MyOrganization,DC=MyDomain"); + settings.put(Keys.realm.ldap.username, ""); + settings.put(Keys.realm.ldap.password, ""); + + UserModel userOneModel = auth.authenticate("UserOne", "userOnePassword".toCharArray()); + assertNotNull(userOneModel); + + UserModel userOneModelFailedAuth = auth.authenticate("UserOne", "userTwoPassword".toCharArray()); + assertNull(userOneModelFailedAuth); + } private int countLdapUsersInUserManager() { int ldapAccountCount = 0; -- 2.39.5