use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_VIEW_REWIND.
/**
* VIEW_REWIND = VIEW access restriction, REWIND access permission
*/
@Test
public void testTeam_VIEW_REWIND() 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.REWIND);
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.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_CLONE_CREATE.
/**
* CLONE_CREATE = CLONE access restriction, CREATE access permission
*/
@Test
public void testTeamMember_CLONE_CREATE() 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.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));
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.CREATE, user.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_VIEW_CLONE.
/**
* VIEW_CLONE = VIEW access restriction, CLONE access permission
*/
@Test
public void testNamed_VIEW_CLONE() 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.CLONE);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT 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.CLONE, 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.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_NONE_CLONE.
/**
* NONE_CLONE = NO access restriction, CLONE access permission
* (not useful scenario)
*/
@Test
public void testTeamMember_NONE_CLONE() 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.CLONE);
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.RepositoryModel 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);
}
Aggregations