diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-11-10 17:13:37 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-11-18 11:17:01 +0100 |
commit | 6cd23f9e6c49c4731da4c878c9891dd3cec8d08d (patch) | |
tree | 8f37c5c9dea4d901a0fb5b78c809c5d989c90414 /sonar-batch | |
parent | 7ec598b6d81cae1840600431f1809cd38ec79c3a (diff) | |
download | sonarqube-6cd23f9e6c49c4731da4c878c9891dd3cec8d08d.tar.gz sonarqube-6cd23f9e6c49c4731da4c878c9891dd3cec8d08d.zip |
SONAR-7008 Call to batch/project WS not encoding parameters
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java | 6 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/rule/DefaultActiveRulesLoaderTest.java | 11 |
2 files changed, 10 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java index 373364dd944..efe0161d905 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/DefaultActiveRulesLoader.java @@ -19,13 +19,17 @@ */ package org.sonar.batch.rule; +import org.sonar.batch.util.BatchUtils; + import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; + import javax.annotation.Nullable; + import org.apache.commons.io.IOUtils; import org.apache.commons.lang.mutable.MutableBoolean; import org.sonar.api.rule.RuleKey; @@ -75,7 +79,7 @@ public class DefaultActiveRulesLoader implements ActiveRulesLoader { private static String getUrl(String qualityProfileKey, int page, int pageSize) { StringBuilder builder = new StringBuilder(1024); builder.append(RULES_SEARCH_URL); - builder.append("&qprofile=").append(qualityProfileKey); + builder.append("&qprofile=").append(BatchUtils.encodeForUrl(qualityProfileKey)); builder.append("&p=").append(page); builder.append("&ps=").append(pageSize); return builder.toString(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultActiveRulesLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultActiveRulesLoaderTest.java index 6c63d0545dc..0a9e4bf678b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultActiveRulesLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/rule/DefaultActiveRulesLoaderTest.java @@ -20,7 +20,6 @@ package org.sonar.batch.rule; import org.sonar.api.rule.RuleKey; - import org.sonar.batch.cache.WSLoaderResult; import org.sonar.batch.cache.WSLoader; import com.google.common.io.Resources; @@ -48,16 +47,16 @@ public class DefaultActiveRulesLoaderTest { } @Test - public void feed_real_response() throws IOException { + public void feed_real_response_encode_qp() throws IOException { InputStream response1 = loadResource("active_rule_search1.protobuf"); InputStream response2 = loadResource("active_rule_search2.protobuf"); - String req1 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=java-sonar-way-26368&p=1&ps=500"; - String req2 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=java-sonar-way-26368&p=2&ps=500"; + String req1 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=c%2B-test_c%2B-values-17445&p=1&ps=500"; + String req2 = "/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=c%2B-test_c%2B-values-17445&p=2&ps=500"; when(ws.loadStream(req1)).thenReturn(new WSLoaderResult<InputStream>(response1, false)); when(ws.loadStream(req2)).thenReturn(new WSLoaderResult<InputStream>(response2, false)); - Collection<LoadedActiveRule> activeRules = loader.load("java-sonar-way-26368", null); + Collection<LoadedActiveRule> activeRules = loader.load("c+-test_c+-values-17445", null); assertThat(activeRules).hasSize(226); assertActiveRule(activeRules); @@ -65,7 +64,7 @@ public class DefaultActiveRulesLoaderTest { verify(ws).loadStream(req2); verifyNoMoreInteractions(ws); } - + private static void assertActiveRule(Collection<LoadedActiveRule> activeRules) { RuleKey key = RuleKey.of("squid", "S3008"); for (LoadedActiveRule r : activeRules) { |