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();
}
Aggregations