Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottvincent committed Dec 25, 2023
1 parent 1fd7e57 commit 79d6e98
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var REGEXES = {

temporary_safe : /(temporary|temporarily)/i,
blocked : /((?:is listed)|blocked|block list|banned|denied|dnsbl)/i,
spam : /(spam)/i,
spam : /(spam|unsolicited)/i,

enhanced_types : {
no_such_recipient : [
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/450_rate_limited.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This is the mail system at host mailer.acme.email.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host mta6.am0.yahoodns.net[76.159.240.27] said: 450 User is
receiving mail too quickly tnmpmscs (in reply to RCPT TO command)
15 changes: 15 additions & 0 deletions test/fixtures/554_5_4_0_hops.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This is the mail system at host burns.eiro.biz.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host
balancer_haproxy.email.locaweb.com.br[1.13.102.292] said: 554 5.4.0 Error:
too many hops (in reply to end of DATA command)
15 changes: 15 additions & 0 deletions test/fixtures/554_5_7_105_sender_blocked.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This is the mail system at host out41.mail.ovh.net.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host mxplan3.mail.ovh.net[49.32.197.262]
said: 554 5.7.105 SenderFilterAgent; Sender denied as sender's email
address is on SenderFilterConfig list (in reply to end of DATA command)
15 changes: 15 additions & 0 deletions test/fixtures/554_5_7_1_no_such_recipient_variant_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This is the mail system at host mailer.acme.email.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host vero.in.mest.micro.com[81.280.22.8]
said: 554 5.7.1 <[email protected]>: Recipient address rejected:
BLOCK-SEND-ER. (in reply to RCPT TO command)
15 changes: 15 additions & 0 deletions test/fixtures/554_5_7_1_spam_content_variant_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This is the mail system at host mailer.acme.email.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host mx01.mail.icloud.com[71.75.155.43] said: 554
5.7.1 [CS01] Message rejected due to local policy. Please visit
https://support.apple.com/en-us/HT204137 (in reply to end of DATA command)
17 changes: 17 additions & 0 deletions test/fixtures/554_5_7_1_spam_content_variant_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This is the mail system at host mailer.acme.email.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

<[email protected]>: host mail2.etecsa.net[118.252.213.4] said: 554 5.7.1
Service unavailable; Client host [39.177.48.171] blocked using
0spam.fusionzero.com; Received: from mailer-2w.outbound.crisp.email
([39.177.48.171]) Fri, 22 Sep 2023 01:01:01 +0000 Subject: Backlinking is
not that crazy anymore (in reply to RCPT TO command)
32 changes: 32 additions & 0 deletions test/fixtures/expected/450_rate_limited.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host mta6.am0.yahoodns.net[76.159.240.27] said: 450 User is receiving mail too quickly tnmpmscs (in reply to RCPT TO command)",
"intro": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host mta6.am0.yahoodns.net[76.159.240.27] said: 450 User is receiving mail too quickly tnmpmscs (in reply to RCPT TO command)"
},
"data": {
"error": {
"code": {
"basic": "450",
"enhanced": null
},
"label": "User is receiving mail too quickly tnmpmscs",
"type": "action_not_taken_mailbox_unavailable",
"temporary": true,
"permanent": false,
"data": {
"type": null,
"blocked": false,
"spam": false
}
},
"recipient": "[email protected]",
"server": {
"hostname": "mta6.am0.yahoodns.net",
"ip": "76.159.240.27",
"port": null
},
"command": "RCPT TO"
}
}
32 changes: 32 additions & 0 deletions test/fixtures/expected/554_5_4_0_hops.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host burns.eiro.biz.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host balancer_haproxy.email.locaweb.com.br[1.13.102.292] said: 554 5.4.0 Error: too many hops (in reply to end of DATA command)",
"intro": "This is the mail system at host burns.eiro.biz.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host balancer_haproxy.email.locaweb.com.br[1.13.102.292] said: 554 5.4.0 Error: too many hops (in reply to end of DATA command)"
},
"data": {
"error": {
"code": {
"basic": "554",
"enhanced": "5.4.0"
},
"label": "Error: too many hops",
"type": "transaction_failed",
"temporary": false,
"permanent": true,
"data": {
"type": null,
"blocked": false,
"spam": false
}
},
"recipient": "[email protected]",
"server": {
"hostname": "balancer_haproxy.email.locaweb.com.br",
"ip": "1.13.102.292",
"port": null
},
"command": "DATA"
}
}
32 changes: 32 additions & 0 deletions test/fixtures/expected/554_5_7_105_sender_blocked.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host out41.mail.ovh.net.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host mxplan3.mail.ovh.net[49.32.197.262] said: 554 5.7.105 SenderFilterAgent; Sender denied as sender's email address is on SenderFilterConfig list (in reply to end of DATA command)",
"intro": "This is the mail system at host out41.mail.ovh.net.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host mxplan3.mail.ovh.net[49.32.197.262] said: 554 5.7.105 SenderFilterAgent; Sender denied as sender's email address is on SenderFilterConfig list (in reply to end of DATA command)"
},
"data": {
"error": {
"code": {
"basic": "554",
"enhanced": "5.7.105"
},
"label": "SenderFilterAgent; Sender denied as sender's email address is on SenderFilterConfig list",
"type": "transaction_failed",
"temporary": false,
"permanent": true,
"data": {
"type": null,
"blocked": true,
"spam": false
}
},
"recipient": "[email protected]",
"server": {
"hostname": "mxplan3.mail.ovh.net",
"ip": "49.32.197.262",
"port": null
},
"command": "DATA"
}
}
32 changes: 32 additions & 0 deletions test/fixtures/expected/554_5_7_1_no_such_recipient_variant_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host vero.in.mest.micro.com[81.280.22.8] said: 554 5.7.1 <[email protected]>: Recipient address rejected: BLOCK-SEND-ER. (in reply to RCPT TO command)",
"intro": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host vero.in.mest.micro.com[81.280.22.8] said: 554 5.7.1 <[email protected]>: Recipient address rejected: BLOCK-SEND-ER. (in reply to RCPT TO command)"
},
"data": {
"error": {
"code": {
"basic": "554",
"enhanced": "5.7.1"
},
"label": "Recipient address rejected: BLOCK-SEND-ER.",
"type": "transaction_failed",
"temporary": false,
"permanent": true,
"data": {
"type": "spam_content",
"blocked": false,
"spam": false
}
},
"recipient": "[email protected]",
"server": {
"hostname": "vero.in.mest.micro.com",
"ip": "81.280.22.8",
"port": null
},
"command": "RCPT TO"
}
}
32 changes: 32 additions & 0 deletions test/fixtures/expected/554_5_7_1_spam_content_variant_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host mx01.mail.icloud.com[71.75.155.43] said: 554 5.7.1 [CS01] Message rejected due to local policy. Please visit https://support.apple.com/en-us/HT204137 (in reply to end of DATA command)",
"intro": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host mx01.mail.icloud.com[71.75.155.43] said: 554 5.7.1 [CS01] Message rejected due to local policy. Please visit https://support.apple.com/en-us/HT204137 (in reply to end of DATA command)"
},
"data": {
"error": {
"code": {
"basic": "554",
"enhanced": "5.7.1"
},
"label": "[CS01] Message rejected due to local policy. Please visit https://support.apple.com/en-us/HT204137",
"type": "transaction_failed",
"temporary": false,
"permanent": true,
"data": {
"type": "spam_content",
"blocked": false,
"spam": false
}
},
"recipient": "[email protected]",
"server": {
"hostname": "mx01.mail.icloud.com",
"ip": "71.75.155.43",
"port": null
},
"command": "DATA"
}
}
32 changes: 32 additions & 0 deletions test/fixtures/expected/554_5_7_1_spam_content_variant_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"bounce": true,
"email": {
"body": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system\n\n<[email protected]>: host mail2.etecsa.net[118.252.213.4] said: 554 5.7.1 Service unavailable; Client host [39.177.48.171] blocked using 0spam.fusionzero.com; Received: from mailer-2w.outbound.crisp.email ([39.177.48.171]) Fri, 22 Sep 2023 01:01:01 +0000 Subject: Backlinking is not that crazy anymore (in reply to RCPT TO command)",
"intro": "This is the mail system at host mailer.acme.email.\n\nI'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can delete your own text from the attached returned message.\n\nThe mail system",
"error": "<[email protected]>: host mail2.etecsa.net[118.252.213.4] said: 554 5.7.1 Service unavailable; Client host [39.177.48.171] blocked using 0spam.fusionzero.com; Received: from mailer-2w.outbound.crisp.email ([39.177.48.171]) Fri, 22 Sep 2023 01:01:01 +0000 Subject: Backlinking is not that crazy anymore (in reply to RCPT TO command)"
},
"data": {
"error": {
"code": {
"basic": "554",
"enhanced": "5.7.1"
},
"label": "Service unavailable; Client host [39.177.48.171] blocked using 0spam.fusionzero.com; Received: from mailer-2w.outbound.crisp.email ([39.177.48.171]) Fri, 22 Sep 2023 01:01:01 +0000 Subject: Backlinking is not that crazy anymore",
"type": "transaction_failed",
"temporary": false,
"permanent": true,
"data": {
"type": "spam_content",
"blocked": true,
"spam": true
}
},
"recipient": "[email protected]",
"server": {
"hostname": "mail2.etecsa.net",
"ip": "118.252.213.4",
"port": null
},
"command": "RCPT TO"
}
}
9 changes: 9 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ module.exports = {

"421_4_7_28_ip_blocked_spam",

"450_rate_limited",

"450_4_2_1_no_such_recipient",

"450_4_2_1_rate_limited",
Expand Down Expand Up @@ -230,11 +232,18 @@ module.exports = {

"554_5_2_3_policy_violation",

"554_5_4_0_hops",

"554_5_7_1_no_such_recipient",
"554_5_7_1_no_such_recipient_variant_1",

"554_5_7_1_spam_content",
"554_5_7_1_spam_content_variant_1",
"554_5_7_1_spam_content_variant_2",
"554_5_7_1_spam_content_variant_3",
"554_5_7_1_spam_content_variant_4",

"554_5_7_105_sender_blocked",

"554_5_7_7_equal_headers"
],
Expand Down

0 comments on commit 79d6e98

Please sign in to comment.