Skip to content
Snippets Groups Projects
Commit caffcc99 authored by Eduard Moraru's avatar Eduard Moraru
Browse files

XWIKI-11801: ResetPassword feature is broken by password salting

- Using TestUtils methods to directly set and restore the email settings in the test setup instead of using the mail UI.
parent 6b7a3382
No related branches found
No related tags found
No related merge requests found
......@@ -69,19 +69,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- Some tests require mail setup and interaction (e.g. ResetPasswordTest) -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-mail-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-mail-test-pageobjects</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
......
......@@ -36,10 +36,8 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.xwiki.administration.test.po.AdministrationPage;
import org.xwiki.administration.test.po.ResetPasswordCompletePage;
import org.xwiki.administration.test.po.ResetPasswordPage;
import org.xwiki.mail.test.po.SendMailAdministrationSectionPage;
import org.xwiki.test.ui.AbstractTest;
import org.xwiki.test.ui.SuperAdminAuthenticationRule;
import org.xwiki.test.ui.po.LoginPage;
......@@ -61,8 +59,6 @@ public class ResetPasswordTest extends AbstractTest
private GreenMail mail;
private Map<String, String> currentEmailSettings;
@Before
public void startMail()
{
......@@ -84,53 +80,17 @@ public void stopMail()
private void configureEmail()
{
// Open administration.
AdministrationPage administrationPage = AdministrationPage.gotoPage();
// Sanity check.
Assert.assertTrue(administrationPage.hasSection("Email", "Mail Sending"));
// Open the Mail Sending section and configure it to use the local test mail server.
administrationPage.clickSection("Email", "Mail Sending");
SendMailAdministrationSectionPage sendMailPage = new SendMailAdministrationSectionPage();
// First, store the current settings so we can set them back once the test is done
currentEmailSettings = new HashMap<String, String>();
currentEmailSettings.put("host", sendMailPage.getHost());
currentEmailSettings.put("port", sendMailPage.getPort());
currentEmailSettings.put("sendWaitTime", sendMailPage.getSendWaitTime());
// Set the new values
sendMailPage.setHost("localhost");
sendMailPage.setPort("3025");
// Make sure we don't wait between email sending in order to speed up the test (and not incur timeouts when
// we wait to receive the mails)
sendMailPage.setSendWaitTime("0");
sendMailPage.clickSave();
getUtil().updateObject("Mail", "MailConfig", "Mail.SendMailConfigClass", 0, "host", "localhost", "port",
"3025", "sendWaitTime", "0");
}
private void restoreSettings()
{
// It is possible that the setup was not executed, so no point in doing cleanup
if (currentEmailSettings == null) {
return;
}
// Make sure we can restore the settings, so we log back with superadmin to finish the work
getUtil().gotoPage(getUtil().getURLToLoginAsSuperAdmin());
// Open administration.
AdministrationPage administrationPage = AdministrationPage.gotoPage();
// Open the Mail Sending section
administrationPage.clickSection("Email", "Mail Sending");
SendMailAdministrationSectionPage sendMailPage = new SendMailAdministrationSectionPage();
// Set the new values
sendMailPage.setHost(currentEmailSettings.get("host"));
sendMailPage.setPort(currentEmailSettings.get("port"));
sendMailPage.setSendWaitTime(currentEmailSettings.get("sendWaitTime"));
sendMailPage.clickSave();
// Remove the previous version that the setup has created.
getUtil().deleteLatestVersion("Mail", "MailConfig");
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment