use of com.gitblit.models.UserModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_NONE_VIEW.
/**
* NONE_VIEW = NO access restriction, VIEW access permission
* (not useful scenario)
*/
@Test
public void testTeamMember_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);
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.UserModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_CLONE_REWIND.
/**
* CLONE_REWIND = CLONE access restriction, REWIND access permission
*/
@Test
public void testTeamMember_CLONE_REWIND() 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.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.UserModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_NONE_PUSH.
/**
* NONE_PUSH = NO access restriction, PUSH access permission.
* (not useful scenario)
*/
@Test
public void testNamed_NONE_PUSH() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.PUSH);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("named has wrong permission!", AccessPermission.REWIND, 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.UserModel in project gitblit by gitblit.
the class PermissionsTest method testNamed_CLONE_REWIND.
/**
* CLONE_REWIND = CLONE access restriction, REWIND access permission
*/
@Test
public void testNamed_CLONE_REWIND() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.NAMED;
repository.accessRestriction = AccessRestrictionType.CLONE;
UserModel user = new UserModel("test");
user.setRepositoryPermission(repository.name, AccessPermission.REWIND);
assertTrue("named CAN NOT view!", user.canView(repository));
assertTrue("named CAN NOT clone!", user.canClone(repository));
assertTrue("named CAN NOT push!", user.canPush(repository));
assertTrue("named CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("named CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("named CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("named has wrong permission!", AccessPermission.REWIND, 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.UserModel in project gitblit by gitblit.
the class PermissionsTest method testAuthenticated_NONE.
/**
* Authenticated access rights/permissions
*/
@Test
public void testAuthenticated_NONE() throws Exception {
RepositoryModel repository = new RepositoryModel("myrepo.git", null, null, new Date());
repository.authorizationControl = AuthorizationControl.AUTHENTICATED;
repository.accessRestriction = AccessRestrictionType.NONE;
UserModel user = new UserModel("test");
// all permissions, except fork
assertTrue("authenticated CAN NOT view!", user.canView(repository));
assertTrue("authenticated CAN NOT clone!", user.canClone(repository));
assertTrue("authenticated CAN NOT push!", user.canPush(repository));
assertTrue("authenticated CAN NOT create ref!", user.canCreateRef(repository));
assertTrue("authenticated CAN NOT delete ref!", user.canDeleteRef(repository));
assertTrue("authenticated CAN NOT rewind ref!", user.canRewindRef(repository));
assertEquals("authenticated has wrong permission!", AccessPermission.REWIND, user.getRepositoryPermission(repository).permission);
user.canFork = false;
repository.allowForks = false;
assertFalse("authenticated CAN fork!", user.canFork(repository));
repository.allowForks = true;
assertFalse("authenticated CAN fork!", user.canFork(repository));
user.canFork = true;
assertTrue("authenticated CAN NOT fork!", user.canFork(repository));
assertFalse("authenticated CAN delete!", user.canDelete(repository));
assertFalse("authenticated CAN edit!", user.canEdit(repository));
}
Aggregations