mirror of
https://github.com/simple-login/app.git
synced 2024-09-27 20:31:30 +02:00
Also quarantine soft_fail dmarc results
This commit is contained in:
parent
4d13e0c2b8
commit
16275620ae
@ -549,6 +549,7 @@ def apply_dmarc_policy(alias: Alias, contact: Contact, msg: Message) -> Optional
|
|||||||
if dmarc_result in (
|
if dmarc_result in (
|
||||||
DmarcCheckResult.quarantine,
|
DmarcCheckResult.quarantine,
|
||||||
DmarcCheckResult.reject,
|
DmarcCheckResult.reject,
|
||||||
|
DmarcCheckResult.soft_fail,
|
||||||
):
|
):
|
||||||
add_or_replace_header(msg, headers.SL_DIRECTION, "Forward")
|
add_or_replace_header(msg, headers.SL_DIRECTION, "Forward")
|
||||||
msg[headers.SL_ENVELOPE_TO] = alias.email
|
msg[headers.SL_ENVELOPE_TO] = alias.email
|
||||||
|
@ -85,3 +85,23 @@ def test_dmarc_quarantine(flask_client):
|
|||||||
email_log = email_logs[0]
|
email_log = email_logs[0]
|
||||||
assert email_log.blocked
|
assert email_log.blocked
|
||||||
assert email_log.refused_email_id
|
assert email_log.refused_email_id
|
||||||
|
|
||||||
|
|
||||||
|
def test_gmail_dmarc_softfail(flask_client):
|
||||||
|
user = create_random_user()
|
||||||
|
alias = Alias.create_new_random(user)
|
||||||
|
msg = load_eml_file("dmarc_gmail_softfail.eml", {"alias_email": alias.email})
|
||||||
|
envelope = Envelope()
|
||||||
|
envelope.mail_from = msg["from"]
|
||||||
|
envelope.rcpt_tos = [msg["to"]]
|
||||||
|
result = email_handler.handle(envelope, msg)
|
||||||
|
assert result == status.E519
|
||||||
|
email_logs = (
|
||||||
|
EmailLog.filter_by(user_id=user.id, alias_id=alias.id)
|
||||||
|
.order_by(EmailLog.id.desc())
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
assert len(email_logs) == 1
|
||||||
|
email_log = email_logs[0]
|
||||||
|
assert email_log.blocked
|
||||||
|
assert email_log.refused_email_id
|
||||||
|
Loading…
Reference in New Issue
Block a user