diff --git a/pom.xml b/pom.xml index 1d0544f42..afe29742d 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 17 - 10.10.0.79500 + 10.10.0.79572 1.6.10 diff --git a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java index 0604a7fd6..39bec8690 100644 --- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java +++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java @@ -222,9 +222,6 @@ public void mockSonarQube() { Issues.TaintVulnerabilityPullQueryTimestamp.newBuilder() .setQueryTimestamp(CURRENT_TIME) .build()); - mockWebServerExtension.addProtobufResponse( - "/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=inFolderToo.py&branch=master&ps=500&p=1", - Hotspots.SearchWsResponse.newBuilder().build()); mockWebServerExtension.addProtobufResponse( "/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=analysisConnected_find_hotspot.py&branch=master&ps=500&p=1", Hotspots.SearchWsResponse.newBuilder().build()); @@ -237,24 +234,6 @@ public void mockSonarQube() { "/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST, Issues.IssuesPullQueryTimestamp.newBuilder() .setQueryTimestamp(CURRENT_TIME) - .build(), - Issues.IssueLite.newBuilder() - .setKey("xyz") - .setRuleKey(PYTHON_S1481) - .setType(Common.RuleType.CODE_SMELL) - .setUserSeverity(Common.Severity.BLOCKER) - .setMainLocation(Issues.Location.newBuilder() - .setFilePath("inFolderToo.py") - .setMessage("Remove the unused local variable \"toto\".") - .setTextRange(Issues.TextRange.newBuilder() - .setStartLine(1) - .setStartLineOffset(2) - .setEndLine(1) - .setEndLineOffset(6) - .setHash("f71dbe52628a3f83a77ab494817525c6") - .build()) - .build()) - .setClosed(false) .build()); client.clearHotspotsAndIssuesAndConfigScopeReadiness(); } @@ -395,6 +374,9 @@ void analysisConnected_find_tracked_hotspot_after_sq_10_1() { mockWebServerExtension.addProtobufResponse( "/api/hotspots/search.protobuf?projectKey=myProject&files=hotspot.py&branch=master&ps=500&p=1", Hotspots.SearchWsResponse.newBuilder().build()); + mockWebServerExtension.addProtobufResponse( + "/api/hotspots/search.protobuf?projectKey=myProject&files=analysisConnected_no_matching_server_issues.py&branch=master&ps=500&p=1", + Hotspots.SearchWsResponse.newBuilder().build()); mockWebServerExtension.addProtobufResponse( "/api/rules/show.protobuf?key=python:S1313", Rules.ShowResponse.newBuilder() @@ -564,7 +546,7 @@ void analysisConnected_no_matching_server_issues() { .build()); addConfigScope(folder1BaseDir.toUri().toString()); - var uriInFolder = folder1BaseDir.resolve("inFolder.py").toUri().toString(); + var uriInFolder = folder1BaseDir.resolve("hotspot.py").toUri().toString(); didOpen(uriInFolder, "python", "def foo():\n toto = 0\n plouf = 0\n"); awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uriInFolder)) @@ -614,11 +596,37 @@ void analysisConnected_matching_server_issues() throws Exception { .setParameter("9.2") .build()) .build()); + mockWebServerExtension.addProtobufResponse( + "/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=analysisConnected_matching_server_issues.py&branch=master&ps=500&p=1", + Hotspots.SearchWsResponse.newBuilder().build()); + mockWebServerExtension.addProtobufResponseDelimited( + "/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST, + Issues.IssuesPullQueryTimestamp.newBuilder() + .setQueryTimestamp(CURRENT_TIME) + .build(), + Issues.IssueLite.newBuilder() + .setKey("xyz") + .setRuleKey(PYTHON_S1481) + .setType(Common.RuleType.CODE_SMELL) + .setUserSeverity(Common.Severity.BLOCKER) + .setMainLocation(Issues.Location.newBuilder() + .setFilePath("analysisConnected_matching_server_issues.py") + .setMessage("Remove the unused local variable \"toto\".") + .setTextRange(Issues.TextRange.newBuilder() + .setStartLine(1) + .setStartLineOffset(2) + .setEndLine(1) + .setEndLineOffset(6) + .setHash("f71dbe52628a3f83a77ab494817525c6") + .build()) + .build()) + .setClosed(false) + .build()); addConfigScope(folder1BaseDir.toUri().toString()); lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "master")); - var uriInFolder = folder1BaseDir.resolve("inFolderToo.py").toUri().toString(); + var uriInFolder = folder1BaseDir.resolve("analysisConnected_matching_server_issues.py").toUri().toString(); didOpen(uriInFolder, "python", "def foo():\n toto = 0\n plouf = 0\n"); awaitUntilAsserted(() -> assertThat(client.getDiagnostics(uriInFolder)) @@ -814,19 +822,18 @@ void checkLocalDetectionSupportedNotBound() throws ExecutionException, Interrupt @Test void shouldChangeIssueStatus() { - var issueKey = "xyz"; - mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(200)); + mockWebServerExtension.addResponse("/api/issues/anticipated_transitions?projectKey=myProject", new MockResponse().setResponseCode(200)); mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(200)); mockWebServerExtension.addProtobufResponse( - "/api/hotspots/search.protobuf?projectKey=myProject&files=inFolderToo.py&branch=master&ps=500&p=1", + "/api/hotspots/search.protobuf?projectKey=myProject&files=hotspot.py&branch=master&ps=500&p=1", Hotspots.SearchWsResponse.newBuilder().build()); addConfigScope(folder1BaseDir.toUri().toString()); awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue()); lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "some/branch/name")); - var fileUri = folder1BaseDir.resolve("inFolderToo.py").toUri().toString(); + var fileUri = folder1BaseDir.resolve("hotspot.py").toUri().toString(); var content = "def foo():\n toto = 0\n plouf = 0\n"; didOpen(fileUri, "python", content); @@ -837,6 +844,8 @@ void shouldChangeIssueStatus() { tuple(1, 2, 1, 6, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"toto\".", DiagnosticSeverity.Warning), tuple(2, 2, 2, 7, PYTHON_S1481, "sonarqube", "Remove the unused local variable \"plouf\".", DiagnosticSeverity.Warning))); + var issueKey = ((JsonObject) client.getDiagnostics(fileUri).get(0).getData()).get("entryKey").getAsString(); + lsProxy.changeIssueStatus(new SonarLintExtendedLanguageServer.ChangeIssueStatusParams(folder1BaseDir.toUri().toString(), issueKey, "False positive", fileUri, "clever comment", false)); @@ -856,14 +865,14 @@ void shouldNotChangeIssueStatus() { mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(400)); mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(400)); mockWebServerExtension.addProtobufResponse( - "/api/hotspots/search.protobuf?projectKey=myProject&files=inFolderToo.py&branch=master&ps=500&p=1", + "/api/hotspots/search.protobuf?projectKey=myProject&files=shouldNotChangeIssueStatus.py&branch=master&ps=500&p=1", Hotspots.SearchWsResponse.newBuilder().build()); addConfigScope(folder1BaseDir.toUri().toString()); awaitUntilAsserted(() -> assertThat(client.logs.stream().anyMatch(messageParams -> messageParams.getMessage().contains("Synchronizing project branches for project 'myProject'"))).isTrue()); lsProxy.didLocalBranchNameChange(new SonarLintExtendedLanguageServer.DidLocalBranchNameChangeParams(folder1BaseDir.toUri().toString(), "some/branch/name")); - var fileUri = folder1BaseDir.resolve("inFolderToo.py").toUri().toString(); + var fileUri = folder1BaseDir.resolve("shouldNotChangeIssueStatus.py").toUri().toString(); var content = "def foo():\n toto = 0\n plouf = 0\n"; didOpen(fileUri, "python", content); @@ -1179,6 +1188,32 @@ void change_issue_status_permission_check() throws ExecutionException, Interrupt .build()) .build()) .build()); + mockWebServerExtension.addProtobufResponse( + "/api/hotspots/search.protobuf?projectKey=" + PROJECT_KEY + "&files=change_issue_status_permission_check.py&branch=master&ps=500&p=1", + Hotspots.SearchWsResponse.newBuilder().build()); + mockWebServerExtension.addProtobufResponseDelimited( + "/api/issues/pull?projectKey=myProject&branchName=master&languages=" + LANGUAGES_LIST, + Issues.IssuesPullQueryTimestamp.newBuilder() + .setQueryTimestamp(CURRENT_TIME) + .build(), + Issues.IssueLite.newBuilder() + .setKey("xyz") + .setRuleKey(PYTHON_S1481) + .setType(Common.RuleType.CODE_SMELL) + .setUserSeverity(Common.Severity.BLOCKER) + .setMainLocation(Issues.Location.newBuilder() + .setFilePath("change_issue_status_permission_check.py") + .setMessage("Remove the unused local variable \"toto\".") + .setTextRange(Issues.TextRange.newBuilder() + .setStartLine(1) + .setStartLineOffset(2) + .setEndLine(1) + .setEndLineOffset(6) + .setHash("f71dbe52628a3f83a77ab494817525c6") + .build()) + .build()) + .setClosed(false) + .build()); mockWebServerExtension.addResponse("/api/issues/do_transition", new MockResponse().setResponseCode(200)); mockWebServerExtension.addResponse("/api/issues/add_comment", new MockResponse().setResponseCode(200));