diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/ServerApiProvider.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/ServerApiProvider.java index c8434cedab..13ca25f112 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/ServerApiProvider.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/ServerApiProvider.java @@ -83,6 +83,9 @@ public Optional getServerApi(String connectionId) { } private boolean checkIfBearerIsSupported(EndpointParams params) { + if (params.isSonarCloud()) { + return true; + } var httpClient = awareHttpClientProvider.getHttpClient(); var cancelMonitor = new SonarLintCancelMonitor(); var serverApi = new ServerApi(params, httpClient); diff --git a/backend/core/src/test/java/org/sonarsource/sonarlint/core/ServerApiProviderTests.java b/backend/core/src/test/java/org/sonarsource/sonarlint/core/ServerApiProviderTests.java index 599fa03e73..599ec9dee1 100644 --- a/backend/core/src/test/java/org/sonarsource/sonarlint/core/ServerApiProviderTests.java +++ b/backend/core/src/test/java/org/sonarsource/sonarlint/core/ServerApiProviderTests.java @@ -67,6 +67,11 @@ void getServerApi_for_sonarqube() { void getServerApi_for_sonarqube_notConnected() { var httpClient = mock(HttpClient.class); when(httpClientProvider.getHttpClientWithPreemptiveAuth("token", false)).thenReturn(httpClient); + when(awareHttpClientProvider.getHttpClient()).thenReturn(httpClient); + var httpResponse = mock(HttpClient.Response.class); + when(httpResponse.isSuccessful()).thenReturn(true); + when(httpResponse.bodyAsString()).thenReturn("{\"id\": \"20160308094653\",\"version\": \"10.0\",\"status\": \"UP\"}"); + when(httpClient.getAsync("sq_notConnected/api/system/status")).thenReturn(CompletableFuture.completedFuture(httpResponse)); var serverApi = underTest.getServerApi("sq_notConnected", null, "token"); assertThat(serverApi.isSonarCloud()).isFalse();