more maildata shifting

This commit is contained in:
holger krekel
2023-10-21 00:47:19 +02:00
parent dd232689a7
commit 7dd2d0b9b4
3 changed files with 29 additions and 33 deletions

View File

@@ -2,36 +2,34 @@ from chatmaild.filtermail import check_encrypted, check_DATA, SendRateLimiter
import pytest
def test_reject_forged_from(mailgen):
class envelope:
mail_from = "bob@c3.testrun.org"
rcpt_tos = ["somebody@c3.testrun.org"]
def test_reject_forged_from(get_mail_data, gencreds):
class env:
mail_from = gencreds()[0]
rcpt_tos = [gencreds()[0]]
# test that the filter lets good mail through
envelope.content = mailgen.get_mail_data(
"plain.eml", from_addr=envelope.mail_from
).as_bytes()
assert not check_DATA(envelope=envelope)
env.content = get_mail_data("plain.eml", from_addr=env.mail_from).as_bytes()
assert not check_DATA(envelope=env)
# test that the filter rejects forged mail
envelope.content = mailgen.get_mail_data(
env.content = get_mail_data(
"plain.eml", from_addr="forged@c3.testrun.org"
).as_bytes()
error = check_DATA(envelope=envelope)
error = check_DATA(envelope=env)
assert "500" in error
def test_filtermail_no_encryption_detection(mailgen):
msg = mailgen.get_mail_data("plain.eml")
def test_filtermail_no_encryption_detection(get_mail_data):
msg = get_mail_data("plain.eml")
assert not check_encrypted(msg)
# https://xkcd.com/1181/
msg = mailgen.get_mail_data("fake-encrypted.eml")
msg = get_mail_data("fake-encrypted.eml")
assert not check_encrypted(msg)
def test_filtermail_encryption_detection(mailgen):
msg = mailgen.get_mail_data("encrypted.eml")
def test_filtermail_encryption_detection(get_mail_data):
msg = get_mail_data("encrypted.eml")
assert check_encrypted(msg)
# if the subject is not "..." it is not considered ac-encrypted
@@ -39,9 +37,8 @@ def test_filtermail_encryption_detection(mailgen):
assert not check_encrypted(msg)
def test_filtermail_mdn_is_not_encrypted(mailgen):
msg = mailgen.get_mail_data("mdn.eml")
assert not check_encrypted(msg)
def test_filtermail_mdn_is_not_encrypted(get_mail_data):
assert not check_encrypted(get_mail_data("mdn.eml"))
def test_send_rate_limiter():