aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-11-20 12:36:09 +0100
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-11-24 17:22:33 +0100
commitad4567f4361fa1843cd57dc614e0ed0c653c86d2 (patch)
treed4cbcdc63fcfc8a8cdc477136c679dfd4367b4bd /server
parentafff558a2cac07019ff5886ccdada9eb25aa1b0c (diff)
downloadsonarqube-ad4567f4361fa1843cd57dc614e0ed0c653c86d2.tar.gz
sonarqube-ad4567f4361fa1843cd57dc614e0ed0c653c86d2.zip
Update users permission IT's
Diffstat (limited to 'server')
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java4
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java98
-rw-r--r--server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java52
3 files changed, 154 insertions, 0 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java
index 25fc6937c8e..996f46d3557 100644
--- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java
+++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java
@@ -178,6 +178,10 @@ public class Navigation {
return open("/account/notifications", NotificationsPage.class);
}
+ public UsersManagementPage openUsersManagement() {
+ return open("/admin/users", UsersManagementPage.class);
+ }
+
public ProjectPermissionsPage openProjectPermissions(String projectKey) {
String url = "/project_roles?id=" + escape(projectKey);
return open(url, ProjectPermissionsPage.class);
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java
new file mode 100644
index 00000000000..0cd63650f10
--- /dev/null
+++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementItem.java
@@ -0,0 +1,98 @@
+/*
+ * 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 org.sonarqube.qa.util.pageobjects;
+
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.Selenide.$$;
+
+public class UsersManagementItem {
+ private final SelenideElement elt;
+
+ public UsersManagementItem(SelenideElement elt) {
+ this.elt = elt;
+ }
+
+ public UsersManagementItem hasTokensCount(Integer count) {
+ this.elt.$(".js-user-tokens").should(Condition.exist).parent().shouldHave(Condition.text(count.toString()));
+ return this;
+ }
+
+ public UsersManagementItem generateToken(String name) {
+ this.openTokenModal();
+ $(".modal #generate-token-form input").should(Condition.exist).sendKeys(name);
+ $(".modal #generate-token-form .js-generate-token").should(Condition.exist).click();
+ $(".modal code").should(Condition.exist);
+ getTokenRow(name).should(Condition.exist);
+ closeModal();
+ return this;
+ }
+
+ public UsersManagementItem revokeToken(String name) {
+ this.openTokenModal();
+ SelenideElement tokenRow = getTokenRow(name).should(Condition.exist);
+ tokenRow.$("button").should(Condition.exist).shouldHave(Condition.text("Revoke")).click();
+ tokenRow.$("button").shouldHave(Condition.text("Sure?")).click();
+ getTokenRow(name).shouldNot(Condition.exist);
+ closeModal();
+ return this;
+ }
+
+ public UsersManagementItem changePassword(String oldPwd, String newPwd) {
+ this.elt.$("button.dropdown-toggle").should(Condition.exist).click();
+ this.elt.$(".js-user-change-password").shouldBe(Condition.visible).click();
+ isModalOpen("Change password");
+ $(".modal #old-user-password").should(Condition.exist).sendKeys(oldPwd);
+ $(".modal #user-password").should(Condition.exist).sendKeys(newPwd);
+ $(".modal #confirm-user-password").should(Condition.exist).sendKeys(newPwd);
+ $(".modal .js-confirm").click();
+ $(".modal").shouldNot(Condition.exist);
+ return this;
+ }
+
+ public UsersManagementItem deactivateUser() {
+ this.elt.$("button.dropdown-toggle").should(Condition.exist).click();
+ this.elt.$(".js-user-deactivate").should(Condition.exist).click();
+ isModalOpen("Deactivate User");
+ $(".modal .js-confirm").should(Condition.exist).click();
+ return this;
+ }
+
+ private void openTokenModal() {
+ if (!$(".modal").exists()) {
+ this.elt.$(".js-user-tokens").should(Condition.exist).click();
+ }
+ isModalOpen("Tokens");
+ }
+
+ private static void closeModal() {
+ $(".modal .js-modal-close").should(Condition.exist).click();
+ }
+
+ private static void isModalOpen(String title) {
+ $(".modal .modal-head").should(Condition.exist).shouldHave(Condition.text(title));
+ }
+
+ private static SelenideElement getTokenRow(String name) {
+ return $$(".modal tr").findBy(Condition.text(name));
+ }
+}
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java
new file mode 100644
index 00000000000..efc2edf913d
--- /dev/null
+++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/UsersManagementPage.java
@@ -0,0 +1,52 @@
+/*
+ * 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 org.sonarqube.qa.util.pageobjects;
+
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.Selenide.$$;
+
+public class UsersManagementPage {
+ public UsersManagementPage() {
+ $("#users-page").shouldBe(Condition.visible);
+ }
+
+ public UsersManagementPage hasUsersCount(Integer count) {
+ $$(".js-user-login").shouldHaveSize(count);
+ return this;
+ }
+
+ public UsersManagementItem getUser(String login) {
+ SelenideElement elt = $$(".js-user-login").findBy(Condition.text(login)).should(Condition.exist);
+ return new UsersManagementItem(elt.parent().parent().parent());
+ }
+
+ public UsersManagementPage createUser(String login) {
+ $("#users-create").should(Condition.exist).click();
+ $(".modal .modal-head").should(Condition.exist).shouldHave(Condition.text("Create User"));
+ $(".modal #create-user-login").should(Condition.exist).sendKeys(login);
+ $(".modal #create-user-name").should(Condition.exist).sendKeys("Name of " + login);
+ $(".modal #create-user-password").should(Condition.exist).sendKeys(login);
+ $(".modal .js-confirm").should(Condition.exist).click();
+ return this;
+ }
+}