use of org.sonarqube.ws.client.HttpConnector in project sonarqube by SonarSource.
the class ScannerWsClientProviderTest method provide_client_with_default_settings.
@Test
public void provide_client_with_default_settings() {
GlobalProperties settings = new GlobalProperties(new HashMap<>());
ScannerWsClient client = underTest.provide(settings, env, new GlobalMode(new GlobalProperties(Collections.emptyMap())));
assertThat(client).isNotNull();
assertThat(client.baseUrl()).isEqualTo("http://localhost:9000/");
HttpConnector httpConnector = (HttpConnector) client.wsConnector();
assertThat(httpConnector.baseUrl()).isEqualTo("http://localhost:9000/");
assertThat(httpConnector.okHttpClient().proxy()).isNull();
assertThat(httpConnector.okHttpClient().connectTimeoutMillis()).isEqualTo(5_000);
assertThat(httpConnector.okHttpClient().readTimeoutMillis()).isEqualTo(60_000);
}
use of org.sonarqube.ws.client.HttpConnector in project sonarqube by SonarSource.
the class ScannerWsClientProviderTest method provide_client_with_custom_settings.
@Test
public void provide_client_with_custom_settings() {
Map<String, String> props = new HashMap<>();
props.put("sonar.host.url", "https://here/sonarqube");
props.put("sonar.login", "theLogin");
props.put("sonar.password", "thePassword");
props.put("sonar.ws.timeout", "42");
GlobalProperties settings = new GlobalProperties(props);
ScannerWsClient client = underTest.provide(settings, env, new GlobalMode(new GlobalProperties(Collections.emptyMap())));
assertThat(client).isNotNull();
HttpConnector httpConnector = (HttpConnector) client.wsConnector();
assertThat(httpConnector.baseUrl()).isEqualTo("https://here/sonarqube/");
assertThat(httpConnector.okHttpClient().proxy()).isNull();
}
use of org.sonarqube.ws.client.HttpConnector in project sonar-scanner-jenkins by SonarSource.
the class HttpClient method getHttp.
public String getHttp(String url, @Nullable String token) {
String baseUrl = StringUtils.substringBeforeLast(url, "/");
String path = StringUtils.substringAfterLast(url, "/");
HttpConnector httpConnector = HttpConnector.newBuilder().userAgent("Scanner for Jenkins").url(baseUrl).credentials(token, null).build();
WsResponse response = httpConnector.call(new GetRequest(path));
response.failIfNotSuccessful();
return response.content();
}
Aggregations