import it.authorisation.IssuePermissionTest;
import it.authorisation.PermissionSearchTest;
import it.authorisation.ProvisioningPermissionTest;
+import it.authorisation.QualityProfileAdminPermissionTest;
import it.i18n.I18nTest;
import it.measureHistory.DifferentialPeriodsTest;
import it.measureHistory.HistoryUiTest;
IssuePermissionTest.class,
PermissionSearchTest.class,
ProvisioningPermissionTest.class,
+ QualityProfileAdminPermissionTest.class,
// measure history
DifferentialPeriodsTest.class,
HistoryUiTest.class,
--- /dev/null
+/*
+ * SonarQube
+ * 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 it.authorisation;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.selenium.Selenese;
+import it.Category1Suite;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.client.permission.AddUserWsRequest;
+import org.sonarqube.ws.client.permission.PermissionsService;
+import util.user.UserRule;
+
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.runProjectAnalysis;
+
+/**
+ * SONAR-4210
+ */
+public class QualityProfileAdminPermissionTest {
+
+ @ClassRule
+ public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+
+ @ClassRule
+ public static UserRule userRule = UserRule.from(orchestrator);
+
+ static PermissionsService permissionsWsClient;
+
+ @BeforeClass
+ public static void init() {
+ orchestrator.resetData();
+ permissionsWsClient = newAdminWsClient(orchestrator).permissions();
+ runProjectAnalysis(orchestrator, "shared/xoo-sample");
+ }
+
+ @AfterClass
+ public static void clearUsers() throws Exception {
+ userRule.resetUsers();
+ }
+
+ @Test
+ public void permission_should_grant_access_to_profile() {
+ userRule.createUser("not_profileadm", "userpwd");
+ userRule.createUser("profileadm", "papwd");
+ permissionsWsClient.addUser(new AddUserWsRequest().setLogin("profileadm").setPermission("profileadmin"));
+
+ orchestrator.executeSelenese(Selenese.builder().setHtmlTestsInClasspath("administrate-profiles",
+ // Verify normal user is not allowed to do any modification
+ "/authorisation/QualityProfileAdminPermissionTest/normal-user.html",
+ // Verify profile admin is allowed to do modifications
+ "/authorisation/QualityProfileAdminPermissionTest/profile-admin.html"
+ ).build());
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <title>user-cannot-administrate-profile</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+ <tbody>
+ <tr>
+ <td>open</td>
+ <td>/sessions/logout</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>open</td>
+ <td>/sessions/new</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>type</td>
+ <td>id=login</td>
+ <td>not_profileadm</td>
+ </tr>
+ <tr>
+ <td>type</td>
+ <td>id=password</td>
+ <td>userpwd</td>
+ </tr>
+ <tr>
+ <td>clickAndWait</td>
+ <td>name=commit</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>open</td>
+ <td>/profiles</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>waitForText</td>
+ <td>css=.quality-profiles-results</td>
+ <td>*Basic*</td>
+ </tr>
+ <tr>
+ <td>assertNotText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Create*</td>
+ </tr>
+ <tr>
+ <td>assertNotText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Restore Profile*</td>
+ </tr>
+ <tr>
+ <td>assertNotText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Restore Built-in Profiles*</td>
+ </tr>
+ <tr>
+ <td>open</td>
+ <td>/project/profile/sample</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>waitForText</td>
+ <td>id=content</td>
+ <td>*Log In to SonarQube*</td>
+ </tr>
+ <tr>
+ <td>assertText</td>
+ <td>id=login_form</td>
+ <td>glob:*You are not authorized to access this page*</td>
+ </tr>
+ </tbody>
+</table>
+</body>
+</html>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <title>user-can-administrate-profile</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+ <tbody>
+ <tr>
+ <td>open</td>
+ <td>/sessions/logout</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/sessions/new</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>id=login</td>
+ <td>profileadm</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>id=password</td>
+ <td>papwd</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>name=commit</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/profiles</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForText</td>
+ <td>css=.quality-profiles-results</td>
+ <td>*Basic*</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Create*</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Restore Profile*</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>css=.search-navigator-filters</td>
+ <td>*Restore Built-in Profiles*</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/project/profile/sample</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForText</td>
+ <td>id=content</td>
+ <td>*Quality Profiles*</td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>id=submit-xoo</td>
+ <td>glob:*Update*</td>
+</tr>
+</tbody>
+</table>
+</body>
+</html>