use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class LocalAuthenticationTest method basic_authentication_based_on_login_and_password.
@Test
public void basic_authentication_based_on_login_and_password() {
String userId = UUID.randomUUID().toString();
String login = format("login-%s", userId);
String name = format("name-%s", userId);
String password = "!ascii-only:-)@";
userRule.createUser(login, name, null, password);
// authenticate
WsClient wsClient = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder().url(ORCHESTRATOR.getServer().getUrl()).credentials(login, password).build());
WsResponse response = wsClient.wsConnector().call(new GetRequest("api/authentication/validate"));
assertThat(response.content()).isEqualTo("{\"valid\":true}");
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class OAuth2IdentityProviderTest method authenticateWithFakeAuthProvider.
private void authenticateWithFakeAuthProvider() {
WsResponse response = adminWsClient.wsConnector().call(new GetRequest(("/sessions/init/" + FAKE_PROVIDER_KEY)));
assertThat(response.code()).isEqualTo(200);
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class RoutesTest method redirect_profiles_export_to_api_qualityprofiles_export.
@Test
public void redirect_profiles_export_to_api_qualityprofiles_export() {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("profiles/export?language=xoo&format=XooFakeExporter"));
assertThat(response.isSuccessful()).isTrue();
assertThat(response.requestUrl()).endsWith("/api/qualityprofiles/export?language=xoo&format=XooFakeExporter");
assertThat(response.content()).isEqualTo("xoo -> Basic -> 1");
// Check 'name' parameter is taken into account
assertThat(newWsClient(orchestrator).wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0");
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class WsLocalCallTest method gets_protobuf.
@Test
public void gets_protobuf() {
WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("local_ws_call/protobuf_data"));
assertThat(response.isSuccessful()).isTrue();
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class ScannerWsClient method call.
/**
* If an exception is not thrown, the response needs to be closed by either calling close() directly, or closing the
* body content's stream/reader.
* @throws IllegalStateException if the request could not be executed due to
* a connectivity problem or timeout. Because networks can
* fail during an exchange, it is possible that the remote server
* accepted the request before the failure
* @throws HttpException if the response code is not in range [200..300)
*/
public WsResponse call(WsRequest request) {
Preconditions.checkState(!globalMode.isMediumTest(), "No WS call should be made in medium test mode");
Profiler profiler = Profiler.createIfDebug(LOG).start();
WsResponse response = target.wsConnector().call(request);
profiler.stopDebug(format("%s %d %s", request.getMethod(), response.code(), response.requestUrl()));
failIfUnauthorized(response);
return response;
}
Aggregations