* E2E: Add SMTP tester * fix loadlocation issue when running tests on alpine * temporary update * add log * update run-suite * Update run-suite * Update run-suite * Update run-suite * Update yarn.lock * apply suggestions + cleanup logs * update yarn.lock & package.json * fix swagger
35 lines
743 B
JavaScript
35 lines
743 B
JavaScript
const ms = require('smtp-tester');
|
|
|
|
const PORT = 7777;
|
|
|
|
const initialize = (on, config) => {
|
|
// starts the SMTP server at localhost:7777
|
|
const mailServer = ms.init(PORT);
|
|
console.log('mail server at port %d', PORT);
|
|
|
|
let lastEmail = {};
|
|
|
|
// process all emails
|
|
mailServer.bind((addr, id, email) => {
|
|
lastEmail[email.headers.to] = email;
|
|
});
|
|
|
|
on('task', {
|
|
resetEmails(recipient) {
|
|
if (recipient) {
|
|
console.log('reset all emails for recipient %s', recipient);
|
|
delete lastEmail[recipient];
|
|
} else {
|
|
console.log('reset all emails');
|
|
lastEmail = {};
|
|
}
|
|
},
|
|
|
|
getLastEmail(email) {
|
|
return lastEmail[email] || null;
|
|
},
|
|
});
|
|
};
|
|
|
|
exports.initialize = initialize;
|