Skip to content

Commit

Permalink
Changed deprecated projectKey parameters while fetching Quality Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-caro-sonarsource committed Oct 22, 2020
1 parent ee96e8e commit 58c3c63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public void Ctor_NullLogger_Throws()
[TestMethod]
public void LogWSOnError()
{
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] = "trash";
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] = "trash";
try
{
_ = this.ws.TryGetQualityProfile("foo bar", null, null, "cs").Result;
Assert.Fail("Exception expected");
}
catch (Exception)
{
this.logger.AssertErrorLogged("Failed to request and parse 'http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar': Error parsing boolean value. Path '', line 1, position 2.");
this.logger.AssertErrorLogged("Failed to request and parse 'http://myhost:222/api/qualityprofiles/search?project=foo+bar': Error parsing boolean value. Path '', line 1, position 2.");
}
}

Expand All @@ -101,11 +101,11 @@ public void TryGetQualityProfile64()
this.downloader.Pages["http://myhost:222/api/server/version"] = "6.4";
Tuple<bool, string> result;

this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] =
"{ profiles: [{\"key\":\"profile1k\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AaBranch"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AaBranch"] =
"{ profiles: [{\"key\":\"profile2k\",\"name\":\"profile2\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AanotherBranch"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AanotherBranch"] =
"{ profiles: [{\"key\":\"profile3k\",\"name\":\"profile3\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";

// main
Expand All @@ -123,7 +123,7 @@ public void TryGetQualityProfile64()
result.Item2.Should().Be("profile3k");

// with organizations
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar&organization=my+org"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar&organization=my+org"] =
"{ profiles: [{\"key\":\"profileOrganization\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
result = this.ws.TryGetQualityProfile("foo bar", null, "my org", "cs").Result;
result.Item1.Should().BeTrue();
Expand All @@ -144,14 +144,14 @@ public void TryGetQualityProfile64()
result.Item2.Should().Be("profileOrganizationDefault");

// no cs in list of profiles
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=java+foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=java+foo+bar"] =
"{ profiles: [{\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs").Result;
result.Item1.Should().BeFalse();
result.Item2.Should().BeNull();

// empty
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=empty+foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=empty+foo+bar"] =
"{ profiles: []}";
result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs").Result;
result.Item1.Should().BeFalse();
Expand All @@ -163,11 +163,11 @@ public void TryGetQualityProfile56()
{
Tuple<bool, string> result;

this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar"] =
"{ profiles: [{\"key\":\"profile1k\",\"name\":\"profile1\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AaBranch"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AaBranch"] =
"{ profiles: [{\"key\":\"profile2k\",\"name\":\"profile2\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=foo+bar%3AanotherBranch"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=foo+bar%3AanotherBranch"] =
"{ profiles: [{\"key\":\"profile3k\",\"name\":\"profile3\",\"language\":\"cs\"}, {\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";

// main
Expand Down Expand Up @@ -202,14 +202,14 @@ public void TryGetQualityProfile56()
result.Item2.Should().Be("profileDefault");

// no cs in list of profiles
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=java+foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=java+foo+bar"] =
"{ profiles: [{\"key\":\"profile4k\",\"name\":\"profile4\",\"language\":\"java\"}]}";
result = this.ws.TryGetQualityProfile("java foo bar", null, null, "cs").Result;
result.Item1.Should().BeFalse();
result.Item2.Should().BeNull();

// empty
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?projectKey=empty+foo+bar"] =
this.downloader.Pages["http://myhost:222/api/qualityprofiles/search?project=empty+foo+bar"] =
"{ profiles: []}";
result = this.ws.TryGetQualityProfile("empty foo bar", null, null, "cs").Result;
result.Item1.Should().BeFalse();
Expand Down
2 changes: 1 addition & 1 deletion src/SonarScanner.MSBuild.PreProcessor/SonarWebService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task<Tuple<bool, string>> TryGetQualityProfile(string projectKey, s
{
var projectId = GetProjectIdentifier(projectKey, projectBranch);

var ws = await AddOrganization(GetUrl("/api/qualityprofiles/search?projectKey={0}", projectId), organization);
var ws = await AddOrganization(GetUrl("/api/qualityprofiles/search?project={0}", projectId), organization);
this.logger.LogDebug(Resources.MSG_FetchingQualityProfile, projectId, ws);

var qualityProfileKey = await DoLogExceptions(async () =>
Expand Down

0 comments on commit 58c3c63

Please sign in to comment.