Search in sources :

Example 76 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method fail_if_administrator_of_other_organization_only.

@Test
public void fail_if_administrator_of_other_organization_only() throws Exception {
    OrganizationDto org1 = db.organizations().insert();
    OrganizationDto org2 = db.organizations().insert();
    GroupDto group = db.users().insertGroup(org1, "the-group");
    loginAsAdmin(org2);
    expectedException.expect(ForbiddenException.class);
    newRequest().setParam(PARAM_GROUP_ID, group.getId().toString()).setParam(PARAM_PERMISSION, PROVISIONING).execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 77 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method fail_when_project_uuid_and_project_key_are_provided.

@Test
public void fail_when_project_uuid_and_project_key_are_provided() throws Exception {
    GroupDto group = db.users().insertGroup();
    ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()));
    loginAsAdmin(db.getDefaultOrganization());
    expectedException.expect(BadRequestException.class);
    expectedException.expectMessage("Project id or project key can be provided, not both.");
    newRequest().setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_PERMISSION, SYSTEM_ADMIN).setParam(PARAM_PROJECT_ID, project.uuid()).setParam(PARAM_PROJECT_KEY, project.key()).execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 78 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method fail_if_not_administrator_of_organization.

@Test
public void fail_if_not_administrator_of_organization() throws Exception {
    GroupDto group = db.users().insertGroup();
    loginAsAdmin(db.getDefaultOrganization());
    expectedException.expect(IllegalArgumentException.class);
    newRequest().setParam(PARAM_GROUP_NAME, group.getName()).execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Example 79 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method adding_global_permission_fails_if_not_administrator_of_organization.

@Test
public void adding_global_permission_fails_if_not_administrator_of_organization() throws Exception {
    GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
    // user is administrator of another organization
    userSession.logIn().addPermission(ADMINISTER, "anotherOrg");
    expectedException.expect(ForbiddenException.class);
    newRequest().setParam(PARAM_GROUP_NAME, group.getName()).setParam(PARAM_PERMISSION, PROVISIONING).execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Example 80 with GroupDto

use of org.sonar.db.user.GroupDto in project sonarqube by SonarSource.

the class AddGroupActionTest method add_permission_to_group_referenced_by_its_id.

@Test
public void add_permission_to_group_referenced_by_its_id() throws Exception {
    GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "sonar-administrators");
    loginAsAdmin(db.getDefaultOrganization());
    newRequest().setParam(PARAM_GROUP_ID, group.getId().toString()).setParam(PARAM_PERMISSION, SYSTEM_ADMIN).execute();
    assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(SYSTEM_ADMIN);
}
Also used : GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Aggregations

GroupDto (org.sonar.db.user.GroupDto)177 Test (org.junit.Test)158 OrganizationDto (org.sonar.db.organization.OrganizationDto)74 UserDto (org.sonar.db.user.UserDto)67 ComponentDto (org.sonar.db.component.ComponentDto)38 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)31 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)18 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)17 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)14 UserGroupDto (org.sonar.db.user.UserGroupDto)12 DbSession (org.sonar.db.DbSession)11 BasePermissionWsTest (org.sonar.server.permission.ws.BasePermissionWsTest)9 PermissionTemplateTesting.newPermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateGroupDto)8 WsGroupsResponse (org.sonarqube.ws.WsPermissions.WsGroupsResponse)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)3 System2 (org.sonar.api.utils.System2)3 DbClient (org.sonar.db.DbClient)3 PermissionTemplateTesting.newPermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto)3 Strings (com.google.common.base.Strings)2