]> source.dussan.org Git - sonarqube.git/commitdiff
bugfix: project permissions page shows all projects
authorStas Vilchik <vilchiks@gmail.com>
Mon, 9 Nov 2015 10:55:48 +0000 (11:55 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 9 Nov 2015 10:55:48 +0000 (11:55 +0100)
it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java [new file with mode: 0644]
it/it-tests/src/test/resources/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html [new file with mode: 0644]
server/sonar-web/src/main/js/apps/project-permissions/app.js

diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectPermissionsTest.java
new file mode 100644 (file)
index 0000000..504dbe9
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.projectAdministration;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarRunner;
+import com.sonar.orchestrator.selenium.Selenese;
+import it.Category1Suite;
+import org.junit.ClassRule;
+import org.junit.Test;
+import util.selenium.SeleneseTest;
+
+import static util.ItUtils.projectDir;
+
+public class ProjectPermissionsTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+
+  @Test
+  public void test_project_permissions_page_shows_only_single_project() throws Exception {
+    executeBuild("project-permissions-project", "Test Project");
+    executeBuild("project-permissions-project-2", "Another Test Project");
+
+    Selenese selenese = Selenese.builder().setHtmlTestsInClasspath("project_permissions_page_shows_only_single_project",
+      "/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html"
+    ).build();
+    new SeleneseTest(selenese).runOn(orchestrator);
+  }
+
+  private void executeBuild(String projectKey, String projectName) {
+    orchestrator.executeBuild(
+      SonarRunner.create(projectDir("shared/xoo-sample"))
+        .setProjectKey(projectKey)
+        .setProjectName(projectName)
+    );
+  }
+}
diff --git a/it/it-tests/src/test/resources/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html b/it/it-tests/src/test/resources/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html
new file mode 100644 (file)
index 0000000..c9eb0c8
--- /dev/null
@@ -0,0 +1,70 @@
+<?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"/>
+  <link rel="selenium.base" href="http://localhost:49506"/>
+  <title>test_project_overview_after_first_analysis</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+  <thead>
+  <tr>
+    <td rowspan="1" colspan="3">test_project_overview_after_first_analysis</td>
+  </tr>
+  </thead>
+  <tbody>
+  <tr>
+    <td>open</td>
+    <td>/sonar/sessions/logout</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>open</td>
+    <td>/sonar/sessions/login</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>type</td>
+    <td>login</td>
+    <td>admin</td>
+  </tr>
+  <tr>
+    <td>type</td>
+    <td>password</td>
+    <td>admin</td>
+  </tr>
+  <tr>
+    <td>clickAndWait</td>
+    <td>commit</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>open</td>
+    <td>/sonar/project_roles?id=project-permissions-project</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>waitForElementPresent</td>
+    <td>css=#projects</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>assertNotText</td>
+    <td>css=#projects</td>
+    <td>*Another Test Project*</td>
+  </tr>
+  <tr>
+    <td>assertElementNotPresent</td>
+    <td>css=footer</td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>assertElementNotPresent</td>
+    <td>css=.search-box</td>
+    <td></td>
+  </tr>
+  </tbody>
+</table>
+</body>
+</html>
index 299c94f9bb7197ada19501d487195ac45c83d59a..b00e13b9a6dd40d71d57da5763ea5794827dbff6 100644 (file)
@@ -11,6 +11,6 @@ function requestPermissionTemplates () {
 window.sonarqube.appStarted.then(options => {
   requestPermissionTemplates().done(r => {
     var el = document.querySelector(options.el);
-    ReactDOM.render(<Main permissionTemplates={r.permissionTemplates} componentId={options.componentId}/>, el);
+    ReactDOM.render(<Main permissionTemplates={r.permissionTemplates} componentId={window.sonarqube.componentId}/>, el);
   });
 });