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