diff options
author | James Moger <james.moger@gitblit.com> | 2013-05-02 22:59:02 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-05-02 22:59:02 -0400 |
commit | 9715e11fe30eccafa4c8272316883c80ba036a6e (patch) | |
tree | 764c6466caf919a6c008dea79d9a4c3ec4773702 /src/test/java/com | |
parent | d5ee557ef1370b5b9953dca1c8d3b14d0bd68a98 (diff) | |
download | gitblit-9715e11fe30eccafa4c8272316883c80ba036a6e.tar.gz gitblit-9715e11fe30eccafa4c8272316883c80ba036a6e.zip |
Improve permission determination when repo is frozen or is not bare
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/gitblit/tests/PermissionsTest.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/java/com/gitblit/tests/PermissionsTest.java b/src/test/java/com/gitblit/tests/PermissionsTest.java index 8e2ed977..12225e42 100644 --- a/src/test/java/com/gitblit/tests/PermissionsTest.java +++ b/src/test/java/com/gitblit/tests/PermissionsTest.java @@ -2843,4 +2843,39 @@ public class PermissionsTest extends Assert { assertTrue("User did not inherit create privileges", user.canCreate()); } + @Test + public void testIsFrozen() throws Exception { + RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date()); + repo.authorizationControl = AuthorizationControl.NAMED; + repo.accessRestriction = AccessRestrictionType.NONE; + + UserModel user = new UserModel("test"); + TeamModel team = new TeamModel("team"); + + assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission); + assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission); + + // freeze repo + repo.isFrozen = true; + assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission); + assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repo).permission); + } + + @Test + public void testIsBare() throws Exception { + RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date()); + repo.authorizationControl = AuthorizationControl.NAMED; + repo.accessRestriction = AccessRestrictionType.NONE; + + UserModel user = new UserModel("test"); + TeamModel team = new TeamModel("team"); + + assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission); + assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission); + + // set repo to have a working copy, pushes prohibited + repo.isBare = false; + assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission); + assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repo).permission); + } } |