aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-09-06 16:02:40 +0200
committerGitHub <noreply@github.com>2016-09-06 16:02:40 +0200
commit710344da59f61f395593782deb1c342d473da5bf (patch)
tree5b5c626aada5c2598cb896afa10c8cb05af769ae /it
parent03c2d379e96b18d0afcf0b50d9f6bac2d1465d06 (diff)
downloadsonarqube-710344da59f61f395593782deb1c342d473da5bf.tar.gz
sonarqube-710344da59f61f395593782deb1c342d473da5bf.zip
SONAR-7980 Rewrite the "Licenses" page (#1207)
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/settings/LicensesPageTest.java84
-rw-r--r--it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java6
-rw-r--r--it/it-tests/src/test/java/pageobjects/Navigation.java5
-rw-r--r--it/it-tests/src/test/java/pageobjects/licenses/LicenseItem.java46
-rw-r--r--it/it-tests/src/test/java/pageobjects/licenses/LicensesPage.java52
-rw-r--r--it/it-tests/src/test/resources/settings/SettingsTest/display-license.html69
-rw-r--r--it/it-tests/src/test/resources/settings/SettingsTest/display-untyped-license.html69
-rw-r--r--it/it-tests/src/test/resources/settings/SettingsTest/ignore-corrupted-license.html59
8 files changed, 187 insertions, 203 deletions
diff --git a/it/it-tests/src/test/java/it/settings/LicensesPageTest.java b/it/it-tests/src/test/java/it/settings/LicensesPageTest.java
new file mode 100644
index 00000000000..4fe48857884
--- /dev/null
+++ b/it/it-tests/src/test/java/it/settings/LicensesPageTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.settings;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.ws.Settings.ValuesWsResponse;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.setting.ValuesRequest;
+import pageobjects.Navigation;
+import pageobjects.licenses.LicenseItem;
+import pageobjects.licenses.LicensesPage;
+
+import static com.codeborne.selenide.Condition.text;
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.pluginArtifact;
+
+public class LicensesPageTest {
+ private static Orchestrator orchestrator;
+ private static WsClient wsClient;
+
+ @Rule
+ public Navigation nav = Navigation.get(orchestrator);
+
+ @BeforeClass
+ public static void start() {
+ orchestrator = Orchestrator.builderEnv()
+ .addPlugin(pluginArtifact("license-plugin"))
+ .build();
+ orchestrator.start();
+
+ wsClient = newAdminWsClient(orchestrator);
+ }
+
+ @AfterClass
+ public static void stop() {
+ if (orchestrator != null) {
+ orchestrator.stop();
+ }
+ }
+
+ @Test
+ public void display_licenses() {
+ LicensesPage page = nav.logIn().asAdmin().openLicenses();
+
+ page.getLicenses().shouldHaveSize(2);
+ page.getLicensesAsItems().get(0).getName().shouldHave(text("typed.license.secured"));
+ page.getLicensesAsItems().get(1).getName().shouldHave(text("untyped.license.secured"));
+ }
+
+ @Test
+ public void change_licenses() {
+ String EXAMPLE_LICENSE = "TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo=";
+
+ LicensesPage page = nav.logIn().asAdmin().openLicenses();
+ LicenseItem licenseItem = page.getLicenseByKey("typed.license.secured");
+ licenseItem.setLicense(EXAMPLE_LICENSE);
+
+ ValuesWsResponse response = wsClient.settingsService()
+ .values(ValuesRequest.builder().setKeys("typed.license.secured").build());
+ assertThat(response.getSettings(0).getValue()).isEqualTo(EXAMPLE_LICENSE);
+ }
+}
diff --git a/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java b/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java
index 67b2eefa62f..7280a23305d 100644
--- a/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java
+++ b/it/it-tests/src/test/java/it/settings/SettingsTestRestartingOrchestrator.java
@@ -72,12 +72,6 @@ public class SettingsTestRestartingOrchestrator {
// test encryption
"/settings/SettingsTest/generate-secret-key.html",
"/settings/SettingsTest/encrypt-text.html"
-
- // test licenses
- // TODO enable when license page will be rewritten
- // "/settings/SettingsTest/ignore-corrupted-license.html",
- // "/settings/SettingsTest/display-license.html",
- // "/settings/SettingsTest/display-untyped-license.html"
).build();
new SeleneseTest(selenese).runOn(orchestrator);
}
diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java
index 28a99e4b3f8..018fdbaaa1a 100644
--- a/it/it-tests/src/test/java/pageobjects/Navigation.java
+++ b/it/it-tests/src/test/java/pageobjects/Navigation.java
@@ -29,6 +29,7 @@ import java.net.URLEncoder;
import javax.annotation.Nullable;
import org.junit.rules.ExternalResource;
import org.openqa.selenium.By;
+import pageobjects.licenses.LicensesPage;
import pageobjects.settings.SettingsPage;
import static com.codeborne.selenide.Selenide.$;
@@ -95,6 +96,10 @@ public class Navigation extends ExternalResource {
return open(url, SettingsPage.class);
}
+ public LicensesPage openLicenses() {
+ return open("/settings/licenses", LicensesPage.class);
+ }
+
public void open(String relativeUrl) {
Selenide.open(relativeUrl);
}
diff --git a/it/it-tests/src/test/java/pageobjects/licenses/LicenseItem.java b/it/it-tests/src/test/java/pageobjects/licenses/LicenseItem.java
new file mode 100644
index 00000000000..2df9869b75a
--- /dev/null
+++ b/it/it-tests/src/test/java/pageobjects/licenses/LicenseItem.java
@@ -0,0 +1,46 @@
+/*
+ * 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 pageobjects.licenses;
+
+import com.codeborne.selenide.SelenideElement;
+
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$;
+
+public class LicenseItem {
+
+ private final SelenideElement elt;
+
+ public LicenseItem(SelenideElement elt) {
+ this.elt = elt;
+ }
+
+ public SelenideElement getName() {
+ return elt.find(".js-product");
+ }
+
+ public LicenseItem setLicense(String value) {
+ elt.find(".js-change").click();
+ $("#license-input").shouldBe(visible).val(value);
+ $(".js-modal-submit").click();
+ $("#license-input").shouldNotBe(visible);
+ return this;
+ }
+}
diff --git a/it/it-tests/src/test/java/pageobjects/licenses/LicensesPage.java b/it/it-tests/src/test/java/pageobjects/licenses/LicensesPage.java
new file mode 100644
index 00000000000..129d6c6844b
--- /dev/null
+++ b/it/it-tests/src/test/java/pageobjects/licenses/LicensesPage.java
@@ -0,0 +1,52 @@
+/*
+ * 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 pageobjects.licenses;
+
+import com.codeborne.selenide.ElementsCollection;
+import com.codeborne.selenide.SelenideElement;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.Selenide.$$;
+
+public class LicensesPage {
+
+ public LicensesPage() {
+ $("#licenses-page").shouldBe(visible);
+ }
+
+ public ElementsCollection getLicenses() {
+ return $$(".js-license");
+ }
+
+ public List<LicenseItem> getLicensesAsItems() {
+ return getLicenses()
+ .stream()
+ .map(LicenseItem::new)
+ .collect(Collectors.toList());
+ }
+
+ public LicenseItem getLicenseByKey(String key) {
+ SelenideElement element = $(".js-license[data-license-key=\"" + key + "\"]");
+ return new LicenseItem(element);
+ }
+}
diff --git a/it/it-tests/src/test/resources/settings/SettingsTest/display-license.html b/it/it-tests/src/test/resources/settings/SettingsTest/display-license.html
deleted file mode 100644
index f2f1d31bb87..00000000000
--- a/it/it-tests/src/test/resources/settings/SettingsTest/display-license.html
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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>display-license</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>/settings?category=general</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=login</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=password</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>clickAndWait</td>
- <td>name=commit</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=input_typed.license.secured</td>
- <td>TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo=</td>
- </tr>
- <tr>
- <td>click</td>
- <td>id=submit_settings</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_typed.license.secured</td>
- <td>*autocontrol*</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_typed.license.secured</td>
- <td>*Developpers*</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_typed.license.secured</td>
- <td>*2012*</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>
diff --git a/it/it-tests/src/test/resources/settings/SettingsTest/display-untyped-license.html b/it/it-tests/src/test/resources/settings/SettingsTest/display-untyped-license.html
deleted file mode 100644
index ae353cf7618..00000000000
--- a/it/it-tests/src/test/resources/settings/SettingsTest/display-untyped-license.html
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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>display-untyped-license</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>/settings?category=general</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=login</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=password</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>clickAndWait</td>
- <td>name=commit</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=input_untyped.license.secured</td>
- <td>TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo=</td>
- </tr>
- <tr>
- <td>click</td>
- <td>submit_settings</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_untyped.license.secured</td>
- <td>*autocontrol*</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_untyped.license.secured</td>
- <td>*Developpers*</td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_untyped.license.secured</td>
- <td>*2012*</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>
diff --git a/it/it-tests/src/test/resources/settings/SettingsTest/ignore-corrupted-license.html b/it/it-tests/src/test/resources/settings/SettingsTest/ignore-corrupted-license.html
deleted file mode 100644
index e05b5727102..00000000000
--- a/it/it-tests/src/test/resources/settings/SettingsTest/ignore-corrupted-license.html
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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>ignore-corrupted-license</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>/settings?category=general</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=login</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=password</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>clickAndWait</td>
- <td>name=commit</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>id=input_typed.license.secured</td>
- <td>ABCDE</td>
- </tr>
- <tr>
- <td>click</td>
- <td>id=submit_settings</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForText</td>
- <td>block_typed.license.secured</td>
- <td>*Product*-*Organization*-*Expiration*-*</td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>