Search in sources :

Example 11 with WsResponse

use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.

the class WsLocalCallTest method fails_if_requires_permissions.

@Test
public void fails_if_requires_permissions() {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("local_ws_call/require_permission"));
    // this is not the unauthorized code as plugin forces it to 500
    assertThat(response.code()).isEqualTo(500);
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Example 12 with WsResponse

use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.

the class WsLocalCallTest method gets_json.

@Test
public void gets_json() {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("local_ws_call/json_data"));
    assertThat(response.isSuccessful()).isTrue();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Example 13 with WsResponse

use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.

the class WsLocalCallTest method propagates_authorization_rights.

@Test
public void propagates_authorization_rights() {
    WsClient wsClient = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder().url(orchestrator.getServer().getUrl()).credentials("admin", "admin").build());
    WsResponse response = wsClient.wsConnector().call(new GetRequest("local_ws_call/require_permission"));
    assertThat(response.isSuccessful()).isTrue();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) WsClient(org.sonarqube.ws.client.WsClient) ItUtils.newWsClient(util.ItUtils.newWsClient) Test(org.junit.Test)

Example 14 with WsResponse

use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.

the class WsTest method gets_json.

@Test
public void gets_json() {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.json"));
    assertThat(response.isSuccessful()).isTrue();
    assertThat(response.contentType()).contains("application/json");
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Example 15 with WsResponse

use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.

the class WsTest method fail_on_unknown_extension.

/**
   * SONAR-7484
   */
@Test
public void fail_on_unknown_extension() {
    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.unknown"));
    assertThat(response.isSuccessful()).isFalse();
    assertThat(response.code()).isEqualTo(HTTP_BAD_REQUEST);
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Aggregations

WsResponse (org.sonarqube.ws.client.WsResponse)38 Test (org.junit.Test)23 GetRequest (org.sonarqube.ws.client.GetRequest)21 WsRequest (org.sonarqube.ws.client.WsRequest)9 MockWsResponse (org.sonarqube.ws.client.MockWsResponse)5 WsClient (org.sonarqube.ws.client.WsClient)3 TempFolder (org.sonar.api.utils.TempFolder)2 HttpException (org.sonarqube.ws.client.HttpException)2 PostRequest (org.sonarqube.ws.client.PostRequest)2 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 CheckForNull (javax.annotation.CheckForNull)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1 MessageException (org.sonar.api.utils.MessageException)1