summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-07-17 09:45:35 -0400
committerJames Moger <james.moger@gitblit.com>2013-07-17 09:45:35 -0400
commit27505e78686b7fd2884001dbef10e117b8e709e6 (patch)
tree9c8c9e423db07a661c174d30f9a444635a98f642
parent88889cf483f8042510c668ea4b127a2d2a816df5 (diff)
downloadgitblit-27505e78686b7fd2884001dbef10e117b8e709e6.tar.gz
gitblit-27505e78686b7fd2884001dbef10e117b8e709e6.zip
Added unit test for reported issue (issue-271)
-rw-r--r--src/test/java/com/gitblit/tests/GitBlitSuite.java2
-rw-r--r--src/test/java/com/gitblit/tests/Issue0271Test.java76
-rw-r--r--src/test/resources/issue0271.conf20
3 files changed, 97 insertions, 1 deletions
diff --git a/src/test/java/com/gitblit/tests/GitBlitSuite.java b/src/test/java/com/gitblit/tests/GitBlitSuite.java
index a2263298..6fff241c 100644
--- a/src/test/java/com/gitblit/tests/GitBlitSuite.java
+++ b/src/test/java/com/gitblit/tests/GitBlitSuite.java
@@ -60,7 +60,7 @@ import com.gitblit.utils.JGitUtils;
DiffUtilsTest.class, MetricUtilsTest.class, TicgitUtilsTest.class, X509UtilsTest.class,
GitBlitTest.class, FederationTests.class, RpcTests.class, GitServletTest.class, GitDaemonTest.class,
GroovyScriptTest.class, LuceneExecutorTest.class, IssuesTest.class, RepositoryModelTest.class,
- FanoutServiceTest.class, Issue0259Test.class })
+ FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class })
public class GitBlitSuite {
public static final File REPOSITORIES = new File("data/git");
diff --git a/src/test/java/com/gitblit/tests/Issue0271Test.java b/src/test/java/com/gitblit/tests/Issue0271Test.java
new file mode 100644
index 00000000..437c5b9e
--- /dev/null
+++ b/src/test/java/com/gitblit/tests/Issue0271Test.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2013 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.tests;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.gitblit.ConfigUserService;
+import com.gitblit.Constants.AccessPermission;
+import com.gitblit.Constants.AccessRestrictionType;
+import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.UserModel;
+
+/**
+ * https://code.google.com/p/gitblit/issues/detail?id=271
+ *
+ * Reported Problem:
+ * Inherited team permissions are incorrect.
+ *
+ * @see src/test/resources/issue0270.conf
+ *
+ * @author James Moger
+ *
+ */
+public class Issue0271Test extends Assert {
+
+ RepositoryModel repo(String name, AccessRestrictionType restriction) {
+ RepositoryModel repo = new RepositoryModel();
+ repo.name = name;
+ repo.accessRestriction = restriction;
+ return repo;
+ }
+
+ /**
+ * Test the provided users.conf file for expected access permissions.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testFile() throws Exception {
+ File realmFile = new File("src/test/resources/issue0271.conf");
+ ConfigUserService service = new ConfigUserService(realmFile);
+
+ RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);
+ RepositoryModel teama_test = repo("teama/test.git", AccessRestrictionType.VIEW);
+
+ UserModel a = service.getUserModel("a");
+ UserModel b = service.getUserModel("b");
+ UserModel c = service.getUserModel("c");
+
+ // assert V for test.git
+ assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(test).permission);
+ assertEquals(AccessPermission.VIEW, b.getRepositoryPermission(test).permission);
+ assertEquals(AccessPermission.VIEW, c.getRepositoryPermission(test).permission);
+
+ // assert expected permissions for teama/test.git
+ assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(teama_test).permission);
+ assertEquals(AccessPermission.PUSH, b.getRepositoryPermission(teama_test).permission);
+ assertEquals(AccessPermission.CREATE, c.getRepositoryPermission(teama_test).permission);
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/issue0271.conf b/src/test/resources/issue0271.conf
new file mode 100644
index 00000000..c77ca921
--- /dev/null
+++ b/src/test/resources/issue0271.conf
@@ -0,0 +1,20 @@
+[user "A"]
+ password = apassword
+ role = "#none"
+[user "B"]
+ password = apassword
+ role = "#none"
+[user "C"]
+ password = apassword
+ role = "#none"
+ repository = RWC:teama/.*
+[team "developers"]
+ role = "#none"
+ repository = V:.*
+ user = A
+ user = B
+ user = C
+[team "teama"]
+ repository = RW:teama/.*
+ user = B
+ user = C