]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9181 Sanitize json example filenames of api/projects domain
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 5 Sep 2017 16:20:37 +0000 (18:20 +0200)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 11 Sep 2017 09:28:29 +0000 (11:28 +0200)
server/sonar-server/src/main/java/org/sonar/server/project/ws/GhostsAction.java
server/sonar-server/src/main/java/org/sonar/server/project/ws/ProvisionedAction.java
server/sonar-server/src/main/resources/org/sonar/server/project/ws/ghosts-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-ghosts.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/project/ws/provisioned-example.json [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/project/ws/GhostsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/project/ws/ProvisionedActionTest.java

index 2c7dd00c722b560be408b01fc56bf1a76bc2bfb4..ab90d8496c613369f0c1c0f9c215ef9476450188 100644 (file)
@@ -70,7 +70,7 @@ public class GhostsAction implements ProjectsWsAction {
       .setDescription("List ghost projects.<br> " +
         "With the current architecture, it's no more possible to have invisible ghost projects. Therefore, the web service is deprecated.<br> " +
         "Requires 'Administer System' permission.")
-      .setResponseExample(Resources.getResource(getClass(), "projects-example-ghosts.json"))
+      .setResponseExample(Resources.getResource(getClass(), "ghosts-example.json"))
       .setSince("5.2")
       .setDeprecatedSince("6.6")
       .addPagingParams(100, MAX_LIMIT)
index a19e83f044ffb43850f3c537bd80d1d3b09be55d..a5fcf853663b1e6ac07afe87a67896c5150bf6f5 100644 (file)
@@ -78,7 +78,7 @@ public class ProvisionedAction implements ProjectsWsAction {
           "Require 'Create Projects' permission.")
       .setSince("5.2")
       .setDeprecatedSince("6.6")
-      .setResponseExample(Resources.getResource(getClass(), "projects-example-provisioned.json"))
+      .setResponseExample(Resources.getResource(getClass(), "provisioned-example.json"))
       .setHandler(this)
       .addPagingParams(100, MAX_LIMIT)
       .addSearchQuery("sonar", "names", "keys")
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/ghosts-example.json b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/ghosts-example.json
new file mode 100644 (file)
index 0000000..87444da
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "projects": [
+    {
+      "uuid": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
+      "key": "org.apache.hbas:hbase",
+      "name": "HBase",
+      "creationDate": "2015-03-04T23:03:44+0100",
+      "visibility": "public"
+    },
+    {
+      "uuid": "c526ef20-131b-4486-9357-063fa64b5079",
+      "key": "com.microsoft.roslyn:roslyn",
+      "name": "Roslyn",
+      "creationDate": "2013-03-04T23:03:44+0100",
+      "visibility": "private"
+    }
+  ],
+  "total": 2,
+  "p": 1,
+  "ps": 100
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-ghosts.json b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-ghosts.json
deleted file mode 100644 (file)
index 87444da..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-{
-  "projects": [
-    {
-      "uuid": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
-      "key": "org.apache.hbas:hbase",
-      "name": "HBase",
-      "creationDate": "2015-03-04T23:03:44+0100",
-      "visibility": "public"
-    },
-    {
-      "uuid": "c526ef20-131b-4486-9357-063fa64b5079",
-      "key": "com.microsoft.roslyn:roslyn",
-      "name": "Roslyn",
-      "creationDate": "2013-03-04T23:03:44+0100",
-      "visibility": "private"
-    }
-  ],
-  "total": 2,
-  "p": 1,
-  "ps": 100
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/projects-example-provisioned.json
deleted file mode 100644 (file)
index 6361d3c..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-  "paging": {
-    "total": 2,
-    "pageIndex": 1,
-    "pageSize": 100
-  },
-  "projects": [
-    {
-      "uuid": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
-      "key": "org.apache.hbas:hbase",
-      "name": "HBase",
-      "creationDate": "2015-03-04T23:03:44+0100",
-      "visibility": "public"
-    },
-    {
-      "uuid": "c526ef20-131b-4486-9357-063fa64b5079",
-      "key": "com.microsoft.roslyn:roslyn",
-      "name": "Roslyn",
-      "creationDate": "2013-03-04T23:03:44+0100",
-      "visibility": "private"
-    }
-  ]
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/project/ws/provisioned-example.json b/server/sonar-server/src/main/resources/org/sonar/server/project/ws/provisioned-example.json
new file mode 100644 (file)
index 0000000..6361d3c
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "paging": {
+    "total": 2,
+    "pageIndex": 1,
+    "pageSize": 100
+  },
+  "projects": [
+    {
+      "uuid": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
+      "key": "org.apache.hbas:hbase",
+      "name": "HBase",
+      "creationDate": "2015-03-04T23:03:44+0100",
+      "visibility": "public"
+    },
+    {
+      "uuid": "c526ef20-131b-4486-9357-063fa64b5079",
+      "key": "com.microsoft.roslyn:roslyn",
+      "name": "Roslyn",
+      "creationDate": "2013-03-04T23:03:44+0100",
+      "visibility": "private"
+    }
+  ]
+}
index 5350d3090cbf315be7cf3c62b6ee5452abe46ee4..47c73884037916066c67d0ad69716e108d1d2e93 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.project.ws;
 
-import com.google.common.io.Resources;
 import java.util.function.Consumer;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
@@ -216,8 +215,7 @@ public class GhostsActionTest {
       .setParam("organization", organization.getKey())
       .execute();
 
-    assertJson(result.getInput())
-      .isSimilarTo(Resources.getResource(getClass(), "projects-example-ghosts.json"));
+    assertJson(result.getInput()).isSimilarTo(ws.getDef().responseExampleAsString());
   }
 
   @Test
index 269a85ba0687f9dcce09f7016196879b16ac117e..07b0782bce53594e9caab76ded35dfda17cb996b 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.project.ws;
 
-import com.google.common.io.Resources;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
 import org.junit.Test;
@@ -192,8 +191,7 @@ public class ProvisionedActionTest {
       .setParam(PARAM_ORGANIZATION, org.getKey())
       .execute();
 
-    assertJson(result.getInput())
-      .isSimilarTo(Resources.getResource(getClass(), "projects-example-provisioned.json"));
+    assertJson(result.getInput()).isSimilarTo(ws.getDef().responseExampleAsString());
   }
 
   @Test