Skip to content

Commit

Permalink
Resolved well-known provider issue, Resolved spamc error catching (cl…
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce authored and ImgBotApp committed Aug 26, 2020
1 parent 2481318 commit 1bda03a
Show file tree
Hide file tree
Showing 3 changed files with 2,199 additions and 1,509 deletions.
2 changes: 1 addition & 1 deletion test/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const getPort = require('get-port');
const redis = require('redis');

const ForwardEmail = require('../../');
const ForwardEmail = require('../..');

const client = redis.createClient();

Expand Down
32 changes: 20 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const nodemailer = require('nodemailer');
const Client = require('nodemailer/lib/smtp-connection');
const domains = require('disposable-email-domains');

const ForwardEmail = require('../');
const ForwardEmail = require('..');
const { beforeEach, afterEach } = require('./helpers');

const tls = { rejectUnauthorized: false };
Expand All @@ -26,7 +26,7 @@ test('binds context', t => {
});

test.cb('rejects auth connections', t => {
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
connection.on('end', t.end);
connection.connect(() => {
Expand All @@ -38,7 +38,7 @@ test.cb('rejects auth connections', t => {
});

test('verifies connection', async t => {
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const transporter = nodemailer.createTransport({ port, tls });
await transporter.verify();
t.pass();
Expand All @@ -48,7 +48,7 @@ test('rejects forwarding a non-FQDN email', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: 'from@forwardemail.net',
Expand Down Expand Up @@ -78,7 +78,7 @@ test('rejects forwarding a non-registered email address', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: 'from@forwardemail.net',
Expand All @@ -104,7 +104,7 @@ test('rejects forwarding an email without dkim and spf', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: 'from@forwardemail.net',
Expand All @@ -120,7 +120,10 @@ test('rejects forwarding an email without dkim and spf', async t => {
connection.connect(() => {
connection.send(info.envelope, info.message, err => {
t.is(err.responseCode, 550);
t.regex(err.message, /No passing DKIM signature found/);
t.regex(
err.message,
/No passing SPF\/DKIM signature or Alexa top-ranked sender found/
);
connection.quit();
});
});
Expand All @@ -131,7 +134,7 @@ test('forwards an email with dkim', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: 'from@forwardemail.net',
Expand Down Expand Up @@ -165,7 +168,7 @@ test('rejects a spam file', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: 'foo@forwardemail.net',
Expand Down Expand Up @@ -205,7 +208,7 @@ test('rejects a file over the limit', async t => {
});
const filePath = path.join(os.tmpdir(), uuid());
const size = bytes('25mb');
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
fs.writeFileSync(filePath, Buffer.from(new Array(size).fill('0')));
const info = await transporter.sendMail({
Expand Down Expand Up @@ -234,7 +237,7 @@ test('prevents spam through rate limiting', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
let failed = 0;
Expand Down Expand Up @@ -280,7 +283,7 @@ test('rejects a disposable email sender', async t => {
const transporter = nodemailer.createTransport({
streamTransport: true
});
const port = t.context.forwardEmail.server.address().port;
const { port } = t.context.forwardEmail.server.address();
const connection = new Client({ port, tls });
const info = await transporter.sendMail({
from: `disposable@${domains[0]}`,
Expand All @@ -301,8 +304,13 @@ test('rejects a disposable email sender', async t => {
});
});

// eslint-disable-next-line ava/no-todo-test
test.todo('rejects invalid dkim signature');
// eslint-disable-next-line ava/no-todo-test
test.todo('accepts valid dkim signature');
// eslint-disable-next-line ava/no-todo-test
test.todo('rejects invalid spf');
// eslint-disable-next-line ava/no-todo-test
test.todo('accepts valid spf');
// eslint-disable-next-line ava/no-todo-test
test.todo('supports + symbol aliased onRcptTo');
Loading

0 comments on commit 1bda03a

Please sign in to comment.