use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class ForceAuthenticationTest method batch_ws_does_not_require_authentication.
@Test
public void batch_ws_does_not_require_authentication() throws Exception {
WsResponse batchIndex = anonymousClient.wsConnector().call(new GetRequest("/batch/index")).failIfNotSuccessful();
String batchIndexContent = batchIndex.content();
assertThat(batchIndexContent).isNotEmpty();
String jar = batchIndexContent.split("\\|")[0];
assertThat(anonymousClient.wsConnector().call(new GetRequest("/batch/file").setParam("name", jar)).failIfNotSuccessful().contentStream()).isNotNull();
// As sonar-runner is still using deprecated /batch/key, we have to also verify it
assertThat(anonymousClient.wsConnector().call(new GetRequest("/batch/" + jar)).failIfNotSuccessful().contentStream()).isNotNull();
}
use of org.sonarqube.ws.client.GetRequest in project sonarqube by SonarSource.
the class LocalAuthenticationTest method basic_authentication_based_on_token.
@Test
public void basic_authentication_based_on_token() {
String tokenName = "Validate token based authentication";
WsUserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateWsRequest().setLogin(LOGIN).setName(tokenName));
WsClient wsClient = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder().url(ORCHESTRATOR.getServer().getUrl()).token(generateWsResponse.getToken()).build());
WsResponse response = wsClient.wsConnector().call(new GetRequest("api/authentication/validate"));
assertThat(response.content()).isEqualTo("{\"valid\":true}");
WsUserTokens.SearchWsResponse searchResponse = userTokensWsClient.search(new SearchWsRequest().setLogin(LOGIN));
assertThat(searchResponse.getUserTokensCount()).isEqualTo(1);
userTokensWsClient.revoke(new RevokeWsRequest().setLogin(LOGIN).setName(tokenName));
searchResponse = userTokensWsClient.search(new SearchWsRequest().setLogin(LOGIN));
assertThat(searchResponse.getUserTokensCount()).isEqualTo(0);
}
use of org.sonarqube.ws.client.GetRequest 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.GetRequest 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.GetRequest 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");
}
Aggregations