]> source.dussan.org Git - gitblit.git/commitdiff
Fix RPC unit test
authorJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 19:01:15 +0000 (15:01 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 2 Jul 2013 19:01:15 +0000 (15:01 -0400)
src/test/java/com/gitblit/tests/RpcTests.java

index f8fdf6f90a40fd46577758c35c43f40de110e583..bd7f277931c1c89f5078497aef96f06f3d19c7d3 100644 (file)
@@ -172,6 +172,7 @@ public class RpcTests {
                model.authorizationControl = AuthorizationControl.AUTHENTICATED;\r
 \r
                // create\r
+               RpcUtils.deleteRepository(model, url, account, password.toCharArray());\r
                assertTrue("Failed to create repository!",\r
                                RpcUtils.createRepository(model, url, account, password.toCharArray()));\r
 \r
@@ -183,24 +184,31 @@ public class RpcTests {
                // rename and change access restriciton\r
                String originalName = model.name;\r
                model.name = "garbagerepo2.git";\r
-               model.accessRestriction = AccessRestrictionType.PUSH;\r
+               model.accessRestriction = AccessRestrictionType.CLONE;\r
                model.authorizationControl = AuthorizationControl.NAMED;\r
+               RpcUtils.deleteRepository(model, url, account, password.toCharArray());\r
                assertTrue("Failed to update repository!", RpcUtils.updateRepository(originalName, model,\r
                                url, account, password.toCharArray()));\r
 \r
                retrievedRepository = findRepository(model.name);\r
                assertNotNull("Failed to find " + model.name, retrievedRepository);\r
                assertTrue("Access retriction type is wrong",\r
-                               AccessRestrictionType.PUSH.equals(retrievedRepository.accessRestriction));\r
+                               AccessRestrictionType.CLONE.equals(retrievedRepository.accessRestriction));\r
 \r
+               // restore VIEW restriction\r
+               retrievedRepository.accessRestriction = AccessRestrictionType.VIEW;\r
+               assertTrue("Failed to update repository!", RpcUtils.updateRepository(retrievedRepository.name, retrievedRepository,\r
+                               url, account, password.toCharArray()));\r
+               retrievedRepository = findRepository(retrievedRepository.name);\r
+               \r
                // memberships\r
                UserModel testMember = new UserModel("justadded");\r
                assertTrue(RpcUtils.createUser(testMember, url, account, password.toCharArray()));\r
 \r
                List<RegistrantAccessPermission> permissions = RpcUtils.getRepositoryMemberPermissions(retrievedRepository, url, account,\r
                                password.toCharArray());\r
-               assertEquals("Membership permissions is not empty!", 0, permissions.size());\r
-               permissions.add(new RegistrantAccessPermission(testMember.username, AccessPermission.PUSH, PermissionType.EXPLICIT, RegistrantType.USER, null, true));\r
+               assertEquals("Unexpected permissions! " + permissions.toString(), 1, permissions.size());\r
+               permissions.add(new RegistrantAccessPermission(testMember.username, AccessPermission.VIEW, PermissionType.EXPLICIT, RegistrantType.USER, null, true));\r
                assertTrue(\r
                                "Failed to set member permissions!",\r
                                RpcUtils.setRepositoryMemberPermissions(retrievedRepository, permissions, url, account,\r
@@ -211,7 +219,7 @@ public class RpcTests {
                for (RegistrantAccessPermission permission : permissions) {\r
                        if (permission.registrant.equalsIgnoreCase(testMember.username)) {\r
                                foundMember = true;\r
-                               assertEquals(AccessPermission.PUSH, permission.permission);\r
+                               assertEquals(AccessPermission.VIEW, permission.permission);\r
                                break;\r
                        }\r
                }\r