From: Grégoire Aubert Date: Fri, 2 Feb 2018 15:29:10 +0000 (+0100) Subject: SONAR-10344 Create IT's for webhooks console page X-Git-Tag: 7.5~1621 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=85f7f977c021ea177d3f2442efa114997e313aa2;p=sonarqube.git SONAR-10344 Create IT's for webhooks console page --- diff --git a/cix.sh b/cix.sh index 715a27db7c9..a6d4f3a2491 100755 --- a/cix.sh +++ b/cix.sh @@ -43,7 +43,7 @@ case "$RUN_ACTIVITY" in ;; Category4) - CATEGORY="Category4|duplication|user" + CATEGORY="Category4|duplication|user|webhook" ;; Category5) 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 ede43929a06..073df461b8b 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 @@ -202,6 +202,18 @@ public class Navigation { return open("/organizations/" + orgKey + "/projects_management", ProjectsManagementPage.class); } + public WebhooksPage openWebhooks() { + return open("/admin/webhooks", WebhooksPage.class); + } + + public WebhooksPage openOrganizationWebhooks(String orgKey) { + return open("/organizations/" + orgKey + "/webhooks", WebhooksPage.class); + } + + public WebhooksPage openProjectWebhooks(String projectKey) { + return open("/project/webhooks?id="+ projectKey, WebhooksPage.class); + } + public LoginPage openLogin() { return open("/sessions/login", LoginPage.class); } diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java new file mode 100644 index 00000000000..af6c8c6f816 --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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.ElementsCollection; + +import static com.codeborne.selenide.Condition.exist; +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$; + +public class WebhooksPage { + + public WebhooksPage() { + $(".page-header .page-title").should(exist).shouldHave(text("Webhooks")); + } + + public WebhooksPage hasWebhook(String text) { + getWebhooks().find(text(text)).should(exist); + return this; + } + + public WebhooksPage countWebhooks(Integer number) { + getWebhooks().shouldHaveSize(number); + return this; + } + + private static ElementsCollection getWebhooks() { + return $$(".boxed-group tbody tr"); + } +} diff --git a/tests/src/test/java/org/sonarqube/tests/Category3Suite.java b/tests/src/test/java/org/sonarqube/tests/Category3Suite.java index 60fbc385ab8..2924b41373f 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category3Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category3Suite.java @@ -65,8 +65,7 @@ import static util.ItUtils.xooPlugin; ReportDumpTest.class, SSLTest.class, FavoriteTest.class, - RedirectTest.class, - WebhooksTest.class + RedirectTest.class }) public class Category3Suite { diff --git a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksSuite.java b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksSuite.java new file mode 100644 index 00000000000..261c88ff139 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksSuite.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 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.tests.webhook; + +import com.sonar.orchestrator.Orchestrator; +import org.junit.ClassRule; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import static util.ItUtils.xooPlugin; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + WebhooksTest.class +}) +public class WebhooksSuite { + + @ClassRule + public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv() + .addPlugin(xooPlugin()) + + // reduce memory for Elasticsearch + .setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m") + + .build(); +} diff --git a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java index 0bbed529135..2531d8674b1 100644 --- a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java @@ -33,12 +33,14 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; -import org.sonarqube.tests.Category3Suite; +import org.sonarqube.qa.util.pageobjects.WebhooksPage; import org.sonarqube.ws.Issues.Issue; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.Qualitygates; import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; +import org.sonarqube.ws.Users; +import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.Webhooks; import org.sonarqube.ws.client.HttpException; import org.sonarqube.ws.client.WsClient; @@ -67,7 +69,7 @@ public class WebhooksTest { private static final String PROJECT_WEBHOOK_PROPERTY = "sonar.webhooks.project"; @ClassRule - public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR; + public static Orchestrator orchestrator = WebhooksSuite.ORCHESTRATOR; @ClassRule public static ExternalServer externalServer = new ExternalServer(); @@ -287,6 +289,28 @@ public class WebhooksTest { assertThat(gate.get("status")).isEqualTo("OK"); } + @Test + public void list_global_webhooks() { + enableGlobalWebhooks(new Webhook("foo", "http://foo.bar"), new Webhook("bar", "https://bar.baz/test")); + tester.wsClient().users().skipOnboardingTutorial(); + WebhooksPage webhooksPage = tester.openBrowser().logIn().submitCredentials("admin").openWebhooks(); + webhooksPage + .countWebhooks(2) + .hasWebhook("http://foo.bar"); + } + + @Test + public void list_project_webhooks() { + analyseProject(); + enableProjectWebhooks(PROJECT_KEY, new Webhook("foo", "http://foo.bar"), new Webhook("bar", "https://bar.baz/test")); + User user = tester.users().generateAdministratorOnDefaultOrganization(); + tester.wsClient().users().skipOnboardingTutorial(); + WebhooksPage webhooksPage = tester.openBrowser().logIn().submitCredentials(user.getLogin()).openProjectWebhooks(PROJECT_KEY); + webhooksPage + .countWebhooks(2) + .hasWebhook("http://foo.bar"); + } + private void analyseProject() { runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.projectKey", PROJECT_KEY,