-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLVS-1818 Upgrade SLCore to 10.14.0.80189 and adapt RPC changes for SQC multi-region #5985
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2b0afa6
SLVS-1818 Upgrade SLCore to 10.14.0.80189 and adapt RPC changes for S…
georgii-borovinskikh-sonarsource 92bcf82
Fix tests
georgii-borovinskikh-sonarsource 8eac38e
Update ListUserOrganizationsParams
georgii-borovinskikh-sonarsource 432cb09
fix test
georgii-borovinskikh-sonarsource e4cad85
upd
georgii-borovinskikh-sonarsource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,6 +38,7 @@ namespace SonarLint.VisualStudio.ConnectedMode.UnitTests; | |||||
[TestClass] | ||||||
public class SlCoreConnectionAdapterTests | ||||||
{ | ||||||
private const string token = "token123"; | ||||||
private static readonly TokenAuthCredentials ValidTokenAuth = new ("I_AM_JUST_A_TOKEN".ToSecureString()); | ||||||
private readonly ServerConnection.SonarQube sonarQubeConnection = new(new Uri("http://localhost:9000/"), new ServerConnectionSettings(true), ValidTokenAuth); | ||||||
private readonly ServerConnection.SonarCloud sonarCloudConnection = new("myOrg", new ServerConnectionSettings(true), ValidTokenAuth); | ||||||
|
@@ -176,7 +177,7 @@ public async Task GetOrganizationsAsync_TokenIsProvided_CallsSlCoreListUserOrgan | |||||
|
||||||
await testSubject.GetOrganizationsAsync(new TokenCredentialsModel(token.CreateSecureString())); | ||||||
|
||||||
await connectionConfigurationSlCoreService.Received(1).ListUserOrganizationsAsync(Arg.Is<ListUserOrganizationsParams>(x=> IsExpectedCredentials(x.credentials, token))); | ||||||
await connectionConfigurationSlCoreService.Received(1).ListUserOrganizationsAsync(Arg.Is<ListUserOrganizationsParams>(x=> IsExpectedCredentials(x.credentials, token) && x.region == SonarCloudRegion.EU)); | ||||||
} | ||||||
|
||||||
[TestMethod] | ||||||
|
@@ -192,10 +193,10 @@ public async Task GetOrganizationsAsync_CredentialsIsNull_ReturnsFailedResponseA | |||||
[TestMethod] | ||||||
public async Task GetOrganizationsAsync_NoOrganizationExists_ReturnsSuccessResponseAndEmptyOrganizations() | ||||||
{ | ||||||
connectionConfigurationSlCoreService.ListUserOrganizationsAsync(Arg.Any<ListUserOrganizationsParams>()) | ||||||
connectionConfigurationSlCoreService.ListUserOrganizationsAsync(Arg.Is<ListUserOrganizationsParams>(x => x.credentials.Left.token == token && x.region == SonarCloudRegion.EU)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.Returns(new ListUserOrganizationsResponse([])); | ||||||
|
||||||
var response = await testSubject.GetOrganizationsAsync(new TokenCredentialsModel("token".CreateSecureString())); | ||||||
var response = await testSubject.GetOrganizationsAsync(new TokenCredentialsModel(token.CreateSecureString())); | ||||||
|
||||||
response.Success.Should().BeTrue(); | ||||||
response.ResponseData.Should().BeEmpty(); | ||||||
|
@@ -205,10 +206,11 @@ public async Task GetOrganizationsAsync_NoOrganizationExists_ReturnsSuccessRespo | |||||
public async Task GetOrganizationsAsync_OrganizationExists_ReturnsSuccessResponseAndMappedOrganizations() | ||||||
{ | ||||||
List<OrganizationDto> serverOrganizations = [new OrganizationDto("key", "name", "desc"), new OrganizationDto("key2", "name2", "desc2")]; | ||||||
connectionConfigurationSlCoreService.ListUserOrganizationsAsync(Arg.Any<ListUserOrganizationsParams>()) | ||||||
|
||||||
connectionConfigurationSlCoreService.ListUserOrganizationsAsync(Arg.Is<ListUserOrganizationsParams>(x => x.credentials.Left.token == token && x.region == SonarCloudRegion.EU)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.Returns(new ListUserOrganizationsResponse(serverOrganizations)); | ||||||
|
||||||
var response = await testSubject.GetOrganizationsAsync(new TokenCredentialsModel("token".CreateSecureString())); | ||||||
var response = await testSubject.GetOrganizationsAsync(new TokenCredentialsModel(token.CreateSecureString())); | ||||||
|
||||||
response.Success.Should().BeTrue(); | ||||||
response.ResponseData.Should().BeEquivalentTo([ | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ public void Serialize_WithSonarCloudToken_AsExpected() | |
"organization": "my-org", | ||
"credentials": { | ||
"token": "super-secret-token" | ||
} | ||
}, | ||
"region": "EU" | ||
} | ||
} | ||
"""; | ||
|
@@ -131,7 +132,8 @@ public void Serialize_WithSonarCloudUsernamePassword_AsExpected() | |
"credentials": { | ||
"username": "[email protected]", | ||
"password": "betwEEn-me-and-U" | ||
} | ||
}, | ||
"region": "EU" | ||
} | ||
} | ||
"""; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,8 @@ public void Serialize_WithSonarCloudToken_AsExpected() | |
"organization": "my-org", | ||
"credentials": { | ||
"token": "super-secret-token" | ||
} | ||
}, | ||
"region": "EU" | ||
}, | ||
"projectKeys": [ | ||
"project-key-1", | ||
|
@@ -149,7 +150,8 @@ public void Serialize_WithSonarCloudUsernamePassword_AsExpected() | |
"credentials": { | ||
"username": "[email protected]", | ||
"password": "betwEEn-me-and-U" | ||
} | ||
}, | ||
"region": "EU" | ||
}, | ||
"projectKeys": [ | ||
"project-key-1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/SLCore.UnitTests/Service/Connection/Models/SonarCloudConnectionConfigurationDtoTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* SonarLint for Visual Studio | ||
* Copyright (C) 2016-2025 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
using Newtonsoft.Json; | ||
using SonarLint.VisualStudio.SLCore.Service.Connection.Models; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Connection.Models; | ||
|
||
[TestClass] | ||
public class SonarCloudConnectionConfigurationDtoTests | ||
{ | ||
|
||
[DataRow("id", true, "org", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "org", | ||
"region": "EU", | ||
"connectionId": "id", | ||
"disableNotification": true | ||
} | ||
""")] | ||
[DataRow("id id id", true, "org", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "org", | ||
"region": "EU", | ||
"connectionId": "id id id", | ||
"disableNotification": true | ||
} | ||
""")] | ||
[DataRow("id", false, "org", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "org", | ||
"region": "EU", | ||
"connectionId": "id", | ||
"disableNotification": false | ||
} | ||
""")] | ||
[DataRow("id", true, "org org org", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "org org org", | ||
"region": "EU", | ||
"connectionId": "id", | ||
"disableNotification": true | ||
} | ||
""")] | ||
[DataRow("id", true, "org", SonarCloudRegion.US, """ | ||
{ | ||
"organization": "org", | ||
"region": "US", | ||
"connectionId": "id", | ||
"disableNotification": true | ||
} | ||
""")] | ||
[DataTestMethod] | ||
public void Serialize_AsExpected(string id, bool notificationEnabled, string organization, SonarCloudRegion region, string expected) => | ||
JsonConvert.SerializeObject(new SonarCloudConnectionConfigurationDto(id, notificationEnabled, organization, region), Formatting.Indented).Should().Be(expected); | ||
} |
75 changes: 75 additions & 0 deletions
75
src/SLCore.UnitTests/Service/Connection/Models/TransientSonarCloudConnectionDtoTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* SonarLint for Visual Studio | ||
* Copyright (C) 2016-2025 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
using Newtonsoft.Json; | ||
using SonarLint.VisualStudio.SLCore.Common.Models; | ||
using SonarLint.VisualStudio.SLCore.Service.Connection.Models; | ||
|
||
namespace SonarLint.VisualStudio.SLCore.UnitTests.Service.Connection.Models; | ||
|
||
[TestClass] | ||
public class TransientSonarCloudConnectionDtoTests | ||
{ | ||
[DataRow("my org", SonarCloudRegion.US, """ | ||
{ | ||
"organization": "my org", | ||
"credentials": { | ||
"token": "abctoken" | ||
}, | ||
"region": "US" | ||
} | ||
""")] | ||
[DataRow("my org two", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "my org two", | ||
"credentials": { | ||
"token": "abctoken" | ||
}, | ||
"region": "EU" | ||
} | ||
""")] | ||
[DataTestMethod] | ||
public void Serialized_Token_AsExpected(string organization, SonarCloudRegion region, string expected) => | ||
JsonConvert.SerializeObject(new TransientSonarCloudConnectionDto(organization, new TokenDto("abctoken"), region), Formatting.Indented).Should().Be(expected); | ||
|
||
[DataRow("my org", SonarCloudRegion.US, """ | ||
{ | ||
"organization": "my org", | ||
"credentials": { | ||
"username": "usr", | ||
"password": "pwd" | ||
}, | ||
"region": "US" | ||
} | ||
""")] | ||
[DataRow("my org two", SonarCloudRegion.EU, """ | ||
{ | ||
"organization": "my org two", | ||
"credentials": { | ||
"username": "usr", | ||
"password": "pwd" | ||
}, | ||
"region": "EU" | ||
} | ||
""")] | ||
[DataTestMethod] | ||
public void Serialized_UsernameAndPassword_AsExpected(string organization, SonarCloudRegion region, string expected) => | ||
JsonConvert.SerializeObject(new TransientSonarCloudConnectionDto(organization, new UsernamePasswordDto("usr", "pwd"), region), Formatting.Indented).Should().Be(expected); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a helper method to check the region, i.e. IsExpectedRegion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see the point of creating a method to replace one equals expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this occurs in multiple places. And if something changes, it would be easier to just modify one helper method instead of multiple places.