Search in sources :

Example 1 with TeamModel

use of com.gitblit.models.TeamModel in project gitblit by gitblit.

the class FederationTests method deleteTestTeam.

private static void deleteTestTeam() throws IOException {
    TeamModel team = new TeamModel(testTeam);
    team.addRepositoryPermission(testTeamRepository);
    RpcUtils.deleteTeam(team, GitBlitSuite.url, GitBlitSuite.account, GitBlitSuite.password.toCharArray());
}
Also used : TeamModel(com.gitblit.models.TeamModel)

Example 2 with TeamModel

use of com.gitblit.models.TeamModel in project gitblit by gitblit.

the class FederationTests method testPullUsers.

@Test
public void testPullUsers() throws Exception {
    // clean up test user and team left over from previous run, if any
    deleteTestUser();
    deleteTestTeam();
    List<UserModel> users = FederationUtils.getUsers(getRegistration());
    assertNotNull(users);
    // admin is excluded, hence there should be no other users in the list
    assertEquals("Gitblit server still contains " + users + " user account(s).", 0, users.size());
    UserModel newUser = new UserModel(testUser);
    newUser.password = testUserPwd;
    assertTrue(RpcUtils.createUser(newUser, url, account, password.toCharArray()));
    TeamModel team = new TeamModel(testTeam);
    team.addUser(testUser);
    team.addRepositoryPermission(testTeamRepository);
    assertTrue(RpcUtils.createTeam(team, url, account, password.toCharArray()));
    users = FederationUtils.getUsers(getRegistration());
    assertNotNull(users);
    assertEquals(1, users.size());
    newUser = users.get(0);
    assertTrue(newUser.isTeamMember(testTeam));
    assertTrue(RpcUtils.deleteUser(newUser, url, account, password.toCharArray()));
    assertTrue(RpcUtils.deleteTeam(team, url, account, password.toCharArray()));
}
Also used : UserModel(com.gitblit.models.UserModel) TeamModel(com.gitblit.models.TeamModel) Test(org.junit.Test)

Example 3 with TeamModel

use of com.gitblit.models.TeamModel in project gitblit by gitblit.

the class PermissionsTest method testTeam_NONE_REWIND.

/**
 * NONE_REWIND = NO access restriction, REWIND access permission
 * (not useful scenario)
 */
@Test
public void testTeam_NONE_REWIND() 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.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);
}
Also used : TeamModel(com.gitblit.models.TeamModel) RepositoryModel(com.gitblit.models.RepositoryModel) Date(java.util.Date) Test(org.junit.Test)

Example 4 with TeamModel

use of com.gitblit.models.TeamModel 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);
}
Also used : UserModel(com.gitblit.models.UserModel) TeamModel(com.gitblit.models.TeamModel) RepositoryModel(com.gitblit.models.RepositoryModel) Date(java.util.Date) Test(org.junit.Test)

Example 5 with TeamModel

use of com.gitblit.models.TeamModel 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);
}
Also used : UserModel(com.gitblit.models.UserModel) TeamModel(com.gitblit.models.TeamModel) RepositoryModel(com.gitblit.models.RepositoryModel) Date(java.util.Date) Test(org.junit.Test)

Aggregations

TeamModel (com.gitblit.models.TeamModel)111 RepositoryModel (com.gitblit.models.RepositoryModel)68 Test (org.junit.Test)67 Date (java.util.Date)62 UserModel (com.gitblit.models.UserModel)58 ArrayList (java.util.ArrayList)18 HashSet (java.util.HashSet)8 RegistrantAccessPermission (com.gitblit.models.RegistrantAccessPermission)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 GitBlitException (com.gitblit.GitBlitException)4 SearchResult (com.unboundid.ldap.sdk.SearchResult)4 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)4 File (java.io.File)4 IOException (java.io.IOException)4 AccessPermission (com.gitblit.Constants.AccessPermission)3 Repository (org.eclipse.jgit.lib.Repository)3 IUserService (com.gitblit.IUserService)2 LdapConnection (com.gitblit.ldap.LdapConnection)2 RefModel (com.gitblit.models.RefModel)2