]> source.dussan.org Git - sonarqube.git/commitdiff
Move QualityProfileAdminPermissionTest ITs
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 12 Feb 2016 08:28:39 +0000 (09:28 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 12 Feb 2016 11:51:40 +0000 (12:51 +0100)
it/it-tests/src/test/java/it/Category1Suite.java
it/it-tests/src/test/java/it/authorisation/QualityProfileAdminPermissionTest.java [new file with mode: 0644]
it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/normal-user.html [new file with mode: 0644]
it/it-tests/src/test/resources/authorisation/QualityProfileAdminPermissionTest/profile-admin.html [new file with mode: 0644]

index 7169de405651894d4e99e6e67e2b1926e610dccd..8e5b1bdeac5c1830d6f64dfa86da075dd2ffb223 100644 (file)
@@ -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 (file)
index 0000000..befe2c2
--- /dev/null
@@ -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 (file)
index 0000000..6d88e48
--- /dev/null
@@ -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 (file)
index 0000000..0242b44
--- /dev/null
@@ -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>