Search in sources :

Example 11 with GroupIdOrAnyone

use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.

the class GroupPermissionChangerTest method add_project_permission_to_group.

@Test
public void add_project_permission_to_group() {
    GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
    assertThat(db.users().selectGroupPermissions(group, null)).isEmpty();
    assertThat(db.users().selectGroupPermissions(group, project)).containsOnly(UserRole.ISSUE_ADMIN);
}
Also used : GroupIdOrAnyone(org.sonar.server.usergroups.ws.GroupIdOrAnyone) Test(org.junit.Test)

Example 12 with GroupIdOrAnyone

use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.

the class GroupPermissionChangerTest method add_project_permission_to_anyone.

@Test
public void add_project_permission_to_anyone() {
    GroupIdOrAnyone groupId = new GroupIdOrAnyone(org.getUuid(), null);
    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
    assertThat(db.users().selectAnyonePermissions(org, null)).isEmpty();
    assertThat(db.users().selectAnyonePermissions(org, project)).containsOnly(UserRole.ISSUE_ADMIN);
}
Also used : GroupIdOrAnyone(org.sonar.server.usergroups.ws.GroupIdOrAnyone) Test(org.junit.Test)

Example 13 with GroupIdOrAnyone

use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.

the class GroupPermissionChangerTest method fail_to_add_project_permission_on_global_group.

@Test
public void fail_to_add_project_permission_on_global_group() {
    GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
    expectedException.expect(BadRequestException.class);
    expectedException.expectMessage("Invalid global permission 'issueadmin'. Valid values are [admin, profileadmin, gateadmin, scan, provisioning]");
    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, null, groupId));
}
Also used : GroupIdOrAnyone(org.sonar.server.usergroups.ws.GroupIdOrAnyone) Test(org.junit.Test)

Example 14 with GroupIdOrAnyone

use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.

the class GroupPermissionChangerTest method remove_project_permission_from_group.

@Test
public void remove_project_permission_from_group() {
    GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
    db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES);
    db.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, project);
    db.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, project);
    apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
    assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(ADMINISTER_QUALITY_GATES.getKey());
    assertThat(db.users().selectGroupPermissions(group, project)).containsOnly(UserRole.CODEVIEWER);
}
Also used : GroupIdOrAnyone(org.sonar.server.usergroups.ws.GroupIdOrAnyone) Test(org.junit.Test)

Example 15 with GroupIdOrAnyone

use of org.sonar.server.usergroups.ws.GroupIdOrAnyone in project sonarqube by SonarSource.

the class GroupPermissionChangerTest method fail_to_add_global_permission_on_project.

@Test
public void fail_to_add_global_permission_on_project() {
    GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
    expectedException.expect(BadRequestException.class);
    expectedException.expectMessage("Invalid project permission 'gateadmin'. Valid values are [admin, codeviewer, issueadmin, scan, user]");
    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, new ProjectId(project), groupId));
}
Also used : GroupIdOrAnyone(org.sonar.server.usergroups.ws.GroupIdOrAnyone) Test(org.junit.Test)

Aggregations

GroupIdOrAnyone (org.sonar.server.usergroups.ws.GroupIdOrAnyone)16 Test (org.junit.Test)12 DbSession (org.sonar.db.DbSession)4 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)2 GroupPermissionChange (org.sonar.server.permission.GroupPermissionChange)2 PermissionChange (org.sonar.server.permission.PermissionChange)2 ProjectId (org.sonar.server.permission.ProjectId)2 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 UserDto (org.sonar.db.user.UserDto)1