]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7973 Fix bad reset of emails settings in ITs
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 5 Sep 2016 07:56:58 +0000 (09:56 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 5 Sep 2016 07:56:58 +0000 (09:56 +0200)
it/it-tests/src/test/java/it/issue/IssueNotificationsTest.java
it/it-tests/src/test/java/it/qualityGate/QualityGateNotificationTest.java
it/it-tests/src/test/java/it/settings/EmailsTest.java
it/it-tests/src/test/java/util/ItUtils.java

index cafa74e29190ccaf10040e8cfefaf2fd69751e2a..9c5f6d2c91adb4070c7fe31ae6222c865c5eb3a2 100644 (file)
@@ -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
index e7843e77c180a1453369c336a21d760d52490166..08b3ce7c5980cf0a95a4a1e9e60b568876ae0fbb 100644 (file)
@@ -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
index ecfe91b0e32000e893d2e5a777c4e9a66b4266e7..329d17483a881ccd610b2584b0f66077a9e8b563 100644 (file)
@@ -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
index 50c5a5437ac91812530e87530521af9eed718b75..61207522e0a91831010b1af6871b3e096a2ba97c 100644 (file)
@@ -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);