Search in sources :

Example 6 with WsRequest

use of org.sonarqube.ws.client.WsRequest in project sonarqube by SonarSource.

the class ScannerWsClientTest method fail_if_credentials_are_not_valid.

@Test
public void fail_if_credentials_are_not_valid() throws Exception {
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Not authorized. Please check the properties sonar.login and sonar.password.");
    WsRequest request = newRequest();
    WsResponse response = newResponse().setCode(401);
    when(wsClient.wsConnector().call(request)).thenReturn(response);
    new ScannerWsClient(wsClient, /* credentials are configured */
    true, new GlobalMode(new GlobalProperties(Collections.emptyMap()))).call(request);
}
Also used : WsRequest(org.sonarqube.ws.client.WsRequest) WsResponse(org.sonarqube.ws.client.WsResponse) MockWsResponse(org.sonarqube.ws.client.MockWsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 WsRequest (org.sonarqube.ws.client.WsRequest)6 WsResponse (org.sonarqube.ws.client.WsResponse)6 MockWsResponse (org.sonarqube.ws.client.MockWsResponse)5 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 TempFolder (org.sonar.api.utils.TempFolder)1