From: Julien Lancelot Date: Fri, 8 Jan 2016 11:44:34 +0000 (+0100) Subject: SONAR-7174 "Execute Analysis" is now also a project permission X-Git-Tag: 5.4-M5~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=51f2544c13d2e857153724337046075cea6df595;p=sonarqube.git SONAR-7174 "Execute Analysis" is now also a project permission --- 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 index f51c5230f9d..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_global_permissions-example.json +++ /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 index 43480d67f96..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/search_project_permissions-example.json +++ /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 index 523c5ebf1d3..00000000000 --- a/server/sonar-server/src/main/resources/org/sonar/server/permission/ws/template/search_templates-example.json +++ /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)" - } - ] -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/i18n/I18nRule.java b/server/sonar-server/src/test/java/org/sonar/server/i18n/I18nRule.java index d84f5af8070..a47bbf2dac4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/i18n/I18nRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/i18n/I18nRule.java @@ -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 index 00000000000..7496b24b5d0 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/i18n/package-info.java @@ -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; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeTest.java index 74a1d2c2e7f..3f49b085e57 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeTest.java @@ -20,14 +20,13 @@ 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(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java index 0bb33521bed..a62135b767b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java @@ -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 diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java index e75dd0f3cba..4418c01f249 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java @@ -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") diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java index 47be8ed0b8a..b457f74a154 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java @@ -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 index 00000000000..f51c5230f9d --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest/search_global_permissions-example.json @@ -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 index 00000000000..5789d2975ed --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/display_all_project_permissions.json @@ -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 + } +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/empty.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/empty.json index 5789d2975ed..acd810938d2 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/empty.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/empty.json @@ -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 index 00000000000..43480d67f96 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest/search_project_permissions-example.json @@ -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 index 00000000000..c6ae975a7a2 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/display_all_project_permissions.json @@ -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." + } + ] +} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json index 985f39eaa92..a3041228330 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/empty.json @@ -13,27 +13,5 @@ "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 index 00000000000..75d69f5b497 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/template/SearchTemplatesActionTest/search_templates-example.json @@ -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" + } + ] +} diff --git a/server/sonar-web/src/main/js/apps/permission-templates/main.js b/server/sonar-web/src/main/js/apps/permission-templates/main.js index 122c573dc54..178b99425ed 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/main.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/main.js @@ -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: { diff --git a/server/sonar-web/src/main/js/apps/project-permissions/main.js b/server/sonar-web/src/main/js/apps/project-permissions/main.js index 7028384ff6a..a3fcacfa7e0 100644 --- a/server/sonar-web/src/main/js/apps/project-permissions/main.js +++ b/server/sonar-web/src/main/js/apps/project-permissions/main.js @@ -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({ diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 22198010256..a1b3baa9830 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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}" diff --git a/sonar-db/src/main/java/org/sonar/core/permission/ProjectPermissions.java b/sonar-db/src/main/java/org/sonar/core/permission/ProjectPermissions.java index 0db669d7069..0d46709d912 100644 --- a/sonar-db/src/main/java/org/sonar/core/permission/ProjectPermissions.java +++ b/sonar-db/src/main/java/org/sonar/core/permission/ProjectPermissions.java @@ -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 ALL = ImmutableList.of(UserRole.USER, UserRole.ADMIN, UserRole.ISSUE_ADMIN, UserRole.CODEVIEWER); + public static final List 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 index 00000000000..7b5d6465924 --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/core/permission/ProjectPermissionsTest.java @@ -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"); + } +}