use of org.sonarqube.ws.client.component.ComponentsService in project sonarqube by SonarSource.
the class OrganizationTest method by_default_anonymous_cannot_analyse_project_on_organization.
@Test
public void by_default_anonymous_cannot_analyse_project_on_organization() {
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);
try {
ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", orgKeyAndName);
fail();
} catch (BuildFailureException e) {
assertThat(e.getResult().getLogs()).contains("Insufficient privileges");
}
ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components();
assertThat(searchSampleProject(orgKeyAndName, componentsService).getComponentsCount()).isEqualTo(0);
adminOrganizationService.delete(orgKeyAndName);
}
use of org.sonarqube.ws.client.component.ComponentsService in project sonarqube by SonarSource.
the class OrganizationTest method an_organization_member_can_analyze_project.
@Test
public void an_organization_member_can_analyze_project() {
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);
userRule.createUser("bob", "bob");
userRule.removeGroups("sonar-users");
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);
}
use of org.sonarqube.ws.client.component.ComponentsService 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