From 3fadf21d94d40ca3eb1e47843cbd0262f43b0195 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 8 Feb 2016 17:47:37 +0100 Subject: [PATCH] move in IT SystemAdminPermissionTest from it-core --- .../SystemAdminPermissionTest.java | 120 +++++++++++++ .../change-other-measure-filter-owner.html | 164 ++++++++++++++++++ .../change-own-measure-filter-owner.html | 134 ++++++++++++++ ...shared-global-dashboard-owner-failure.html | 104 +++++++++++ .../change-shared-global-dashboard-owner.html | 104 +++++++++++ ...hared-project-dashboard-owner-failure.html | 109 ++++++++++++ ...change-shared-project-dashboard-owner.html | 104 +++++++++++ .../change-system-measure-filter-owner.html | 89 ++++++++++ 8 files changed, 928 insertions(+) create mode 100644 it/it-tests/src/test/java/it/permissions/SystemAdminPermissionTest.java create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-other-measure-filter-owner.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-own-measure-filter-owner.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner-failure.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner-failure.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner.html create mode 100644 it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-system-measure-filter-owner.html diff --git a/it/it-tests/src/test/java/it/permissions/SystemAdminPermissionTest.java b/it/it-tests/src/test/java/it/permissions/SystemAdminPermissionTest.java new file mode 100644 index 00000000000..5f04b26d796 --- /dev/null +++ b/it/it-tests/src/test/java/it/permissions/SystemAdminPermissionTest.java @@ -0,0 +1,120 @@ +/* + * 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.permissions; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarScanner; +import com.sonar.orchestrator.selenium.Selenese; +import it.Category4Suite; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonarqube.ws.client.PostRequest; +import org.sonarqube.ws.client.WsClient; +import util.ItUtils; + +public class SystemAdminPermissionTest { + + @ClassRule + public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR; + + @BeforeClass + public static void setUpUsers() { + orchestrator.resetData(); + + WsClient client = ItUtils.newAdminWsClient(orchestrator); + + createUser(client, "can_share", "password"); + addPermission("can_share", "shareDashboard"); + + createUser(client, "cannot_share", "password"); + } + + @AfterClass + public static void reset() { + WsClient client = ItUtils.newAdminWsClient(orchestrator); + deactivateUser(client, "can_share"); + deactivateUser(client, "cannot_share"); + } + + /** + * SONAR-4398 + */ + @Test + public void should_change_ownership_of_shared_measure_filter() throws Exception { + // change-own-measure-filter-owner.html + // 1 - as admin, create measure filter, shared with every one + // 2 - as admin, edit filter and set owner to can_share + seleniumSuite("change-measure-filter-ownership", + "/permissions/SystemAdminPermissionTest/change-own-measure-filter-owner.html", + "/permissions/SystemAdminPermissionTest/change-other-measure-filter-owner.html", + "/permissions/SystemAdminPermissionTest/change-system-measure-filter-owner.html"); + } + + /** + * SONAR-4136 + */ + @Test + public void should_change_ownership_of_shared_global_dashboard() throws Exception { + seleniumSuite("change-global-dashboard-ownership", + "/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner.html", + "/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner-failure.html"); + } + + /** + * SONAR-4136 + */ + @Test + public void should_change_ownership_of_shared_project_dashboard() throws Exception { + orchestrator.executeBuild(SonarScanner.create(ItUtils.projectDir("shared/xoo-sample"))); + + seleniumSuite("change-project-dashboard-ownership", + "/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner.html", + "/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner-failure.html"); + } + + private void seleniumSuite(String suiteName, String... tests) { + Selenese selenese = Selenese.builder().setHtmlTestsInClasspath(suiteName, tests).build(); + orchestrator.executeSelenese(selenese); + } + + private static void addPermission(String login, String permission) { + orchestrator.getServer().adminWsClient().post("api/permissions/add_user", + "login", login, + "permission", permission); + } + + private static void createUser(WsClient client, String login, String password) { + client.wsConnector().call( + new PostRequest("api/users/create") + .setParam("login", login) + .setParam("name", login) + .setParam("password", password) + ); + } + + private static void deactivateUser(WsClient client, String login) { + client.wsConnector().call( + new PostRequest("/api/users/deactivate") + .setParam("login", login) + ); + } +} diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-other-measure-filter-owner.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-other-measure-filter-owner.html new file mode 100644 index 00000000000..bd7ab433180 --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-other-measure-filter-owner.html @@ -0,0 +1,164 @@ + + + + + + change-other-measure-filter-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
storeEval'filter_'+(new Date()).getTime()FILTER_NAME
open/sessions/logout
open/sessions/new
typelogincan_share
typepasswordpassword
clickAndWaitcommit
open/measures
waitForElementPresentclass=navigator-filter-submit
clickclass=navigator-filter-submit
waitForTextcontent*Save As*
clicksave-as
waitForTextsave-as-filter-form*Save Filter*
typename${FILTER_NAME}
clickname=shared
clickAndWaitsave-as-submit
waitForTextfilter-titleglob:*${FILTER_NAME}*Shared with all users*
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/measures
waitForElementPresentid=manage-favorites
clickAndWaitid=manage-favorites
assertTextshared-filtersglob:*${FILTER_NAME}*
clickedit_system_${FILTER_NAME}
waitForTextedit-filter-form*Edit Filter*
typeselect-filter-owneradmin
clickAndWaitsave-submit
assertTextfilter-titleglob:*${FILTER_NAME}*Shared with all users*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-own-measure-filter-owner.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-own-measure-filter-owner.html new file mode 100644 index 00000000000..fda11c0eb7a --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-own-measure-filter-owner.html @@ -0,0 +1,134 @@ + + + + + + change-own-measure-filter-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
storeEval'filter_'+(new Date()).getTime()FILTER_NAME
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/measures
waitForElementPresentclass=navigator-filter-submit
clickclass=navigator-filter-submit
waitForTextcontent*Save As*
clicksave-as
waitForTextsave-as-filter-form*Save Filter*
typename${FILTER_NAME}
clickname=shared
clickAndWaitsave-as-submit
waitForTextfilter-titleglob:*${FILTER_NAME}*Shared with all users*
waitForElementPresentid=manage-favorites
clickAndWaitid=manage-favorites
assertTextmy-filtersglob:*${FILTER_NAME}*
clickedit_${FILTER_NAME}
waitForTextedit-filter-form*Edit Filter*
typeselect-filter-ownercan_share
clickAndWaitsave-submit
assertTextfilter-titleglob:*${FILTER_NAME}*Shared by can_share*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner-failure.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner-failure.html new file mode 100644 index 00000000000..d89c7cb54af --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner-failure.html @@ -0,0 +1,104 @@ + + + + + + change-shared-global-dashboard-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/dashboards
typeloginadmin
typepasswordadmin
clickAndWaitcommit
clickcreate-link-dashboard
waitForVisiblecss=div.modal-body
typenameshared-global-dashboard-fail
storeValuenameDASHBOARD_NAME
clickname=shared
clickAndWaitsave-submit
waitForVisibleedit-${DASHBOARD_NAME}
clickedit-${DASHBOARD_NAME}
waitForVisiblecss=div.modal-body
typeselect-dashboard-ownercannot_share
clicksave-submit
waitForVisiblecss=div.modal-body > p.error
assertTextcss=div.modal-body > p.errorglob:*User cannot own this dashboard because of insufficient rights*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner.html new file mode 100644 index 00000000000..46819e977fc --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-global-dashboard-owner.html @@ -0,0 +1,104 @@ + + + + + + change-shared-global-dashboard-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/dashboards
typeloginadmin
typepasswordadmin
clickAndWaitcommit
waitForVisiblecreate-link-dashboard
clickcreate-link-dashboard
waitForVisiblecss=div.modal-body
typenameshared-global-dashboard
storeValuenameDASHBOARD_NAME
clickname=shared
clickAndWaitsave-submit
waitForVisibleedit-${DASHBOARD_NAME}
clickedit-${DASHBOARD_NAME}
waitForVisiblecss=div.modal-body
typeselect-dashboard-ownercan_share
clickAndWaitsave-submit
assertTextdashboardsglob:*can_share*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner-failure.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner-failure.html new file mode 100644 index 00000000000..7a4545dcfd3 --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner-failure.html @@ -0,0 +1,109 @@ + + + + + + change-shared-project-dashboard-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/dashboards?resource=sample
clickcreate-link-dashboard
waitForVisiblecss=div.modal-body
typenameshared-project-dashboard-fail
storeValuenameDASHBOARD_NAME
clickname=shared
clickAndWaitsave-submit
waitForVisibleedit-${DASHBOARD_NAME}
clickedit-${DASHBOARD_NAME}
waitForVisiblecss=div.modal-body
typeselect-dashboard-ownercannot_share
clicksave-submit
waitForVisiblecss=div.modal-body > p.error
assertTextcss=div.modal-body > p.errorglob:*User cannot own this dashboard because of insufficient rights*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner.html new file mode 100644 index 00000000000..05bfe502af7 --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-shared-project-dashboard-owner.html @@ -0,0 +1,104 @@ + + + + + + change-shared-project-dashboard-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/dashboards?resource=sample
clickcreate-link-dashboard
waitForVisiblecss=div.modal-body
typenameshared-project-dashboard
storeValuenameDASHBOARD_NAME
clickname=shared
clickAndWaitsave-submit
waitForVisibleedit-${DASHBOARD_NAME}
clickedit-${DASHBOARD_NAME}
waitForVisiblecss=div.modal-body
typeselect-dashboard-ownercan_share
clickAndWaitsave-submit
assertTextdashboardsglob:*can_share*
+ + diff --git a/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-system-measure-filter-owner.html b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-system-measure-filter-owner.html new file mode 100644 index 00000000000..0379982322e --- /dev/null +++ b/it/it-tests/src/test/resources/permissions/SystemAdminPermissionTest/change-system-measure-filter-owner.html @@ -0,0 +1,89 @@ + + + + + + change-system-measure-filter-owner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
storeEval'filter_'+(new Date()).getTime()FILTER_NAME
open/sessions/logout
open/sessions/new
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/measures
waitForElementPresentid=manage-favorites
clickAndWaitid=manage-favorites
assertTextshared-filtersglob:*My favourites*
clickedit_system_my-favourites
waitForTextedit-filter-form*Edit Filter*
typeselect-filter-owneradmin
clickAndWaitsave-submit
assertTextfilter-titleglob:*My favourites*Shared with all users*
+ + -- 2.39.5