summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorFlorian Zschocke <f.zschocke+git@gmail.com>2022-08-07 14:09:27 +0200
committerFlorian Zschocke <f.zschocke+git@gmail.com>2022-08-07 14:09:27 +0200
commitbf5aa7f42e22547e3ea95ece0b142ac6c9282e52 (patch)
treed724494c6ebf88103aa6a204e0ab987e7c8bd8d6 /src/test/java
parentea9526d456219a063296ddce2f29c9de802ffa8c (diff)
downloadgitblit-bf5aa7f42e22547e3ea95ece0b142ac6c9282e52.tar.gz
gitblit-bf5aa7f42e22547e3ea95ece0b142ac6c9282e52.zip
Add init test for getting repository permissions
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/gitblit/tests/UserModelTest.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/test/java/com/gitblit/tests/UserModelTest.java b/src/test/java/com/gitblit/tests/UserModelTest.java
index 0de02d57..699de213 100644
--- a/src/test/java/com/gitblit/tests/UserModelTest.java
+++ b/src/test/java/com/gitblit/tests/UserModelTest.java
@@ -15,10 +15,15 @@
*/
package com.gitblit.tests;
+import com.gitblit.Constants;
+import com.gitblit.models.RegistrantAccessPermission;
+import com.gitblit.models.TeamModel;
import org.junit.Test;
import com.gitblit.models.UserModel;
+import java.util.List;
+
/**
* @author Alfred Schmid
*
@@ -49,4 +54,48 @@ public class UserModelTest extends GitblitUnitTest {
assertEquals("When displayName is not empty its value has to be returnd from getDisplayName().", displayName, userModel.getDisplayName());
}
+
+ @Test
+ public void getRepositoryPermissionsMultipleTeams()
+ {
+
+ TeamModel aTeam = new TeamModel("A team");
+ aTeam.addRepositoryPermission("RW+:acerepo.git");
+ aTeam.addRepositoryPermission("V:boobrepo.git");
+
+ TeamModel bTeam = new TeamModel("Team B");
+ bTeam.addRepositoryPermission("R:acerepo.git");
+ bTeam.addRepositoryPermission("RWC:boobrepo.git");
+
+ UserModel user = new UserModel("tessiur");
+ user.teams.add(aTeam);
+ user.teams.add(bTeam);
+ user.addRepositoryPermission("RW+:myrepo.git");
+
+ List<RegistrantAccessPermission> repoPerms = user.getRepositoryPermissions();
+ int found = 0;
+ for (RegistrantAccessPermission p : repoPerms) {
+ switch (p.registrant) {
+ case "acerepo.git":
+ assertEquals("Expected REWIND(RW+) permission for " + p.registrant, Constants.AccessPermission.REWIND, p.permission);
+ found++;
+ break;
+ case "boobrepo.git":
+ assertEquals("Expected CREATE(RWC) permission for " + p.registrant, Constants.AccessPermission.CREATE, p.permission);
+ found++;
+ break;
+ case "myrepo.git":
+ assertEquals("Expected REWIND(RW+) permission for " + p.registrant, Constants.AccessPermission.REWIND, p.permission);
+ found++;
+ break;
+ default:
+ fail("Unknown repository registrant " + p.registrant);
+ break;
+ }
+ }
+
+ assertEquals("Repostory permissions missing in list.", 3, found);
+
+ }
+
}