use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class EventTest method old_ws_events_does_not_allow_creating_events_on_modules.
@Test
public void old_ws_events_does_not_allow_creating_events_on_modules() {
SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample"));
orchestrator.executeBuild(sampleProject);
WsConnector wsConnector = ItUtils.newAdminWsClient(orchestrator).wsConnector();
WsResponse response = wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample", "bar"));
assertThat(response.code()).isEqualTo(200);
assertThat(wsConnector.call(newCreateEventRequest("com.sonarsource.it.samples:multi-modules-sample:module_a", "bar")).code()).isEqualTo(400);
}
use of org.sonarqube.ws.client.WsResponse in project sonarqube by SonarSource.
the class UserRule method getUsers.
public Users getUsers() {
WsResponse response = adminWsClient().wsConnector().call(new GetRequest("api/users/search"));
assertThat(response.code()).isEqualTo(200);
return Users.parse(response.content());
}
use of org.sonarqube.ws.client.WsResponse 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.WsResponse in project sonarqube by SonarSource.
the class ForceAuthenticationTest method verifyPathRequiresAuthentication.
private void verifyPathRequiresAuthentication(String path, WsRequest.Method method) {
assertThat(call(anonymousClient, path, method).code()).isEqualTo(401);
WsResponse wsResponse = call(adminWsClient, path, method);
assertThat(wsResponse.isSuccessful()).as("code is %s on path %s", wsResponse.code(), path).isTrue();
}
use of org.sonarqube.ws.client.WsResponse 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);
}
Aggregations