diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/com/gitblit/tests/FederationTests.java | 2 | ||||
-rw-r--r-- | tests/com/gitblit/tests/GitServletTest.java | 8 | ||||
-rw-r--r-- | tests/com/gitblit/tests/PermissionsTest.java | 51 | ||||
-rw-r--r-- | tests/com/gitblit/tests/RpcTests.java | 2 |
4 files changed, 53 insertions, 10 deletions
diff --git a/tests/com/gitblit/tests/FederationTests.java b/tests/com/gitblit/tests/FederationTests.java index be9960a9..ced500a5 100644 --- a/tests/com/gitblit/tests/FederationTests.java +++ b/tests/com/gitblit/tests/FederationTests.java @@ -72,7 +72,7 @@ public class FederationTests { model.accessRestriction = AccessRestrictionType.VIEW;
model.description = "cloneable repository " + i;
model.lastChange = new Date();
- model.addRepoAdministrator("adminuser");
+ model.addOwner("adminuser");
model.name = "repo" + i + ".git";
model.size = "5 MB";
model.hasCommits = true;
diff --git a/tests/com/gitblit/tests/GitServletTest.java b/tests/com/gitblit/tests/GitServletTest.java index 284be4c5..a05b3650 100644 --- a/tests/com/gitblit/tests/GitServletTest.java +++ b/tests/com/gitblit/tests/GitServletTest.java @@ -40,8 +40,8 @@ import com.gitblit.Keys; import com.gitblit.models.PushLogEntry;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.MultiConfigUtil;
import com.gitblit.utils.PushLogUtils;
public class GitServletTest {
@@ -59,8 +59,6 @@ public class GitServletTest { String password = GitBlitSuite.password;
private static final AtomicBoolean started = new AtomicBoolean(false);
-
- private MultiConfigUtil multiConfigUtil = new MultiConfigUtil();
@BeforeClass
public static void startGitblit() throws Exception {
@@ -728,7 +726,7 @@ public class GitServletTest { // confirm default personal repository permissions
RepositoryModel model = GitBlit.self().getRepositoryModel(MessageFormat.format("~{0}/ticgit.git", user.username));
- assertEquals("Unexpected owner", user.username, multiConfigUtil.convertCollectionToSingleLineString(model.getRepoAdministrators()));
+ assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners));
assertEquals("Unexpected authorization control", AuthorizationControl.NAMED, model.authorizationControl);
assertEquals("Unexpected access restriction", AccessRestrictionType.VIEW, model.accessRestriction);
@@ -752,7 +750,7 @@ public class GitServletTest { // confirm default project repository permissions
RepositoryModel model = GitBlit.self().getRepositoryModel("project/ticgit.git");
- assertEquals("Unexpected owner", user.username, multiConfigUtil.convertCollectionToSingleLineString(model.getRepoAdministrators()));
+ assertEquals("Unexpected owner", user.username, ArrayUtils.toString(model.owners));
assertEquals("Unexpected authorization control", AuthorizationControl.fromName(GitBlit.getString(Keys.git.defaultAuthorizationControl, "NAMED")), model.authorizationControl);
assertEquals("Unexpected access restriction", AccessRestrictionType.fromName(GitBlit.getString(Keys.git.defaultAccessRestriction, "NONE")), model.accessRestriction);
diff --git a/tests/com/gitblit/tests/PermissionsTest.java b/tests/com/gitblit/tests/PermissionsTest.java index 6eca046b..5a951042 100644 --- a/tests/com/gitblit/tests/PermissionsTest.java +++ b/tests/com/gitblit/tests/PermissionsTest.java @@ -2327,7 +2327,7 @@ public class PermissionsTest extends Assert { repository.accessRestriction = AccessRestrictionType.VIEW; UserModel user = new UserModel("test"); - repository.addRepoAdministrator(user.username); + repository.addOwner(user.username); assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name)); assertTrue("owner CAN NOT view!", user.canView(repository)); @@ -2345,13 +2345,58 @@ public class PermissionsTest extends Assert { } @Test + public void testMultipleOwners() throws Exception { + RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date()); + repository.authorizationControl = AuthorizationControl.NAMED; + repository.accessRestriction = AccessRestrictionType.VIEW; + + UserModel user = new UserModel("test"); + repository.addOwner(user.username); + UserModel user2 = new UserModel("test2"); + repository.addOwner(user2.username); + + // first owner + assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name)); + assertTrue("owner CAN NOT view!", user.canView(repository)); + assertTrue("owner CAN NOT clone!", user.canClone(repository)); + assertTrue("owner CAN NOT push!", user.canPush(repository)); + + assertTrue("owner CAN NOT create ref!", user.canCreateRef(repository)); + assertTrue("owner CAN NOT delete ref!", user.canDeleteRef(repository)); + assertTrue("owner CAN NOT rewind ref!", user.canRewindRef(repository)); + + assertTrue("owner CAN NOT fork!", user.canFork(repository)); + + assertFalse("owner CAN NOT delete!", user.canDelete(repository)); + assertTrue("owner CAN NOT edit!", user.canEdit(repository)); + + // second owner + assertFalse("user SHOULD NOT HAVE a repository permission!", user2.hasRepositoryPermission(repository.name)); + assertTrue("owner CAN NOT view!", user2.canView(repository)); + assertTrue("owner CAN NOT clone!", user2.canClone(repository)); + assertTrue("owner CAN NOT push!", user2.canPush(repository)); + + assertTrue("owner CAN NOT create ref!", user2.canCreateRef(repository)); + assertTrue("owner CAN NOT delete ref!", user2.canDeleteRef(repository)); + assertTrue("owner CAN NOT rewind ref!", user2.canRewindRef(repository)); + + assertTrue("owner CAN NOT fork!", user2.canFork(repository)); + + assertFalse("owner CAN NOT delete!", user2.canDelete(repository)); + assertTrue("owner CAN NOT edit!", user2.canEdit(repository)); + + assertTrue(repository.isOwner(user.username)); + assertTrue(repository.isOwner(user2.username)); + } + + @Test public void testOwnerPersonalRepository() throws Exception { RepositoryModel repository = new RepositoryModel("~test/myrepo.git", null, null, new Date()); repository.authorizationControl = AuthorizationControl.NAMED; repository.accessRestriction = AccessRestrictionType.VIEW; UserModel user = new UserModel("test"); - repository.addRepoAdministrator(user.username); + repository.addOwner(user.username); assertFalse("user SHOULD NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name)); assertTrue("user CAN NOT view!", user.canView(repository)); @@ -2375,7 +2420,7 @@ public class PermissionsTest extends Assert { repository.accessRestriction = AccessRestrictionType.VIEW; UserModel user = new UserModel("visitor"); - repository.addRepoAdministrator("test"); + repository.addOwner("test"); assertFalse("user HAS a repository permission!", user.hasRepositoryPermission(repository.name)); assertFalse("user CAN view!", user.canView(repository)); diff --git a/tests/com/gitblit/tests/RpcTests.java b/tests/com/gitblit/tests/RpcTests.java index 7228441f..3241a8ab 100644 --- a/tests/com/gitblit/tests/RpcTests.java +++ b/tests/com/gitblit/tests/RpcTests.java @@ -167,7 +167,7 @@ public class RpcTests { RepositoryModel model = new RepositoryModel();
model.name = "garbagerepo.git";
model.description = "created by RpcUtils";
- model.addRepoAdministrator("garbage");
+ model.addOwner("garbage");
model.accessRestriction = AccessRestrictionType.VIEW;
model.authorizationControl = AuthorizationControl.AUTHENTICATED;
|