aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-12 09:28:39 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-12 12:51:40 +0100
commit7997d13bb54f2c61d1ca4782c3f16a4d06ff7ee4 (patch)
tree15d833857b371f96362a261005b4a99ab43f639a
parentc44564e9d2dc8efe25f6f42a3838da9a4de26d37 (diff)
downloadsonarqube-7997d13bb54f2c61d1ca4782c3f16a4d06ff7ee4.tar.gz
sonarqube-7997d13bb54f2c61d1ca4782c3f16a4d06ff7ee4.zip
Move QualityProfileAdminPermissionTest ITs
-rw-r--r--it/it-tests/src/test/java/it/Category1Suite.java2
-rw-r--r--it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java75
-rw-r--r--it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html79
-rw-r--r--it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html79
4 files changed, 235 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java
index 7169de40565..8e5b1bdeac5 100644
--- a/it/it-tests/src/test/java/it/Category1Suite.java
+++ b/it/it-tests/src/test/java/it/Category1Suite.java
@@ -46,6 +46,7 @@ import it.authorisation.ExecuteAnalysisPermissionTest;
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;
@@ -105,6 +106,7 @@ import static util.ItUtils.xooPlugin;
IssuePermissionTest.class,
PermissionSearchTest.class,
ProvisioningPermissionTest.class,
+ QualityProfileAdminPermissionTest.class,
// measure history
DifferentialPeriodsTest.class,
HistoryUiTest.class,
diff --git a/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java b/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java
new file mode 100644
index 00000000000..befe2c242a2
--- /dev/null
+++ b/it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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());
+ }
+
+}
diff --git a/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html b/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
new file mode 100644
index 00000000000..6d88e48f5c9
--- /dev/null
+++ b/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html
@@ -0,0 +1,79 @@
+<?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>
diff --git a/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html b/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html
new file mode 100644
index 00000000000..0242b441deb
--- /dev/null
+++ b/it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html
@@ -0,0 +1,79 @@
+<?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>