summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAlfred Schmid <A.Schmid@ff-muenchen.de>2014-02-03 10:01:04 +0100
committerJames Moger <james.moger@gitblit.com>2014-02-19 11:04:16 -0500
commitf6d7de15b1471b1c101362dbaf598de8031e6540 (patch)
treef07d4635d35c97c2525ef48f8bb0d02435c9c976 /src/test
parentedae533cd47384c155485af74ef968453de69b9e (diff)
downloadgitblit-f6d7de15b1471b1c101362dbaf598de8031e6540.tar.gz
gitblit-f6d7de15b1471b1c101362dbaf598de8031e6540.zip
Load empty groups as empty teams from ldap, when ldap user
synchronization is enabled.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/gitblit/tests/LdapAuthenticationTest.java28
-rw-r--r--src/test/resources/ldap/addgroup.ldif5
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java b/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java
index ce3615e0..670dde00 100644
--- a/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java
+++ b/src/test/java/com/gitblit/tests/LdapAuthenticationTest.java
@@ -34,6 +34,7 @@ import com.gitblit.auth.LdapAuthProvider;
import com.gitblit.manager.IUserManager;
import com.gitblit.manager.RuntimeManager;
import com.gitblit.manager.UserManager;
+import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
import com.gitblit.tests.mock.MemorySettings;
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
@@ -208,6 +209,23 @@ public class LdapAuthenticationTest extends GitblitUnitTest {
assertEquals("Number of ldap users in gitblit user model", 6, countLdapUsersInUserManager());
}
+ @Test
+ public void addingGroupsInLdapShouldNotUpdateGitBlitUsersAndGroups() throws Exception {
+ settings.put("realm.ldap.ldapCachePeriod", "0 MINUTES");
+ ds.addEntries(LDIFReader.readEntries(RESOURCE_DIR + "addgroup.ldif"));
+ ldap.synchronizeWithLdapService();
+ assertEquals("Number of ldap groups in gitblit team model", 0, countLdapTeamsInUserManager());
+ }
+
+ @Test
+ public void addingGroupsInLdapShouldUpdateGitBlitUsersAndGroups() throws Exception {
+ settings.put("realm.ldap.synchronizeUsers.enable", "true");
+ settings.put("realm.ldap.ldapCachePeriod", "0 MINUTES");
+ ds.addEntries(LDIFReader.readEntries(RESOURCE_DIR + "addgroup.ldif"));
+ ldap.synchronizeWithLdapService();
+ assertEquals("Number of ldap groups in gitblit team model", 1, countLdapTeamsInUserManager());
+ }
+
private int countLdapUsersInUserManager() {
int ldapAccountCount = 0;
for (UserModel userModel : userManager.getAllUsers()) {
@@ -218,4 +236,14 @@ public class LdapAuthenticationTest extends GitblitUnitTest {
return ldapAccountCount;
}
+ private int countLdapTeamsInUserManager() {
+ int ldapAccountCount = 0;
+ for (TeamModel teamModel : userManager.getAllTeams()) {
+ if (AccountType.LDAP.equals(teamModel.accountType)) {
+ ldapAccountCount++;
+ }
+ }
+ return ldapAccountCount;
+ }
+
}
diff --git a/src/test/resources/ldap/addgroup.ldif b/src/test/resources/ldap/addgroup.ldif
new file mode 100644
index 00000000..665df31b
--- /dev/null
+++ b/src/test/resources/ldap/addgroup.ldif
@@ -0,0 +1,5 @@
+dn: CN=Git_Group_Without_Members,OU=Groups,OU=UserControl,OU=MyOrganization,DC=MyDomain
+objectClass: top
+objectClass: group
+cn: Git_Group_Without_Members
+sAMAccountName: Git_Group_Without_Members