From 536c12d9890d3e5ef1951e75f7eb1a1d338a4aff Mon Sep 17 00:00:00 2001 From: missytake Date: Tue, 26 Dec 2023 13:18:48 +0100 Subject: [PATCH] tests: use generic recipient for DKIM testing --- .../src/cmdeploy/tests/online/test_1_basic.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 1edd9df..7cacd4e 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -43,16 +43,13 @@ def test_reject_forged_from(cmsetup, maildata, gencreds, lp, forgeaddr): @pytest.mark.parametrize("from_addr", ["fake@example.org", "fake@testrun.org"]) -def test_reject_wrong_dmarc_spf(cmsetup, maildata, from_addr): - """Test that emails with missing or wrong DKIM and SPF entries are rejected.""" - # create recipient - recipient = "charlie@c1.testrun.org" # cmsetup.gen_users(1)[0] - # craft email object with fake sender - msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient).as_string() - # initiate SMTP connection +def test_reject_missing_dkim(cmsetup, maildata, from_addr): + """Test that emails with missing or wrong DKIM entries are rejected.""" + recipient = cmsetup.gen_users(1)[0] + msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient.addr).as_string() with smtplib.SMTP(cmsetup.maildomain, 25) as s: - with pytest.raises(smtplib.SMTPException): - s.sendmail(from_addr=from_addr, to_addrs=recipient, msg=msg) + with pytest.raises(smtplib.SMTPDataError): + s.sendmail(from_addr=from_addr, to_addrs=recipient.addr, msg=msg) # assert response code == 500 or something