use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class AuthenticationCheckerTest method test_authentication_ko.
@Test
public void test_authentication_ko() {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/authentication/validate?format=json", "{\"valid\": false}");
AuthenticationChecker checker = new AuthenticationChecker(wsClient);
ValidationResult validationResult = checker.validateCredentials();
assertThat(validationResult.success()).isFalse();
assertThat(validationResult.message()).isEqualTo("Authentication failed");
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method no_fallback_if_not_404.
@Test
public void no_fallback_if_not_404() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMock();
WsClientTestUtils.addFailedResponse(wsClient, "api/system/status", HttpURLConnection.HTTP_UNAUTHORIZED, "Not authorized");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
try {
checker.checkVersionAndStatus();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).isExactlyInstanceOf(IllegalStateException.class).hasMessage("Not authorized. Please check server credentials.");
}
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method incompatibleVersion.
@Test
public void incompatibleVersion() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/system/status", "{\"id\": \"20160308094653\",\"version\": \"4.5\",\"status\": \"UP\"}");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
ValidationResult validateStatusAndVersion = checker.validateStatusAndVersion();
assertThat(validateStatusAndVersion.success()).isFalse();
assertThat(validateStatusAndVersion.message()).isEqualTo("SonarQube server has version 4.5. Version should be greater or equal to 5.6");
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method failWhenServerNotReady.
@Test
public void failWhenServerNotReady() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/system/status", "{\"id\": \"20160308094653\",\"version\": \"5.5-SNAPSHOT\",\"status\": \"DOWN\"}");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
try {
checker.checkVersionAndStatus();
fail("Expected exception");
} catch (Exception e) {
assertThat(e).hasMessage("Server not ready (DOWN)");
}
}
use of org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusCheckerTest method serverNotReady.
@Test
public void serverNotReady() throws Exception {
SonarLintWsClient wsClient = WsClientTestUtils.createMockWithResponse("api/system/status", "{\"id\": \"20160308094653\",\"version\": \"5.5-SNAPSHOT\",\"status\": \"DOWN\"}");
ServerVersionAndStatusChecker checker = new ServerVersionAndStatusChecker(wsClient);
ValidationResult validateStatusAndVersion = checker.validateStatusAndVersion();
assertThat(validateStatusAndVersion.success()).isFalse();
assertThat(validateStatusAndVersion.message()).isEqualTo("Server not ready (DOWN)");
}
Aggregations