Search in sources :

Example 1 with GetSecurityHotspotRequestParams

use of org.sonarsource.sonarlint.core.serverapi.hotspot.GetSecurityHotspotRequestParams in project sonarlint-core by SonarSource.

the class ConnectedModeTest method canFetchHotspot.

@Test
public void canFetchHotspot() throws InvalidProtocolBufferException {
    assumeTrue("SonarQube should support opening security hotspots", ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(8, 6));
    analyzeMavenProject(PROJECT_KEY_JAVA_HOTSPOT);
    var securityHotspotsService = new ServerApi(endpointParams(ORCHESTRATOR), sqHttpClient()).hotspot();
    var remoteHotspot = securityHotspotsService.fetch(new GetSecurityHotspotRequestParams(getFirstHotspotKey(PROJECT_KEY_JAVA_HOTSPOT), PROJECT_KEY_JAVA_HOTSPOT));
    assertThat(remoteHotspot).isNotEmpty();
    var actualHotspot = remoteHotspot.get();
    assertThat(actualHotspot.message).isEqualTo("Make sure using this hardcoded IP address is safe here.");
    assertThat(actualHotspot.filePath).isEqualTo("src/main/java/foo/Foo.java");
    assertThat(actualHotspot.textRange).isEqualToComparingFieldByField(new TextRange(5, 14, 5, 29));
    assertThat(actualHotspot.author).isEmpty();
    assertThat(actualHotspot.status).isEqualTo(ServerHotspot.Status.TO_REVIEW);
    assertThat(actualHotspot.resolution).isNull();
    assertThat(actualHotspot.rule.key).isEqualTo("java:S1313");
}
Also used : GetSecurityHotspotRequestParams(org.sonarsource.sonarlint.core.serverapi.hotspot.GetSecurityHotspotRequestParams) ServerApi(org.sonarsource.sonarlint.core.serverapi.ServerApi) TextRange(org.sonarsource.sonarlint.core.analysis.api.TextRange) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 TextRange (org.sonarsource.sonarlint.core.analysis.api.TextRange)1 ServerApi (org.sonarsource.sonarlint.core.serverapi.ServerApi)1 GetSecurityHotspotRequestParams (org.sonarsource.sonarlint.core.serverapi.hotspot.GetSecurityHotspotRequestParams)1