]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8804 Add IT 1682/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 16 Feb 2017 17:34:28 +0000 (18:34 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 17 Feb 2017 08:43:55 +0000 (09:43 +0100)
it/it-tests/src/test/java/it/Category1Suite.java
it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java [new file with mode: 0644]

index 067db2094d2ae5d96422d4b00494d1347d4d788d..af6812ff25aaf8a671fee1edb57a8a8571a2e0f6 100644 (file)
@@ -20,6 +20,7 @@
 package it;
 
 import com.sonar.orchestrator.Orchestrator;
+import it.administration.ProjectsAdministrationTest;
 import it.administration.UsersPageTest;
 import it.authorisation.ExecuteAnalysisPermissionTest;
 import it.authorisation.IssuePermissionTest;
@@ -62,6 +63,7 @@ import static util.ItUtils.xooPlugin;
 @Suite.SuiteClasses({
   // administration
   UsersPageTest.class,
+  ProjectsAdministrationTest.class,
   // project administration
   BulkDeletionTest.class,
   ProjectAdministrationTest.class,
diff --git a/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java b/it/it-tests/src/test/java/it/administration/ProjectsAdministrationTest.java
new file mode 100644 (file)
index 0000000..c6258e7
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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.administration;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import it.Category1Suite;
+import java.sql.SQLException;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.ws.client.permission.RemoveGroupWsRequest;
+import pageobjects.Navigation;
+
+import static com.codeborne.selenide.Condition.text;
+import static com.codeborne.selenide.Selenide.$;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.projectDir;
+
+public class ProjectsAdministrationTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+
+  @Rule
+  public Navigation nav = Navigation.get(orchestrator);
+
+  @Before
+  public void deleteAnalysisData() throws SQLException {
+    orchestrator.resetData();
+  }
+
+  @Test
+  public void return_all_projects_even_when_no_permission() throws Exception {
+    orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample1"));
+    orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProperties("sonar.projectKey", "sample2"));
+    // Remove 'Browse' permission from anyone and 'Admin' permission for admin group on project 2 -> No one can access or admin this
+    // project, expect System Admin
+    newAdminWsClient(orchestrator).permissions().removeGroup(new RemoveGroupWsRequest().setProjectKey("sample2").setGroupName("Anyone").setPermission("user"));
+    newAdminWsClient(orchestrator).permissions().removeGroup(new RemoveGroupWsRequest().setProjectKey("sample2").setGroupName("sonar-administrators").setPermission("admin"));
+
+    nav.logIn().asAdmin().open("/projects_admin");
+    $(".data.zebra")
+      .shouldHave(text("sample1"))
+      .shouldHave(text("sample2"));
+  }
+
+}