DiffUtilsTest.class, MetricUtilsTest.class, TicgitUtilsTest.class, X509UtilsTest.class,\r
GitBlitTest.class, FederationTests.class, RpcTests.class, GitServletTest.class, GitDaemonTest.class,\r
GroovyScriptTest.class, LuceneExecutorTest.class, IssuesTest.class, RepositoryModelTest.class,\r
- FanoutServiceTest.class, Issue0259Test.class })\r
+ FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class })\r
public class GitBlitSuite {\r
\r
public static final File REPOSITORIES = new File("data/git");\r
--- /dev/null
+/*\r
+ * Copyright 2013 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.tests;\r
+\r
+import java.io.File;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+import com.gitblit.ConfigUserService;\r
+import com.gitblit.Constants.AccessPermission;\r
+import com.gitblit.Constants.AccessRestrictionType;\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
+\r
+/**\r
+ * https://code.google.com/p/gitblit/issues/detail?id=271\r
+ * \r
+ * Reported Problem:\r
+ * Inherited team permissions are incorrect.\r
+ * \r
+ * @see src/test/resources/issue0270.conf\r
+ * \r
+ * @author James Moger\r
+ *\r
+ */\r
+public class Issue0271Test extends Assert {\r
+\r
+ RepositoryModel repo(String name, AccessRestrictionType restriction) {\r
+ RepositoryModel repo = new RepositoryModel();\r
+ repo.name = name;\r
+ repo.accessRestriction = restriction;\r
+ return repo;\r
+ }\r
+ \r
+ /**\r
+ * Test the provided users.conf file for expected access permissions.\r
+ * \r
+ * @throws Exception\r
+ */\r
+ @Test\r
+ public void testFile() throws Exception {\r
+ File realmFile = new File("src/test/resources/issue0271.conf");\r
+ ConfigUserService service = new ConfigUserService(realmFile);\r
+ \r
+ RepositoryModel test = repo("test.git", AccessRestrictionType.VIEW);\r
+ RepositoryModel teama_test = repo("teama/test.git", AccessRestrictionType.VIEW);\r
+ \r
+ UserModel a = service.getUserModel("a");\r
+ UserModel b = service.getUserModel("b");\r
+ UserModel c = service.getUserModel("c");\r
+ \r
+ // assert V for test.git\r
+ assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(test).permission);\r
+ assertEquals(AccessPermission.VIEW, b.getRepositoryPermission(test).permission);\r
+ assertEquals(AccessPermission.VIEW, c.getRepositoryPermission(test).permission);\r
+ \r
+ // assert expected permissions for teama/test.git\r
+ assertEquals(AccessPermission.VIEW, a.getRepositoryPermission(teama_test).permission);\r
+ assertEquals(AccessPermission.PUSH, b.getRepositoryPermission(teama_test).permission);\r
+ assertEquals(AccessPermission.CREATE, c.getRepositoryPermission(teama_test).permission);\r
+ }\r
+}
\ No newline at end of file