;;
Category4)
- CATEGORY="Category4|duplication|user"
+ CATEGORY="Category4|duplication|user|webhook"
;;
Category5)
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);
}
--- /dev/null
+/*
+ * 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");
+ }
+}
ReportDumpTest.class,
SSLTest.class,
FavoriteTest.class,
- RedirectTest.class,
- WebhooksTest.class
+ RedirectTest.class
})
public class Category3Suite {
--- /dev/null
+/*
+ * 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();
+}
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;
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();
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,