Search in sources :

Example 1 with CreateWsRequest

use of org.sonarqube.ws.client.organization.CreateWsRequest 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));
}
Also used : OrganizationService(org.sonarqube.ws.client.organization.OrganizationService) CreateWsRequest(org.sonarqube.ws.client.organization.CreateWsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CreateWsRequest (org.sonarqube.ws.client.organization.CreateWsRequest)1 OrganizationService (org.sonarqube.ws.client.organization.OrganizationService)1