From a3aa0cfdd9457a14bf2319700d83d7ae6cb461a3 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 5 Sep 2016 09:56:58 +0200 Subject: [PATCH] SONAR-7973 Fix bad reset of emails settings in ITs --- .../src/test/java/it/issue/IssueNotificationsTest.java | 3 +++ .../java/it/qualityGate/QualityGateNotificationTest.java | 3 +++ it/it-tests/src/test/java/it/settings/EmailsTest.java | 6 +++--- it/it-tests/src/test/java/util/ItUtils.java | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java b/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java index cafa74e2919..9c5f6d2c91a 100644 --- a/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java +++ b/it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java @@ -39,6 +39,7 @@ import util.selenium.SeleneseTest; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.resetEmailSettings; import static util.ItUtils.runProjectAnalysis; import static util.ItUtils.setServerProperty; @@ -61,6 +62,7 @@ public class IssueNotificationsTest extends AbstractIssueTest { System.out.println("SMTP Server port: " + smtpServer.getServer().getPort()); // Configure Sonar + resetEmailSettings(ORCHESTRATOR); setServerProperty(ORCHESTRATOR, "email.smtp_host.secured", "localhost"); setServerProperty(ORCHESTRATOR, "email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort())); @@ -94,6 +96,7 @@ public class IssueNotificationsTest extends AbstractIssueTest { } userRule.deactivateUsers(USER_LOGIN); setServerProperty(ORCHESTRATOR, "sonar.issues.defaultAssigneeLogin", null); + resetEmailSettings(ORCHESTRATOR); } @Before diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java index e7843e77c18..08b3ce7c598 100644 --- a/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java @@ -45,6 +45,7 @@ import util.selenium.SeleneseTest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; +import static util.ItUtils.resetEmailSettings; import static util.ItUtils.setServerProperty; public class QualityGateNotificationTest { @@ -62,12 +63,14 @@ public class QualityGateNotificationTest { setServerProperty(orchestrator, "sonar.timemachine.period2", "30"); setServerProperty(orchestrator, "sonar.timemachine.period3", "previous_version"); DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id(); + resetEmailSettings(orchestrator); } @AfterClass public static void resetData() throws Exception { ItUtils.resetPeriods(orchestrator); qgClient().setDefault(DEFAULT_QUALITY_GATE); + resetEmailSettings(orchestrator); } @Before diff --git a/it/it-tests/src/test/java/it/settings/EmailsTest.java b/it/it-tests/src/test/java/it/settings/EmailsTest.java index ecfe91b0e32..329d17483a8 100644 --- a/it/it-tests/src/test/java/it/settings/EmailsTest.java +++ b/it/it-tests/src/test/java/it/settings/EmailsTest.java @@ -40,7 +40,7 @@ import org.subethamail.wiser.WiserMessage; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.groups.Tuple.tuple; import static util.ItUtils.newAdminWsClient; -import static util.ItUtils.resetSettings; +import static util.ItUtils.resetEmailSettings; public class EmailsTest { @@ -55,6 +55,7 @@ public class EmailsTest { public static void before() throws Exception { ADMIN_WS_CLIENT = newAdminWsClient(orchestrator); SETTINGS = ADMIN_WS_CLIENT.settingsService(); + resetEmailSettings(orchestrator); SMTP_SERVER = new Wiser(0); SMTP_SERVER.start(); @@ -66,8 +67,7 @@ public class EmailsTest { if (SMTP_SERVER != null) { SMTP_SERVER.stop(); } - resetSettings(orchestrator, null, "email.smtp_host.secured", "email.smtp_port.secured", "email.smtp_secure_connection.secured", "email.smtp_username.secured", - "email.smtp_password.secured", "email.from", "email.prefix"); + resetEmailSettings(orchestrator); } @Before diff --git a/it/it-tests/src/test/java/util/ItUtils.java b/it/it-tests/src/test/java/util/ItUtils.java index 50c5a5437ac..61207522e0a 100644 --- a/it/it-tests/src/test/java/util/ItUtils.java +++ b/it/it-tests/src/test/java/util/ItUtils.java @@ -53,6 +53,7 @@ import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.services.PropertyDeleteQuery; import org.sonar.wsclient.services.PropertyUpdateQuery; import org.sonarqube.ws.client.HttpConnector; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.setting.ResetRequest; @@ -229,6 +230,10 @@ public class ItUtils { newAdminWsClient(orchestrator).settingsService().reset(ResetRequest.builder().setKeys(keys).setComponentKey(componentKey).build()); } + public static void resetEmailSettings(Orchestrator orchestrator) { + newAdminWsClient(orchestrator).wsConnector().call(new PostRequest("/api/emails/update_configuration")).failIfNotSuccessful(); + } + public static void resetPeriods(Orchestrator orchestrator) { setServerProperty(orchestrator, "sonar.timemachine.period1", null); setServerProperty(orchestrator, "sonar.timemachine.period2", null); -- 2.39.5