]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7174 "Execute Analysis" is now also a project permission
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 8 Jan 2016 11:44:34 +0000 (12:44 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 12 Jan 2016 14:34:25 +0000 (15:34 +0100)
21 files changed:
server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_global_permissions-example.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_project_permissions-example.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json [deleted file]
server/sonar-server/src/test/java/org/sonar/server/i18n/I18nRule.java
server/sonar-server/src/test/java/org/sonar/server/i18n/package-info.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest/search_global_permissions-example.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/display_all_project_permissions.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/empty.json
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/search_project_permissions-example.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/display_all_project_permissions.json [new file with mode: 0644]
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/search_templates-example.json [new file with mode: 0644]
server/sonar-web/src/main/js/apps/permission-templates/main.js
server/sonar-web/src/main/js/apps/project-permissions/main.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-db/src/main/java/org/sonar/core/permission/ProjectPermissions.java
sonar-db/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java [new file with mode: 0644]

diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_global_permissions-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_global_permissions-example.json
deleted file mode 100644 (file)
index f51c523..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-{
-  "permissions": [
-    {
-      "key": "admin",
-      "name": "Administer System",
-      "description": "Ability to perform all administration functions for the instance: global configuration and personalization of default dashboards.",
-      "usersCount": 0,
-      "groupsCount": 1
-    },
-    {
-      "key": "profileadmin",
-      "name": "Administer Quality Profiles and Gates",
-      "description": "Ability to perform any action on the quality profiles and gates.",
-      "usersCount": 2,
-      "groupsCount": 0
-    },
-    {
-      "key": "shareDashboard",
-      "name": "Share Dashboards And Filters",
-      "description": "Ability to share dashboards, issue filters and measure filters.",
-      "usersCount": 0,
-      "groupsCount": 1
-    },
-    {
-      "key": "scan",
-      "name": "Execute Analysis",
-      "description": "Ability to execute analyses, and to get all settings required to perform the analysis, even the secured ones like the scm account password, the jira account password, and so on.",
-      "usersCount": 0,
-      "groupsCount": 2
-    },
-    {
-      "key": "dryRunScan",
-      "name": "Execute Preview Analysis",
-      "description": "Ability to execute preview analysis (results are not pushed to the server). This permission does not include the ability to access secured settings such as the scm account password, the jira account password, and so on. This permission is required to execute preview analysis in Eclipse or via the Issues Report plugin.",
-      "usersCount": 2,
-      "groupsCount": 0
-    },
-    {
-      "key": "provisioning",
-      "name": "Provision Projects",
-      "description": "Ability to initialize project structure before first analysis.",
-      "usersCount": 1,
-      "groupsCount": 1
-    }
-  ]
-}
-
-
-
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_project_permissions-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_project_permissions-example.json
deleted file mode 100644 (file)
index 43480d6..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-{
-  "paging": {
-    "pageIndex": 1,
-    "pageSize": 25,
-    "total": 4
-  },
-  "projects": [
-    {
-      "id": "0bd7b1e7-91d6-439e-a607-4a3a9aad3c6a",
-      "key": "net.java.openjdk:jdk7",
-      "name": "JDK 7",
-      "qualifier": "TRK",
-      "permissions": [
-        {
-          "key": "admin",
-          "usersCount": 3,
-          "groupsCount": 4
-        },
-        {
-          "key": "issueadmin",
-          "usersCount": 1,
-          "groupsCount": 0
-        }
-      ]
-    },
-    {
-      "id": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
-      "key": "clang",
-      "name": "Clang",
-      "qualifier": "TRK",
-      "permissions": [
-        {
-          "key": "issueadmin",
-          "usersCount": 1,
-          "groupsCount": 0
-        }
-      ]
-    },
-    {
-      "id": "4e607bf9-7ed0-484a-946d-d58ba7dab2fb",
-      "key": "simon-brandhof",
-      "name": "Simon Brandhof",
-      "qualifier": "DEV",
-      "permissions": [
-        {
-          "key": "admin",
-          "usersCount": 0,
-          "groupsCount": 1
-        },
-        {
-          "key": "issueadmin",
-          "usersCount": 1,
-          "groupsCount": 0
-        }
-      ]
-    },
-    {
-      "id": "752d8bfd-420c-4a83-a4e5-8ab19b13c8fc",
-      "key": "Java",
-      "name": "Java",
-      "qualifier": "VW",
-      "permissions": [
-        {
-          "key": "admin",
-          "usersCount": 0,
-          "groupsCount": 1
-        },
-        {
-          "key": "issueadmin",
-          "usersCount": 1,
-          "groupsCount": 0
-        }
-      ]
-    }
-  ],
-  "permissions": [
-    {
-      "key": "user",
-      "name": "Browse",
-      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
-    },
-    {
-      "key": "admin",
-      "name": "Administer",
-      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "issueadmin",
-      "name": "Administer Issues",
-      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won\u0027t Fix or changing an Issue\u0027s severity. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "codeviewer",
-      "name": "See Source Code",
-      "description": "Ability to view the project\u0027s source code. (Users will also need \"Browse\" permission)"
-    }
-  ]
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json b/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json
deleted file mode 100644 (file)
index 523c5eb..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-{
-  "permissionTemplates": [
-    {
-      "id": "AU-TpxcA-iU5OvuD2FL0",
-      "name": "Default template for Developers",
-      "projectKeyPattern": ".*sonar.developer.*",
-      "createdAt": "2004-11-15T07:26:40+0100",
-      "updatedAt": "2004-11-19T22:33:20+0100",
-      "permissions": [
-        {
-          "key": "user",
-          "usersCount": 0,
-          "groupsCount": 1
-        }
-      ]
-    },
-    {
-      "id": "AU-Tpxb--iU5OvuD2FLy",
-      "name": "Default template for Projects",
-      "description": "Template for new projects",
-      "createdAt": "2001-09-09T03:46:40+0200",
-      "updatedAt": "2001-09-09T03:46:40+0200",
-      "permissions": [
-        {
-          "key": "admin",
-          "usersCount": 0,
-          "groupsCount": 1
-        },
-        {
-          "key": "codeviewer",
-          "usersCount": 1,
-          "groupsCount": 0
-        },
-        {
-          "key": "issueadmin",
-          "usersCount": 3,
-          "groupsCount": 0
-        }
-      ]
-    },
-    {
-      "id": "AU-TpxcA-iU5OvuD2FLz",
-      "name": "Default template for Views",
-      "description": "Template for new views",
-      "projectKeyPattern": ".*sonar.views.*",
-      "createdAt": "2001-09-09T03:46:40+0200",
-      "updatedAt": "2004-11-09T12:33:20+0100",
-      "permissions": [
-        {
-          "key": "issueadmin",
-          "usersCount": 0,
-          "groupsCount": 3
-        },
-        {
-          "key": "user",
-          "usersCount": 2,
-          "groupsCount": 0
-        }
-      ]
-    }
-  ],
-  "defaultTemplates": [
-    {
-      "templateId": "AU-Tpxb--iU5OvuD2FLy",
-      "qualifier": "TRK"
-    },
-    {
-      "templateId": "AU-TpxcA-iU5OvuD2FLz",
-      "qualifier": "VW"
-    },
-    {
-      "templateId": "AU-TpxcA-iU5OvuD2FL0",
-      "qualifier": "DEV"
-    }
-  ],
-  "permissions": [
-    {
-      "key": "user",
-      "name": "Browse",
-      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
-    },
-    {
-      "key": "admin",
-      "name": "Administer",
-      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "issueadmin",
-      "name": "Administer Issues",
-      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won\u0027t Fix or changing an Issue\u0027s severity. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "codeviewer",
-      "name": "See Source Code",
-      "description": "Ability to view the project\u0027s source code. (Users will also need \"Browse\" permission)"
-    }
-  ]
-}
index d84f5af8070e2df5c6521d1d9ad151a855900aea..a47bbf2dac41419109d096d600ba8ef0df92d4b6 100644 (file)
@@ -47,6 +47,9 @@ public class I18nRule implements I18n {
     put("projects_role.user.desc", "Ability to access a project, browse its measures, and create/edit issues for it.");
     put("projects_role.codeviewer", "See Source Code");
     put("projects_role.codeviewer.desc", "Ability to view the project's source code. (Users will also need \"Browse\" permission)");
+    put("projects_role.scan", "Execute Analysis");
+    put("projects_role.scan.desc",
+      "Ability to execute analyses, and to get all settings required to perform the analysis, even the secured ones like the scm account password, the jira account password, and so on.");
   }
 
   @Override
diff --git a/server/sonar-server/src/test/java/org/sonar/server/i18n/package-info.java b/server/sonar-server/src/test/java/org/sonar/server/i18n/package-info.java
new file mode 100644 (file)
index 0000000..7496b24
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SonarQube :: Server
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.i18n;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 74a1d2c2e7fe9f39da128883812e546bc2fedbe1..3f49b085e5728a99d063ab94f565fdc400a567d8 100644 (file)
 package org.sonar.server.permission;
 
 import com.google.common.collect.Maps;
+import java.util.Map;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.core.permission.GlobalPermissions;
 import org.sonar.server.exceptions.BadRequestException;
 
-import java.util.Map;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class PermissionChangeTest {
@@ -132,7 +131,7 @@ public class PermissionChangeTest {
     PermissionChange query = PermissionChange.buildFromParams(inconsistentParams);
 
     thrown.expect(BadRequestException.class);
-    thrown.expectMessage("Invalid component permission key invalid. Valid values are [user, admin, issueadmin, codeviewer]");
+    thrown.expectMessage("Invalid component permission key invalid. Valid values are [user, admin, issueadmin, codeviewer, scan]");
     query.validate();
   }
 }
index 0bb33521bed4e6269dcdfbd6186e92f6974beab3..a62135b767b3709fe18114f824b4043d8bd236bc 100644 (file)
@@ -91,7 +91,7 @@ public class SearchGlobalPermissionsActionTest {
 
     String result = ws.newRequest().execute().getInput();
 
-    assertJson(result).isSimilarTo(getClass().getResource("search_global_permissions-example.json"));
+    assertJson(result).isSimilarTo(getClass().getResource("SearchGlobalPermissionsActionTest/search_global_permissions-example.json"));
   }
 
   @Test
index e75dd0f3cba4f7e625371bbd32bb6f6650c1f94c..4418c01f2497f8916148953fc4bc07732c4649f4 100644 (file)
@@ -135,14 +135,18 @@ public class SearchProjectPermissionsActionTest {
 
     String result = ws.newRequest().execute().getInput();
 
-    assertJson(result).isSimilarTo(getClass().getResource("search_project_permissions-example.json"));
+    assertJson(result)
+      .ignoreFields("permissions")
+      .isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/search_project_permissions-example.json"));
   }
 
   @Test
   public void empty_result() {
     String result = ws.newRequest().execute().getInput();
 
-    assertJson(result).isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/empty.json"));
+    assertJson(result)
+      .ignoreFields("permissions")
+      .isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/empty.json"));
   }
 
   @Test
@@ -275,6 +279,15 @@ public class SearchProjectPermissionsActionTest {
     ws.newRequest().execute();
   }
 
+  @Test
+  public void display_all_project_permissions() {
+    String result = ws.newRequest().execute().getInput();
+
+    assertJson(result)
+      .ignoreFields("permissions")
+      .isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/display_all_project_permissions.json"));
+  }
+
   private ComponentDto insertView() {
     return insertComponent(newView()
       .setUuid("752d8bfd-420c-4a83-a4e5-8ab19b13c8fc")
index 47be8ed0b8aca4d4d46267e668715df8a9a2ce61..b457f74a15499c451c368acbc029125b9c5d2dea 100644 (file)
@@ -136,7 +136,8 @@ public class SearchTemplatesActionTest {
 
     assertJson(result)
       .withStrictArrayOrder()
-      .isSimilarTo(getClass().getResource("search_templates-example.json"));
+      .ignoreFields("permissions")
+      .isSimilarTo(getClass().getResource("SearchTemplatesActionTest/search_templates-example.json"));
   }
 
   @Test
@@ -145,6 +146,7 @@ public class SearchTemplatesActionTest {
 
     assertJson(result)
       .withStrictArrayOrder()
+      .ignoreFields("permissions")
       .isSimilarTo(getClass().getResource("SearchTemplatesActionTest/empty.json"));
   }
 
@@ -180,6 +182,16 @@ public class SearchTemplatesActionTest {
     ws.newRequest().execute();
   }
 
+  @Test
+  public void display_all_project_permissions() {
+    String result = newRequest();
+
+    assertJson(result)
+      .withStrictArrayOrder()
+      .ignoreFields("defaultTemplates", "permissionTemplates")
+      .isSimilarTo(getClass().getResource("SearchTemplatesActionTest/display_all_project_permissions.json"));
+  }
+
   private String newRequest() {
     return ws.newRequest().execute().getInput();
   }
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest/search_global_permissions-example.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest/search_global_permissions-example.json
new file mode 100644 (file)
index 0000000..f51c523
--- /dev/null
@@ -0,0 +1,49 @@
+{
+  "permissions": [
+    {
+      "key": "admin",
+      "name": "Administer System",
+      "description": "Ability to perform all administration functions for the instance: global configuration and personalization of default dashboards.",
+      "usersCount": 0,
+      "groupsCount": 1
+    },
+    {
+      "key": "profileadmin",
+      "name": "Administer Quality Profiles and Gates",
+      "description": "Ability to perform any action on the quality profiles and gates.",
+      "usersCount": 2,
+      "groupsCount": 0
+    },
+    {
+      "key": "shareDashboard",
+      "name": "Share Dashboards And Filters",
+      "description": "Ability to share dashboards, issue filters and measure filters.",
+      "usersCount": 0,
+      "groupsCount": 1
+    },
+    {
+      "key": "scan",
+      "name": "Execute Analysis",
+      "description": "Ability to execute analyses, and to get all settings required to perform the analysis, even the secured ones like the scm account password, the jira account password, and so on.",
+      "usersCount": 0,
+      "groupsCount": 2
+    },
+    {
+      "key": "dryRunScan",
+      "name": "Execute Preview Analysis",
+      "description": "Ability to execute preview analysis (results are not pushed to the server). This permission does not include the ability to access secured settings such as the scm account password, the jira account password, and so on. This permission is required to execute preview analysis in Eclipse or via the Issues Report plugin.",
+      "usersCount": 2,
+      "groupsCount": 0
+    },
+    {
+      "key": "provisioning",
+      "name": "Provision Projects",
+      "description": "Ability to initialize project structure before first analysis.",
+      "usersCount": 1,
+      "groupsCount": 1
+    }
+  ]
+}
+
+
+
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/display_all_project_permissions.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/display_all_project_permissions.json
new file mode 100644 (file)
index 0000000..5789d29
--- /dev/null
@@ -0,0 +1,30 @@
+{
+  "projects": [],
+  "permissions": [
+    {
+      "key": "user",
+      "name": "Browse",
+      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
+    },
+    {
+      "key": "admin",
+      "name": "Administer",
+      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "issueadmin",
+      "name": "Administer Issues",
+      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won't Fix or changing an Issue's severity. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "codeviewer",
+      "name": "See Source Code",
+      "description": "Ability to view the project's source code. (Users will also need \"Browse\" permission)"
+    }
+  ],
+  "paging": {
+    "pageIndex": 1,
+    "pageSize": 25,
+    "total": 0
+  }
+}
index 5789d2975ede32cc5148fc834ac9771b78ac80c6..acd810938d2b26735d4c78413eef20015b40073f 100644 (file)
@@ -1,27 +1,5 @@
 {
   "projects": [],
-  "permissions": [
-    {
-      "key": "user",
-      "name": "Browse",
-      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
-    },
-    {
-      "key": "admin",
-      "name": "Administer",
-      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "issueadmin",
-      "name": "Administer Issues",
-      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won't Fix or changing an Issue's severity. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "codeviewer",
-      "name": "See Source Code",
-      "description": "Ability to view the project's source code. (Users will also need \"Browse\" permission)"
-    }
-  ],
   "paging": {
     "pageIndex": 1,
     "pageSize": 25,
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/search_project_permissions-example.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/search_project_permissions-example.json
new file mode 100644 (file)
index 0000000..43480d6
--- /dev/null
@@ -0,0 +1,98 @@
+{
+  "paging": {
+    "pageIndex": 1,
+    "pageSize": 25,
+    "total": 4
+  },
+  "projects": [
+    {
+      "id": "0bd7b1e7-91d6-439e-a607-4a3a9aad3c6a",
+      "key": "net.java.openjdk:jdk7",
+      "name": "JDK 7",
+      "qualifier": "TRK",
+      "permissions": [
+        {
+          "key": "admin",
+          "usersCount": 3,
+          "groupsCount": 4
+        },
+        {
+          "key": "issueadmin",
+          "usersCount": 1,
+          "groupsCount": 0
+        }
+      ]
+    },
+    {
+      "id": "ce4c03d6-430f-40a9-b777-ad877c00aa4d",
+      "key": "clang",
+      "name": "Clang",
+      "qualifier": "TRK",
+      "permissions": [
+        {
+          "key": "issueadmin",
+          "usersCount": 1,
+          "groupsCount": 0
+        }
+      ]
+    },
+    {
+      "id": "4e607bf9-7ed0-484a-946d-d58ba7dab2fb",
+      "key": "simon-brandhof",
+      "name": "Simon Brandhof",
+      "qualifier": "DEV",
+      "permissions": [
+        {
+          "key": "admin",
+          "usersCount": 0,
+          "groupsCount": 1
+        },
+        {
+          "key": "issueadmin",
+          "usersCount": 1,
+          "groupsCount": 0
+        }
+      ]
+    },
+    {
+      "id": "752d8bfd-420c-4a83-a4e5-8ab19b13c8fc",
+      "key": "Java",
+      "name": "Java",
+      "qualifier": "VW",
+      "permissions": [
+        {
+          "key": "admin",
+          "usersCount": 0,
+          "groupsCount": 1
+        },
+        {
+          "key": "issueadmin",
+          "usersCount": 1,
+          "groupsCount": 0
+        }
+      ]
+    }
+  ],
+  "permissions": [
+    {
+      "key": "user",
+      "name": "Browse",
+      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
+    },
+    {
+      "key": "admin",
+      "name": "Administer",
+      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "issueadmin",
+      "name": "Administer Issues",
+      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won\u0027t Fix or changing an Issue\u0027s severity. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "codeviewer",
+      "name": "See Source Code",
+      "description": "Ability to view the project\u0027s source code. (Users will also need \"Browse\" permission)"
+    }
+  ]
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/display_all_project_permissions.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/display_all_project_permissions.json
new file mode 100644 (file)
index 0000000..c6ae975
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "permissions": [
+    {
+      "key": "user",
+      "name": "Browse",
+      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
+    },
+    {
+      "key": "admin",
+      "name": "Administer",
+      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "issueadmin",
+      "name": "Administer Issues",
+      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won't Fix or changing an Issue's severity. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "codeviewer",
+      "name": "See Source Code",
+      "description": "Ability to view the project's source code. (Users will also need \"Browse\" permission)"
+    },
+    {
+      "key": "scan",
+      "name": "Execute Analysis",
+      "description": "Ability to execute analyses, and to get all settings required to perform the analysis, even the secured ones like the scm account password, the jira account password, and so on."
+    }
+  ]
+}
index 985f39eaa922a0c4986efcf43ab262d5aa80d514..a304122833057b6e7352e47f395552a4146216b0 100644 (file)
       "templateId": "AU-TpxcA-iU5OvuD2FL0",
       "qualifier": "DEV"
     }
-  ],
-  "permissions": [
-    {
-      "key": "user",
-      "name": "Browse",
-      "description": "Ability to access a project, browse its measures, and create/edit issues for it."
-    },
-    {
-      "key": "admin",
-      "name": "Administer",
-      "description": "Ability to access project settings and perform administration tasks. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "issueadmin",
-      "name": "Administer Issues",
-      "description": "Grants the permission to perform advanced editing on issues: marking an issue False Positive / Won't Fix or changing an Issue's severity. (Users will also need \"Browse\" permission)"
-    },
-    {
-      "key": "codeviewer",
-      "name": "See Source Code",
-      "description": "Ability to view the project's source code. (Users will also need \"Browse\" permission)"
-    }
   ]
 }
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/search_templates-example.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/search_templates-example.json
new file mode 100644 (file)
index 0000000..75d69f5
--- /dev/null
@@ -0,0 +1,76 @@
+{
+  "permissionTemplates": [
+    {
+      "id": "AU-TpxcA-iU5OvuD2FL0",
+      "name": "Default template for Developers",
+      "projectKeyPattern": ".*sonar.developer.*",
+      "createdAt": "2004-11-15T07:26:40+0100",
+      "updatedAt": "2004-11-19T22:33:20+0100",
+      "permissions": [
+        {
+          "key": "user",
+          "usersCount": 0,
+          "groupsCount": 1
+        }
+      ]
+    },
+    {
+      "id": "AU-Tpxb--iU5OvuD2FLy",
+      "name": "Default template for Projects",
+      "description": "Template for new projects",
+      "createdAt": "2001-09-09T03:46:40+0200",
+      "updatedAt": "2001-09-09T03:46:40+0200",
+      "permissions": [
+        {
+          "key": "admin",
+          "usersCount": 0,
+          "groupsCount": 1
+        },
+        {
+          "key": "codeviewer",
+          "usersCount": 1,
+          "groupsCount": 0
+        },
+        {
+          "key": "issueadmin",
+          "usersCount": 3,
+          "groupsCount": 0
+        }
+      ]
+    },
+    {
+      "id": "AU-TpxcA-iU5OvuD2FLz",
+      "name": "Default template for Views",
+      "description": "Template for new views",
+      "projectKeyPattern": ".*sonar.views.*",
+      "createdAt": "2001-09-09T03:46:40+0200",
+      "updatedAt": "2004-11-09T12:33:20+0100",
+      "permissions": [
+        {
+          "key": "issueadmin",
+          "usersCount": 0,
+          "groupsCount": 3
+        },
+        {
+          "key": "user",
+          "usersCount": 2,
+          "groupsCount": 0
+        }
+      ]
+    }
+  ],
+  "defaultTemplates": [
+    {
+      "templateId": "AU-Tpxb--iU5OvuD2FLy",
+      "qualifier": "TRK"
+    },
+    {
+      "templateId": "AU-TpxcA-iU5OvuD2FLz",
+      "qualifier": "VW"
+    },
+    {
+      "templateId": "AU-TpxcA-iU5OvuD2FL0",
+      "qualifier": "DEV"
+    }
+  ]
+}
index 122c573dc54804d7dc7932a9e00a7f8abb6ae539..178b99425edc9bfb6443123c4350cb1594379fc7 100644 (file)
@@ -23,7 +23,7 @@ import Header from './header';
 import PermissionTemplates from './permission-templates';
 import { getPermissionTemplates } from '../../api/permissions';
 
-const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin'];
+const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin', 'scan'];
 
 export default React.createClass({
   propTypes: {
index 7028384ff6a97daf1a1cc1f86cf3b4897b2e6e3e..a3fcacfa7e070fbc2806fe3eafad1fd3192a8a64 100644 (file)
@@ -28,7 +28,7 @@ import ApplyTemplateView from './apply-template-view';
 import { translate } from '../../helpers/l10n';
 
 
-const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin'];
+const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin', 'scan'];
 
 
 export default React.createClass({
index 22198010256919697af51639fa487eb0c38858e5..a1b3baa983072beb20b70c7e47b1761b3306aa28 100644 (file)
@@ -2841,6 +2841,8 @@ projects_role.user=Browse
 projects_role.user.desc=Access a project, browse its measures, and create/edit issues for it.
 projects_role.codeviewer=See Source Code
 projects_role.codeviewer.desc=View the project's source code. (Users will also need "Browse" permission)
+projects_role.scan=Execute Analysis
+projects_role.scan.desc=Ability to execute analyses, and to get all settings required to perform the analysis, even the secured ones like the scm account password, the jira account password, and so on.
 projects_role.bulk_change=Bulk Change
 projects_role.apply_template=Apply Permission Template
 projects_role.apply_template_to_xxx=Apply Permission Template To "{0}"
index 0db669d7069359209c48fccae86e9b634ea87a9d..0d46709d9125b7b2d15de117fb123e8419d249b1 100644 (file)
@@ -30,13 +30,14 @@ import org.sonar.api.web.UserRole;
  */
 public final class ProjectPermissions {
 
-  private ProjectPermissions() {
-    // static constants only
-  }
-
   /**
-   * All the component permissions values, ordered from {@link UserRole#USER} to {@link UserRole#CODEVIEWER}.
+   * All the component permissions values, ordered from {@link UserRole#USER} to {@link GlobalPermissions#SCAN_EXECUTION}.
    */
-  public static final List<String> ALL = ImmutableList.of(UserRole.USER, UserRole.ADMIN, UserRole.ISSUE_ADMIN, UserRole.CODEVIEWER);
+  public static final List<String> ALL = ImmutableList.of(UserRole.USER, UserRole.ADMIN, UserRole.ISSUE_ADMIN, UserRole.CODEVIEWER, GlobalPermissions.SCAN_EXECUTION);
+
   public static final String ALL_ON_ONE_LINE = Joiner.on(", ").join(ProjectPermissions.ALL);
+
+  private ProjectPermissions() {
+    // static constants only
+  }
 }
diff --git a/sonar-db/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java b/sonar-db/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java
new file mode 100644 (file)
index 0000000..7b5d646
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube :: Database
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.core.permission;
+
+import org.junit.Test;
+import org.sonar.api.web.UserRole;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ProjectPermissionsTest {
+
+  @Test
+  public void all_permissions() throws Exception {
+    assertThat(ProjectPermissions.ALL).containsOnly(UserRole.USER, UserRole.ADMIN, UserRole.ISSUE_ADMIN, UserRole.CODEVIEWER, GlobalPermissions.SCAN_EXECUTION);
+  }
+
+  @Test
+  public void all_permissions_as_string() throws Exception {
+    assertThat(ProjectPermissions.ALL_ON_ONE_LINE).isEqualTo("user, admin, issueadmin, codeviewer, scan");
+  }
+}