Closed madurangasiriwardena closed 1 month ago
To use the mock email server,
Make sure below configuration is added to the deployment.toml file. If a new deployment.toml file is not added in the particular test case, this file is automatically available during the initial server startup.
[output_adapter.email]
from_address= "admin@wso2.com"
username= "admin"
password= "admin"
hostname= "localhost"
port= 3025
enable_start_tls= true
enable_authentication= true
Delete all the emails in the server before the tests are started.
Utils.getMailServer().purgeEmailFromAllMailboxes();
To access the email message follow below steps
Utils.getMailServer().waitForIncomingEmail(10000, 1);
Message[] messages = Utils.getMailServer().getReceivedMessages();
String body = GreenMailUtil.getBody(messages[0]).replaceAll("=\r?\n", "");
More details can be extracted from https://github.com/wso2/product-is/pull/21167
Is your suggestion related to an experience ? Please describe. Currently, there is no way to test the email sending flows with the integration test suit. This is a blocker to improve the automation test coverage.
Describe the improvement Add a mock email server to the integration test suite. This allows us to configure a email server in the integration tests and test the email sending flows.
Additional context