use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_NONE_CREATE.
/**
* NONE_CREATE = NO access restriction, CREATE access permission
* (not useful scenario)
*/
@Test
public void testTeamMember_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);
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));
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_CLONE_VIEW.
/**
* CLONE_VIEW = CLONE access restriction, VIEW access permission
*/
@Test
public void testTeam_CLONE_VIEW() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
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);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_NONE_PUSH.
/**
* NONE_PUSH = NO access restriction, PUSH access permission
* (not useful scenario)
*/
@Test
public void testTeamMember_NONE_PUSH() 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.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));
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("team member CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_NONE_VIEW.
/**
* NONE_VIEW = NO access restriction, VIEW access permission
* (not useful scenario)
*/
@Test
public void testTeam_NONE_VIEW() 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.VIEW);
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 testTeamMember_CLONE_DELETE.
/**
* CLONE_DELETE = CLONE access restriction, DELETE access permission
*/
@Test
public void testTeamMember_CLONE_DELETE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
TeamModel team = new TeamModel("test");
team.setRepositoryPermission(repository.name, AccessPermission.DELETE);
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));
assertTrue("team member CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("team member CAN NOT delete ref!", user.canDeleteRef(repository));
assertFalse("team member CAN rewind ref!", user.canRewindRef(repository));
assertEquals("team member has wrong permission!", AccessPermission.DELETE, user.getRepositoryPermission(repository).permission);
}
Aggregations