Search in sources :

Example 16 with WsResponse

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

the class WsTest method gets_protobuf.

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

Example 17 with WsResponse

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

the class AutoAssignTest method createUser.

private void createUser(String login, String password) {
    WsResponse response = newAdminWsClient(ORCHESTRATOR).wsConnector().call(new PostRequest("api/users/create").setParam("login", login).setParam("name", login).setParam("password", password));
    assertThat(response.code()).isEqualTo(200);
}
Also used : PostRequest(org.sonarqube.ws.client.PostRequest) WsResponse(org.sonarqube.ws.client.WsResponse)

Example 18 with WsResponse

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

the class RestartTest method restart_in_prod_mode_requires_sysadmin_permission_and_restarts.

@Test
public void restart_in_prod_mode_requires_sysadmin_permission_and_restarts() throws Exception {
    // server classloader locks Jar files on Windows
    if (!SystemUtils.IS_OS_WINDOWS) {
        orchestrator = Orchestrator.builderEnv().setOrchestratorProperty("orchestrator.keepWorkspace", "true").build();
        orchestrator.start();
        verifyFailWith403(() -> newWsClient(orchestrator).system().restart());
        createNonSystemAdministrator("john", "doe");
        verifyFailWith403(() -> ItUtils.newUserWsClient(orchestrator, "john", "doe").system().restart());
        createSystemAdministrator("big", "boss");
        ItUtils.newUserWsClient(orchestrator, "big", "boss").system().restart();
        WsResponse wsResponse = newAdminWsClient(orchestrator).wsConnector().call(new GetRequest("/api/system/status")).failIfNotSuccessful();
        assertThat(wsResponse.content()).contains("RESTARTING");
        // we just wait five seconds, for a lack of a better approach to waiting for the restart process to start in SQ
        Thread.sleep(5000);
        assertThat(FileUtils.readFileToString(orchestrator.getServer().getWebLogs())).contains("SonarQube restart requested by big");
    }
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) Test(org.junit.Test)

Example 19 with WsResponse

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

the class ServerSystemTest method download_system_info.

@Test
public void download_system_info() throws Exception {
    waitForComputeEngineToBeUp(orchestrator);
    WsResponse response = newAdminWsClient(orchestrator).wsConnector().call(new GetRequest("api/system/info"));
    assertThat(response.code()).isEqualTo(200);
    assertThat(response.content()).contains(// SONAR-7436 monitor ES and CE
    "\"Compute Engine Database Connection\":", "\"Compute Engine State\":", "\"Compute Engine Tasks\":", "\"Elasticsearch\":", "\"State\":\"GREEN\"", // SONAR-7271 get settings
    "\"Settings\":", "\"sonar.jdbc.url\":", "\"sonar.path.data\":");
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsResponse(org.sonarqube.ws.client.WsResponse) ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) Test(org.junit.Test)

Example 20 with WsResponse

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

the class QualityGateTest method getAnalysisId.

private String getAnalysisId(String taskId) throws IOException {
    WsResponse activity = wsClient.wsConnector().call(new GetRequest("api/ce/task").setParam("id", taskId).setMediaType(MediaTypes.PROTOBUF));
    WsCe.TaskResponse activityWsResponse = WsCe.TaskResponse.parseFrom(activity.contentStream());
    return activityWsResponse.getTask().getAnalysisId();
}
Also used : GetRequest(org.sonarqube.ws.client.GetRequest) WsCe(org.sonarqube.ws.WsCe) WsResponse(org.sonarqube.ws.client.WsResponse) ProjectStatusWsResponse(org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse)

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