Skip to content

Commit

Permalink
SLCORE-400 URL encode quality profile parameter for rules API
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-urruty-sonarsource committed Sep 19, 2022
1 parent b0b6415 commit d152262
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Collection<ServerActiveRule> getAllActiveRules(String qualityProfileKey,
private String getSearchByQualityProfileUrl(String qualityProfileKey) {
var builder = new StringBuilder();
builder.append("/api/rules/search.protobuf?qprofile=");
builder.append(qualityProfileKey);
builder.append(UrlUtils.urlEncode(qualityProfileKey));
serverApiHelper.getOrganizationKey().ifPresent(org -> builder.append("&organization=").append(UrlUtils.urlEncode(org)));
builder.append("&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY&s=key");
return builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void should_get_rule_from_organization() throws ExecutionException, InterruptedE
@Test
void should_get_active_rules_of_a_given_quality_profile() {
mockServer.addProtobufResponse(
"/api/rules/search.protobuf?qprofile=QPKEY&organization=orgKey&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY&s=key&ps=500&p=1",
"/api/rules/search.protobuf?qprofile=QPKEY%2B&organization=orgKey&activation=true&f=templateKey,actives&types=CODE_SMELL,BUG,VULNERABILITY&s=key&ps=500&p=1",
Rules.SearchResponse.newBuilder()
.setTotal(2)
.setPs(1)
Expand All @@ -125,7 +125,7 @@ void should_get_active_rules_of_a_given_quality_profile() {

var rulesApi = new RulesApi(mockServer.serverApiHelper("orgKey"));

var activeRules = rulesApi.getAllActiveRules("QPKEY", progress);
var activeRules = rulesApi.getAllActiveRules("QPKEY+", progress);

assertThat(activeRules)
.extracting("ruleKey", "severity", "templateKey", "params")
Expand Down

0 comments on commit d152262

Please sign in to comment.