use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_NONE_DELETE.
/**
* NONE_DELETE = NO access restriction, DELETE access permission.
* (not useful scenario)
*/
@Test
public void testNamed_NONE_DELETE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("named has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
user.canFork = false;
assertFalse("named CAN fork!", user.canFork(repository));
user.canFork = true;
assertFalse("named CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testCreateTeamInheritance.
@Test
public void testCreateTeamInheritance() throws Exception {
UserModel user = new UserModel("test");
TeamModel team = new TeamModel("team");
team.canCreate = true;
user.teams.add(team);
assertTrue("User did not inherit create privileges", user.canCreate());
}
use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_CLONE_NONE.
/**
* CLONE_NONE = CLONE access restriction, NO access permission
*/
@Test
public void testNamed_CLONE_NONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
UserModel user = new UserModel("test");
assertTrue("named CAN NOT view!", user.canView(repository));
assertFalse("named CAN clone!", user.canClone(repository));
assertFalse("named CAN push!", user.canPush(repository));
assertFalse("named CAN create ref!", user.canCreateRef(repository));
assertFalse("named CAN delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
assertEquals("named has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
user.canFork = false;
assertFalse("named CAN fork!", user.canFork(repository));
user.canFork = true;
assertFalse("named CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertFalse("named CAN NOT fork!", user.canFork(repository));
}
use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testAdminTeamInheritance.
@Test
public void testAdminTeamInheritance() throws Exception {
UserModel user = new UserModel("test");
TeamModel team = new TeamModel("team");
team.canAdmin = true;
user.teams.add(team);
assertTrue("User did not inherit admin privileges", user.canAdmin());
}
use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_VIEW_DELETE.
/**
* VIEW_DELETE = VIEW access restriction, DELETE access permission
*/
@Test
public void testNamed_VIEW_DELETE() 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");
user.setRepositoryPermission(repository.name, AccessPermission.DELETE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN not push!", user.canPush(repository));
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("named CAN rewind ref!", user.canRewindRef(repository));
assertEquals("named has wrong permission!", AccessPermission.DELETE, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
user.canFork = false;
assertFalse("named CAN fork!", user.canFork(repository));
user.canFork = true;
assertFalse("named CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertTrue("named CAN NOT fork!", user.canFork(repository));
}
Aggregations