]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9869 Fix project urls in webhook payload
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 24 Oct 2017 09:26:59 +0000 (11:26 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 24 Oct 2017 12:21:12 +0000 (14:21 +0200)
server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java

index f70e4683a8ec518a7eabcb7c976220ff9d34a03f..9f4c0ca5015e92ea6868477773ccead4c3ea24cc 100644 (file)
@@ -110,7 +110,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
   }
 
   private String projectUrlOf(Project project) {
-    return format("%s/project/dashboard?id=%s", server.getPublicRootUrl(), encode(project.getKey()));
+    return format("%s/dashboard?id=%s", server.getPublicRootUrl(), encode(project.getKey()));
   }
 
   private String branchUrlOf(Project project, Branch branch) {
@@ -118,7 +118,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
       if (branch.isMain()) {
         return projectUrlOf(project);
       }
-      return format("%s/project/dashboard?branch=%s&id=%s",
+      return format("%s/dashboard?branch=%s&id=%s",
         server.getPublicRootUrl(), encode(branch.getName().orElse("")), encode(project.getKey()));
     } else {
       return format("%s/project/issues?branch=%s&id=%s&resolved=false",
index d9239b774b0191e645711ed5a8502d3ad238e75b..05501d9e366a28c682fd1fda792df1f6b18ac310 100644 (file)
@@ -69,7 +69,7 @@ public class WebhookPayloadFactoryImplTest {
         "  \"project\": {" +
         "    \"key\": \"P1\"," +
         "    \"name\": \"Project One\"," +
-        "    \"url\": \"http://foo/project/dashboard?id=P1\"" +
+        "    \"url\": \"http://foo/dashboard?id=P1\"" +
         "  }," +
         "  \"qualityGate\": {" +
         "    \"name\": \"Gate One\"," +
@@ -110,7 +110,7 @@ public class WebhookPayloadFactoryImplTest {
         "  \"project\": {" +
         "    \"key\": \"P1\"," +
         "    \"name\": \"Project One\"," +
-        "    \"url\": \"http://foo/project/dashboard?id=P1\"" +
+        "    \"url\": \"http://foo/dashboard?id=P1\"" +
         "  }," +
         "  \"qualityGate\": {" +
         "    \"name\": \"Gate One\"," +
@@ -151,7 +151,7 @@ public class WebhookPayloadFactoryImplTest {
         "  \"project\": {" +
         "    \"key\": \"P1\"," +
         "    \"name\": \"Project One\"," +
-        "    \"url\": \"http://foo/project/dashboard?id=P1\"" +
+        "    \"url\": \"http://foo/dashboard?id=P1\"" +
         "  }," +
         "  \"qualityGate\": {" +
         "    \"name\": \"Gate One\"," +
@@ -186,7 +186,7 @@ public class WebhookPayloadFactoryImplTest {
         "  \"project\": {" +
         "    \"key\": \"P1\"," +
         "    \"name\": \"Project One\"," +
-        "    \"url\": \"http://foo/project/dashboard?id=P1\"" +
+        "    \"url\": \"http://foo/dashboard?id=P1\"" +
         "  }," +
         "  \"properties\": {" +
         "  }" +
@@ -266,7 +266,7 @@ public class WebhookPayloadFactoryImplTest {
         "  \"name\": \"feature/foo\"" +
         "  \"type\": \"LONG\"" +
         "  \"isMain\": false," +
-        "  \"url\": \"http://foo/project/dashboard?branch=feature%2Ffoo&id=P1\"" +
+        "  \"url\": \"http://foo/dashboard?branch=feature%2Ffoo&id=P1\"" +
         "}" +
         "}");
   }
@@ -282,7 +282,7 @@ public class WebhookPayloadFactoryImplTest {
         "\"branch\": {" +
         "  \"type\": \"LONG\"" +
         "  \"isMain\": true," +
-        "  \"url\": \"http://foo/project/dashboard?id=P1\"" +
+        "  \"url\": \"http://foo/dashboard?id=P1\"" +
         "}" +
         "}");
   }
index 2539ab6bb6dfb19e94d06153ffef58ec3aade15b..16d2ec83f881b08eef9d6341f7e824c8e64b581f 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonarqube.tests.webhook;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category3Suite;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -31,6 +30,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
+import org.sonarqube.tests.Category3Suite;
 import org.sonarqube.ws.Webhooks;
 import org.sonarqube.ws.client.HttpException;
 import org.sonarqube.ws.client.WsClient;
@@ -107,6 +107,7 @@ public class WebhooksTest {
     Map<String, String> project = (Map<String, String>) payload.get("project");
     assertThat(project.get("key")).isEqualTo(PROJECT_KEY);
     assertThat(project.get("name")).isEqualTo(PROJECT_NAME);
+    assertThat(project.get("url")).isEqualTo(orchestrator.getServer().getUrl() + "/dashboard?id=" + PROJECT_KEY);
     Map<String, Object> gate = (Map<String, Object>) payload.get("qualityGate");
     assertThat(gate.get("name")).isEqualTo("SonarQube way");
     assertThat(gate.get("status")).isEqualTo("OK");