*/\r
package com.gitblit.tests;\r
\r
+import com.gitblit.Constants;\r
+import com.gitblit.models.RegistrantAccessPermission;\r
+import com.gitblit.models.TeamModel;\r
import org.junit.Test;\r
\r
import com.gitblit.models.UserModel;\r
\r
+import java.util.List;\r
+\r
/**\r
* @author Alfred Schmid\r
*\r
assertEquals("When displayName is not empty its value has to be returnd from getDisplayName().", displayName, userModel.getDisplayName());\r
}\r
\r
+\r
+ @Test\r
+ public void getRepositoryPermissionsMultipleTeams()\r
+ {\r
+\r
+ TeamModel aTeam = new TeamModel("A team");\r
+ aTeam.addRepositoryPermission("RW+:acerepo.git");\r
+ aTeam.addRepositoryPermission("V:boobrepo.git");\r
+\r
+ TeamModel bTeam = new TeamModel("Team B");\r
+ bTeam.addRepositoryPermission("R:acerepo.git");\r
+ bTeam.addRepositoryPermission("RWC:boobrepo.git");\r
+\r
+ UserModel user = new UserModel("tessiur");\r
+ user.teams.add(aTeam);\r
+ user.teams.add(bTeam);\r
+ user.addRepositoryPermission("RW+:myrepo.git");\r
+\r
+ List<RegistrantAccessPermission> repoPerms = user.getRepositoryPermissions();\r
+ int found = 0;\r
+ for (RegistrantAccessPermission p : repoPerms) {\r
+ switch (p.registrant) {\r
+ case "acerepo.git":\r
+ assertEquals("Expected REWIND(RW+) permission for " + p.registrant, Constants.AccessPermission.REWIND, p.permission);\r
+ found++;\r
+ break;\r
+ case "boobrepo.git":\r
+ assertEquals("Expected CREATE(RWC) permission for " + p.registrant, Constants.AccessPermission.CREATE, p.permission);\r
+ found++;\r
+ break;\r
+ case "myrepo.git":\r
+ assertEquals("Expected REWIND(RW+) permission for " + p.registrant, Constants.AccessPermission.REWIND, p.permission);\r
+ found++;\r
+ break;\r
+ default:\r
+ fail("Unknown repository registrant " + p.registrant);\r
+ break;\r
+ }\r
+ }\r
+\r
+ assertEquals("Repostory permissions missing in list.", 3, found);\r
+\r
+ }\r
+\r
}\r