use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testAnonymous_CLONE.
@Test
public void testAnonymous_CLONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
UserModel user = UserModel.ANONYMOUS;
assertTrue("anonymous CAN NOT view!", user.canView(repository));
assertFalse("anonymous CAN clone!", user.canClone(repository));
assertFalse("anonymous CAN push!", user.canPush(repository));
assertFalse("anonymous CAN create ref!", user.canCreateRef(repository));
assertFalse("anonymous CAN delete ref!", user.canDeleteRef(repository));
assertFalse("anonymous CAN rewind ref!", user.canRewindRef(repository));
assertEquals("anonymous has wrong permission!", AccessPermission.VIEW, user.getRepositoryPermission(repository).permission);
repository.allowForks = false;
assertFalse("anonymous CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertFalse("anonymous CAN fork!", user.canFork(repository));
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_PUSH_PUSH.
/**
* PUSH_PUSH = PUSH access restriction, PUSH access permission
*/
@Test
public void testTeamMember_PUSH_PUSH() 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.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.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_PUSH_REWIND.
/**
* PUSH_REWIND = PUSH access restriction, REWIND access permission
*/
@Test
public void testTeamMember_PUSH_REWIND() 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.REWIND);
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_CLONE_PUSH.
/**
* CLONE_PUSH = CLONE access restriction, PUSH access permission
*/
@Test
public void testTeam_CLONE_PUSH() 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.PUSH);
assertTrue("team CAN NOT view!", team.canView(repository));
assertTrue("team CAN NOT clone!", team.canClone(repository));
assertTrue("team CAN NOT 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.PUSH, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.RepositoryModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_CLONE_VIEW.
/**
* CLONE_VIEW = CLONE access restriction, VIEW access permission
*/
@Test
public void testTeamMember_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);
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);
}
Aggregations