Search in sources :

Example 46 with TeamModel

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

Example 47 with TeamModel

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

the class PermissionsTest method testTeam_CLONE_VIEW.

/**
	 * CLONE_VIEW = CLONE access restriction, VIEW access permission
	 */
@Test
public void testTeam_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);
    assertTrue("team CAN NOT view!", team.canView(repository));
    assertFalse("team CAN 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.VIEW, 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 48 with TeamModel

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

the class PermissionsTest method testTeam_VIEW_VIEW.

/**
	 * VIEW_VIEW = VIEW access restriction, VIEW access permission
	 */
@Test
public void testTeam_VIEW_VIEW() 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.VIEW);
    assertTrue("team CAN NOT view!", team.canView(repository));
    assertFalse("team CAN 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.VIEW, 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 49 with TeamModel

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

Example 50 with TeamModel

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

Aggregations

TeamModel (com.gitblit.models.TeamModel)109 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)6 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 List (java.util.List)3 Repository (org.eclipse.jgit.lib.Repository)3 StoredConfig (org.eclipse.jgit.lib.StoredConfig)3 IUserService (com.gitblit.IUserService)2