E2E: Add SMTP tester (#88392)
* 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
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user