use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class LdapAuthenticationTest method syncUpdateUsersAndGroupsAdminProperty.
@Test
public void syncUpdateUsersAndGroupsAdminProperty() throws Exception {
// This test only makes sense if the authentication mode allows for synchronization.
assumeTrue(authMode == AuthMode.ANONYMOUS || authMode == AuthMode.DS_MANAGER);
settings.put(Keys.realm.ldap.synchronize, "true");
ldap.sync();
UserModel user = userManager.getUserModel("UserOne");
assertNotNull(user);
assertFalse(user.canAdmin);
assertTrue(user.canAdmin());
user = userManager.getUserModel("UserTwo");
assertNotNull(user);
assertFalse(user.canAdmin);
assertTrue(user.canAdmin());
user = userManager.getUserModel("UserThree");
assertNotNull(user);
assertTrue(user.canAdmin);
assertTrue(user.canAdmin());
user = userManager.getUserModel("UserFour");
assertNotNull(user);
assertFalse(user.canAdmin);
assertFalse(user.canAdmin());
TeamModel team = userManager.getTeamModel("Git_Admins");
assertNotNull(team);
assertTrue(team.canAdmin);
team = userManager.getTeamModel("Git Admins");
assertNotNull(team);
assertTrue(team.canAdmin);
team = userManager.getTeamModel("Git_Users");
assertNotNull(team);
assertFalse(team.canAdmin);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeamMember_NONE_NONE.
/**
* NONE_NONE = NO access restriction, NO access permission
*/
@Test
public void testTeamMember_NONE_NONE() 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");
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_PUSH_DELETE.
/**
* PUSH_DELETE = PUSH access restriction, DELETE access permission
*/
@Test
public void testTeam_PUSH_DELETE() 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.DELETE);
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));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.DELETE, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_CLONE_DELETE.
/**
* CLONE_DELETE = CLONE access restriction, DELETE access permission
*/
@Test
public void testTeam_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);
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));
assertFalse("team CAN rewind ref!", team.canRewindRef(repository));
assertEquals("team has wrong permission!", AccessPermission.DELETE, team.getRepositoryPermission(repository).permission);
}
use of com.gitblit.models.TeamModel in project gitblit by gitblit.
the class PermissionsTest method testTeam_NONE_CLONE.
/**
* NONE_CLONE = NO access restriction, CLONE access permission
* (not useful scenario)
*/
@Test
public void testTeam_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);
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);
}
Aggregations