use of org.sonarqube.ws.client.organization.OrganizationService in project sonarqube by SonarSource.
the class OrganizationTest method create_fails_if_user_is_not_root.
@Test
public void create_fails_if_user_is_not_root() {
userRule.createUser("foo", "bar");
CreateWsRequest createWsRequest = new CreateWsRequest.Builder().setName("bla bla").build();
OrganizationService fooUserOrganizationService = ItUtils.newUserWsClient(orchestrator, "foo", "bar").organizations();
expect403HttpError(() -> fooUserOrganizationService.create(createWsRequest));
userRule.setRoot("foo");
assertThat(fooUserOrganizationService.create(createWsRequest).getOrganization().getKey()).isEqualTo("bla-bla");
// delete org, attempt recreate when no root anymore and ensure it can't anymore
fooUserOrganizationService.delete("bla-bla");
userRule.unsetRoot("foo");
expect403HttpError(() -> fooUserOrganizationService.create(createWsRequest));
}
use of org.sonarqube.ws.client.organization.OrganizationService in project sonarqube by SonarSource.
the class OrganizationTest method verifyUserNotAuthorized.
private void verifyUserNotAuthorized(String login, String password, Consumer<OrganizationService> consumer) {
try {
OrganizationService organizationService = ItUtils.newUserWsClient(orchestrator, login, password).organizations();
consumer.accept(organizationService);
fail("An HttpException should have been raised");
} catch (HttpException e) {
assertThat(e.code()).isEqualTo(403);
}
}
Aggregations