use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_PUSH_NONE.
/**
* PUSH_NONE = PUSH access restriction, NO access permission
*/
@Test
public void testTeam_PUSH_NONE() 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");
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CLONE, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel 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.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_PUSH_CREATE.
/**
* PUSH_CREATE = PUSH access restriction, CREATE access permission
*/
@Test
public void testTeam_PUSH_CREATE() 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.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));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.CREATE, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_VIEW_PUSH.
/**
* VIEW_PUSH = VIEW access restriction, PUSH access permission
*/
@Test
public void testTeamMember_VIEW_PUSH() 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.PUSH);
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));
assertTrue("team member CAN NOT 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.PUSH, user.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_VIEW_VIEW.
/**
* VIEW_VIEW = VIEW access restriction, VIEW access permission
*/
@Test
public void testTeam_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);
assertTrue("team CAN NOT view!", team.canView(repository));
assertFalse("team CAN clone!", team.canClone(repository));
assertFalse("team CAN push!", team.canPush(repository));
assertFalse("team CAN create ref!", team.canCreateRef(repository));
assertFalse("team CAN delete ref!", team.canDeleteRef(repository));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.VIEW, team.getRepositoryPermission(repository).permission);
}
Aggregations