use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_NONE_CREATE.
/**
* NONE_CREATE = NO access restriction, CREATE access permission
* (not useful scenario)
*/
@Test
public void testTeam_NONE_CREATE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.NONE;
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.CREATE);
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT push!", team.canPush(repository));
assertTrue("team CAN NOT create ref!", team.canCreateRef(repository));
assertTrue("team CAN NOT delete ref!", team.canDeleteRef(repository));
assertTrue("team CAN NOT rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testIsMirror.
@Test
public void testIsMirror() throws Exception {
RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
repo.authorizationControl = AuthorizationControl.NAMED;
repo.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
TeamModel team = new TeamModel("team");
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission);
// set repo to be a mirror, pushes prohibited
repo.isMirror = true;
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repo).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_VIEW_VIEW.
/**
* VIEW_VIEW = VIEW access restriction, VIEW access permission
*/
@Test
public void testTeamMember_VIEW_VIEW() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.VIEW;
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
UserModel user = new UserModel("test");
user.teams.add(team);
assertTrue("team member CAN NOT view!", user.canView(repository));
assertFalse("team member CAN clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testIsBare.
@Test
public void testIsBare() throws Exception {
RepositoryModel repo = new RepositoryModel("somerepo.git", null, null, new Date());
repo.authorizationControl = AuthorizationControl.NAMED;
repo.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
TeamModel team = new TeamModel("team");
assertEquals("user has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.REWIND, team.getRepositoryPermission(repo).permission);
// set repo to have a working copy, pushes prohibited
repo.isBare = false;
assertEquals("user has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repo).permission);
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repo).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_PUSH_VIEW.
/**
* PUSH_VIEW = PUSH access restriction, VIEW access permission
*/
@Test
public void testTeamMember_PUSH_VIEW() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.PUSH;
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.VIEW);
UserModel user = new UserModel("test");
user.teams.add(team);
assertTrue("team member CAN NOT view!", user.canView(repository));
assertTrue("team member CAN NOT clone!", user.canClone(repository));
assertFalse("team member CAN push!", user.canPush(repository));
assertFalse("team member CAN create ref!", user.canCreateRef(repository));
assertFalse("team member CAN delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.CLONE, user.getRepositoryPermission(repository).permission);
}
Aggregations