Search in sources :

Example 11 with GroupDto

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

the class UsersActionTest method fail_if_not_admin_of_organization.

@Test
public void fail_if_not_admin_of_organization() throws Exception {
    GroupDto group = db.users().insertGroup();
    userSession.logIn("not-admin");
    expectedException.expect(ForbiddenException.class);
    newUsersRequest().setParam("id", group.getId().toString()).setParam("login", "john").execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Example 12 with GroupDto

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

the class CreateActionTest method add_group_with_a_name_that_already_exists_in_another_organization.

@Test
public void add_group_with_a_name_that_already_exists_in_another_organization() throws Exception {
    String name = "the-group";
    OrganizationDto org1 = db.organizations().insert();
    OrganizationDto org2 = db.organizations().insert();
    GroupDto group = db.users().insertGroup(org1, name);
    loginAsAdmin(org2);
    newRequest().setParam("organization", org2.getKey()).setParam("name", name).execute().assertJson("{" + "  \"group\": {" + "    \"organization\": \"" + org2.getKey() + "\"," + "    \"name\": \"" + group.getName() + "\"," + "  }" + "}");
    assertThat(db.users().selectGroups(org1)).extracting(GroupDto::getName).containsOnly(name);
    assertThat(db.users().selectGroups(org2)).extracting(GroupDto::getName).containsOnly(name);
}
Also used : GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 13 with GroupDto

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

the class CreateActionTest method fail_if_group_with_same_name_already_exists_in_the_organization.

@Test
public void fail_if_group_with_same_name_already_exists_in_the_organization() throws Exception {
    OrganizationDto org = db.organizations().insert();
    GroupDto group = db.users().insertGroup(org, "the-group");
    loginAsAdmin(org);
    expectedException.expect(ServerException.class);
    expectedException.expectMessage("Group '" + group.getName() + "' already exists");
    newRequest().setParam("organization", org.getKey()).setParam("name", group.getName()).execute();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 14 with GroupDto

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

the class CreateActionTest method create_group_on_specific_organization.

@Test
public void create_group_on_specific_organization() throws Exception {
    OrganizationDto org = db.organizations().insert();
    loginAsAdmin(org);
    newRequest().setParam("organization", org.getKey()).setParam("name", "some-product-bu").setParam("description", "Business Unit for Some Awesome Product").execute().assertJson("{" + "  \"group\": {" + "    \"organization\": \"" + org.getKey() + "\"," + "    \"name\": \"some-product-bu\"," + "    \"description\": \"Business Unit for Some Awesome Product\"," + "    \"membersCount\": 0" + "  }" + "}");
    GroupDto createdGroup = db.users().selectGroup(org, "some-product-bu").get();
    assertThat(createdGroup.getId()).isNotNull();
    assertThat(createdGroup.getOrganizationUuid()).isEqualTo(org.getUuid());
}
Also used : GroupDto(org.sonar.db.user.GroupDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 15 with GroupDto

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

the class DeleteActionTest method delete_by_name_on_default_organization.

@Test
public void delete_by_name_on_default_organization() throws Exception {
    addAdminToDefaultOrganization();
    GroupDto group = db.users().insertGroup();
    loginAsAdminOnDefaultOrganization();
    newRequest().setParam(PARAM_GROUP_NAME, group.getName()).execute().assertNoContent();
    assertThat(db.users().selectGroupById(group.getId())).isNull();
}
Also used : GroupDto(org.sonar.db.user.GroupDto) Test(org.junit.Test)

Aggregations

GroupDto (org.sonar.db.user.GroupDto)424 Test (org.junit.Test)387 UserDto (org.sonar.db.user.UserDto)148 ComponentDto (org.sonar.db.component.ComponentDto)127 GroupTesting.newGroupDto (org.sonar.db.user.GroupTesting.newGroupDto)70 OrganizationDto (org.sonar.db.organization.OrganizationDto)42 UserTesting.newUserDto (org.sonar.db.user.UserTesting.newUserDto)36 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)34 QProfileDto (org.sonar.db.qualityprofile.QProfileDto)31 QualityGateDto (org.sonar.db.qualitygate.QualityGateDto)28 DbSession (org.sonar.db.DbSession)20 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)17 NotFoundException (org.sonar.server.exceptions.NotFoundException)14 PermissionTemplateTesting.newPermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto)13 UserGroupDto (org.sonar.db.user.UserGroupDto)12 BasePermissionWsTest (org.sonar.server.permission.ws.BasePermissionWsTest)12 TestResponse (org.sonar.server.ws.TestResponse)11 Qualitygates (org.sonarqube.ws.Qualitygates)10 PermissionTemplateTesting.newPermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateGroupDto)9 SearchGroupsResponse (org.sonarqube.ws.Qualityprofiles.SearchGroupsResponse)9