mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 00:03:03 +08:00
Also quarantine soft_fail dmarc results
This commit is contained in:
parent
4d13e0c2b8
commit
16275620ae
2 changed files with 21 additions and 0 deletions
|
@ -549,6 +549,7 @@ def apply_dmarc_policy(alias: Alias, contact: Contact, msg: Message) -> Optional
|
|||
if dmarc_result in (
|
||||
DmarcCheckResult.quarantine,
|
||||
DmarcCheckResult.reject,
|
||||
DmarcCheckResult.soft_fail,
|
||||
):
|
||||
add_or_replace_header(msg, headers.SL_DIRECTION, "Forward")
|
||||
msg[headers.SL_ENVELOPE_TO] = alias.email
|
||||
|
|
|
@ -85,3 +85,23 @@ def test_dmarc_quarantine(flask_client):
|
|||
email_log = email_logs[0]
|
||||
assert email_log.blocked
|
||||
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 a new issue