mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
Add no header test
This commit is contained in:
parent
085c166cb2
commit
ac9b88f87d
3 changed files with 36 additions and 2 deletions
|
@ -563,7 +563,7 @@ def apply_dmarc_policy(
|
|||
# DmarcCheckResult.soft_fail,
|
||||
):
|
||||
LOG.w(
|
||||
f"put email from {contact} to {alias} to quarantine. {spam_result}, "
|
||||
f"put email from {contact} to {alias} to quarantine. {spam_result.event_data()}, "
|
||||
f"mail_from:{envelope.mail_from}, from_header: {msg[headers.FROM]}"
|
||||
)
|
||||
email_log = quarantine_dmarc_failed_email(alias, contact, envelope, msg)
|
||||
|
@ -2595,7 +2595,8 @@ class MailHandler:
|
|||
return_status = handle(envelope, msg)
|
||||
elapsed = time.time() - start
|
||||
if return_status[0] == "5":
|
||||
if get_spamd_result(msg).spf in (
|
||||
spamd_result = get_spamd_result(msg)
|
||||
if spamd_result and get_spamd_result(msg).spf in (
|
||||
SPFCheckResult.fail,
|
||||
SPFCheckResult.soft_fail,
|
||||
):
|
||||
|
|
19
tests/example_emls/no_spamd_header.eml
Normal file
19
tests/example_emls/no_spamd_header.eml
Normal file
|
@ -0,0 +1,19 @@
|
|||
X-SimpleLogin-Client-IP: 54.39.200.130
|
||||
Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=34.59.200.130;
|
||||
helo=relay.somewhere.net; envelope-from=everwaste@gmail.com;
|
||||
receiver=<UNKNOWN>
|
||||
Received: from relay.somewhere.net (relay.somewhere.net [34.59.200.130])
|
||||
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
|
||||
(No client certificate requested)
|
||||
by mx1.sldev.ovh (Postfix) with ESMTPS id 6D8C13F069
|
||||
for <wehrman_mannequin@sldev.ovh>; Thu, 17 Mar 2022 16:50:20 +0000 (UTC)
|
||||
Date: Thu, 17 Mar 2022 16:50:18 +0000
|
||||
To: {{ alias_email }}
|
||||
From: somewhere@rainbow.com
|
||||
Subject: test Thu, 17 Mar 2022 16:50:18 +0000
|
||||
Message-Id: <20220317165018.000191@somewhere-5488dd4b6b-7crp6>
|
||||
X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/
|
||||
X-Rspamd-Queue-Id: 6D8C13F069
|
||||
X-Rspamd-Server: staging1
|
||||
|
||||
This is a test mailing
|
|
@ -145,3 +145,17 @@ def test_preserve_5xx_with_valid_spf(flask_client):
|
|||
envelope.rcpt_tos = [msg["to"]]
|
||||
result = email_handler.MailHandler()._handle(envelope, msg)
|
||||
assert result == status.E512
|
||||
|
||||
|
||||
def test_preserve_5xx_with_no_header(flask_client):
|
||||
user = create_random_user()
|
||||
alias = Alias.create_new_random(user)
|
||||
msg = load_eml_file(
|
||||
"no_spamd_header.eml",
|
||||
{"alias_email": alias.email},
|
||||
)
|
||||
envelope = Envelope()
|
||||
envelope.mail_from = BOUNCE_EMAIL.format(999999999999999999)
|
||||
envelope.rcpt_tos = [msg["to"]]
|
||||
result = email_handler.MailHandler()._handle(envelope, msg)
|
||||
assert result == status.E512
|
||||
|
|
Loading…
Reference in a new issue