Search in sources :

Example 1 with ShowWsResponse

use of org.sonarqube.ws.ServerId.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method return_no_server_id_info_when_no_server_id_but_other_settings.

@Test
public void return_no_server_id_info_when_no_server_id_but_other_settings() throws Exception {
    logInAsSystemAdministrator();
    insertConfiguration(null, "home", "127.0.0.1");
    ShowWsResponse response = executeRequest();
    assertThat(response.hasServerId()).isFalse();
    assertThat(response.hasOrganization()).isFalse();
    assertThat(response.hasIp()).isFalse();
    assertThat(response.getValidIpAddressesList()).isEmpty();
    assertThat(response.hasInvalidServerId()).isFalse();
}
Also used : ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) Test(org.junit.Test)

Example 2 with ShowWsResponse

use of org.sonarqube.ws.ServerId.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method return_invalid_server_id.

@Test
public void return_invalid_server_id() throws Exception {
    logInAsSystemAdministrator();
    when(generator.validate("home", "127.0.0.1", "1818a1eefb26f9g")).thenReturn(true);
    insertConfiguration("invalid", null, null);
    ShowWsResponse response = executeRequest();
    assertThat(response.hasInvalidServerId()).isTrue();
    assertThat(response.getServerId()).isEqualTo("invalid");
    assertThat(response.hasOrganization()).isFalse();
    assertThat(response.hasIp()).isFalse();
    assertThat(response.getValidIpAddressesList()).isEmpty();
}
Also used : ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) Test(org.junit.Test)

Example 3 with ShowWsResponse

use of org.sonarqube.ws.ServerId.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method return_available_ips_even_if_no_settings.

@Test
public void return_available_ips_even_if_no_settings() throws Exception {
    logInAsSystemAdministrator();
    setAvailableIpAdresses("192.168.1.1", "127.0.0.1");
    ShowWsResponse response = executeRequest();
    assertThat(response.hasServerId()).isFalse();
    assertThat(response.hasOrganization()).isFalse();
    assertThat(response.hasIp()).isFalse();
    assertThat(response.getValidIpAddressesList()).containsOnly("192.168.1.1", "127.0.0.1");
    assertThat(response.hasInvalidServerId()).isFalse();
}
Also used : ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) Test(org.junit.Test)

Example 4 with ShowWsResponse

use of org.sonarqube.ws.ServerId.ShowWsResponse in project sonarqube by SonarSource.

the class ServerSystemTest method getValidIpAddress.

private String getValidIpAddress() throws IOException {
    WsClient adminWsClient = newAdminWsClient(orchestrator);
    ShowWsResponse response = ShowWsResponse.parseFrom(adminWsClient.wsConnector().call(new GetRequest("api/server_id/show").setMediaType(MediaTypes.PROTOBUF)).contentStream());
    assertThat(response.getValidIpAddressesCount()).isGreaterThan(0);
    return response.getValidIpAddresses(0);
}
Also used : ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) GetRequest(org.sonarqube.ws.client.GetRequest) WsClient(org.sonarqube.ws.client.WsClient) ItUtils.newAdminWsClient(util.ItUtils.newAdminWsClient) ItUtils.newWsClient(util.ItUtils.newWsClient)

Example 5 with ShowWsResponse

use of org.sonarqube.ws.ServerId.ShowWsResponse in project sonarqube by SonarSource.

the class ShowActionTest method return_no_server_id_info_when_no_settings_and_no_available_ips.

@Test
public void return_no_server_id_info_when_no_settings_and_no_available_ips() throws Exception {
    logInAsSystemAdministrator();
    ShowWsResponse response = executeRequest();
    assertThat(response.hasServerId()).isFalse();
    assertThat(response.hasOrganization()).isFalse();
    assertThat(response.hasIp()).isFalse();
    assertThat(response.getValidIpAddressesList()).isEmpty();
    assertThat(response.hasInvalidServerId()).isFalse();
}
Also used : ShowWsResponse(org.sonarqube.ws.ServerId.ShowWsResponse) Test(org.junit.Test)

Aggregations

ShowWsResponse (org.sonarqube.ws.ServerId.ShowWsResponse)6 Test (org.junit.Test)5 GetRequest (org.sonarqube.ws.client.GetRequest)1 WsClient (org.sonarqube.ws.client.WsClient)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.newWsClient (util.ItUtils.newWsClient)1