aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-03-02 12:22:16 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2017-03-03 11:07:45 +0100
commit5956787e24902abdb9d9db2fe712125969c9d263 (patch)
treed6b2bcd66fc92b536d915abb96802a53a2751f60
parent845746eaf1d1f2d20f3a05a0e528ac696c65586a (diff)
downloadsonarqube-5956787e24902abdb9d9db2fe712125969c9d263.tar.gz
sonarqube-5956787e24902abdb9d9db2fe712125969c9d263.zip
SONAR-8838 WS api/project_tags/set requires POST requests
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java11
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java2
2 files changed, 8 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java b/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java
index dae6604ebb3..555cf149519 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/projecttag/ws/SetAction.java
@@ -56,17 +56,13 @@ public class SetAction implements ProjectTagsWsAction {
this.userSession = userSession;
}
- private static String checkTag(String tag) {
- checkRequest(tag.matches(VALID_TAG_REGEXP), "Tag '%s' is invalid. Project tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'", tag);
- return tag;
- }
-
@Override
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction("set")
.setDescription("Set tags on a project.<br>" +
"Requires the following permission: 'Administer' rights on the specified project")
.setSince("6.4")
+ .setPost(true)
.setHandler(this);
action.createParam(PARAM_PROJECT)
@@ -102,4 +98,9 @@ public class SetAction implements ProjectTagsWsAction {
response.noContent();
}
+
+ private static String checkTag(String tag) {
+ checkRequest(tag.matches(VALID_TAG_REGEXP), "Tag '%s' is invalid. Project tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'", tag);
+ return tag;
+ }
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
index 4f7f83eabed..3b2349841e0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
@@ -137,6 +137,8 @@ public class SetActionTest {
public void definition() {
WebService.Action definition = ws.getDef();
+ assertThat(definition.isPost()).isTrue();
+ assertThat(definition.isInternal()).isFalse();
assertThat(definition.params()).extracting(WebService.Param::key)
.containsOnly("project", "tags");
assertThat(definition.description()).isNotEmpty();