Search in sources :

Example 1 with GroupManagement

use of util.user.GroupManagement in project sonarqube by SonarSource.

the class OrganizationTest method deleting_an_organization_also_deletes_group_permissions_and_projects_and_check_security.

@Test
public void deleting_an_organization_also_deletes_group_permissions_and_projects_and_check_security() {
    verifyNoExtraOrganization();
    String orgKeyAndName = "org-key";
    Organizations.Organization createdOrganization = adminOrganizationService.create(new CreateWsRequest.Builder().setName(orgKeyAndName).setKey(orgKeyAndName).build()).getOrganization();
    verifySingleSearchResult(createdOrganization, orgKeyAndName, null, null, null);
    GroupManagement groupManagement = userRule.forOrganization(orgKeyAndName);
    userRule.createUser("bob", "bob");
    groupManagement.createGroup("grp1");
    groupManagement.createGroup("grp2");
    groupManagement.associateGroupsToUser("bob", "grp1", "grp2");
    assertThat(groupManagement.getUserGroups("bob").getGroups()).extracting(Groups.Group::getName).contains("grp1", "grp2");
    addPermissionsToUser(orgKeyAndName, "bob", "provisioning", "scan");
    ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", orgKeyAndName, "sonar.login", "bob", "sonar.password", "bob");
    ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components();
    assertThat(searchSampleProject(orgKeyAndName, componentsService).getComponentsList()).hasSize(1);
    adminOrganizationService.delete(orgKeyAndName);
    expect404HttpError(() -> searchSampleProject(orgKeyAndName, componentsService));
    assertThat(groupManagement.getUserGroups("bob").getGroups()).extracting(Groups.Group::getName).doesNotContain("grp1", "grp2");
    verifyNoExtraOrganization();
}
Also used : ComponentsService(org.sonarqube.ws.client.component.ComponentsService) Groups(util.user.Groups) Organizations(org.sonarqube.ws.Organizations) GroupManagement(util.user.GroupManagement) CreateWsRequest(org.sonarqube.ws.client.organization.CreateWsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Organizations (org.sonarqube.ws.Organizations)1 ComponentsService (org.sonarqube.ws.client.component.ComponentsService)1 CreateWsRequest (org.sonarqube.ws.client.organization.CreateWsRequest)1 GroupManagement (util.user.GroupManagement)1 Groups (util.user.Groups)1