From 66debb9245f01a4cac9dcbfea2af4f64f9228bd7 Mon Sep 17 00:00:00 2001 From: missytake Date: Wed, 27 Dec 2023 13:34:24 +0100 Subject: [PATCH] lint fixes, final touch --- cmdeploy/src/cmdeploy/dns.py | 9 ++++++--- cmdeploy/src/cmdeploy/tests/online/test_1_basic.py | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index 5a051a6..8a1baca 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -60,7 +60,9 @@ def show_dns(args, out): continue line = line.replace("\t", " ") lines.append(line) - lines[0] = f"dkim._domainkey.{mail_domain}. IN TXT " + lines[0].strip("dkim._domainkey IN TXT ") + lines[0] = f"dkim._domainkey.{mail_domain}. IN TXT " + lines[0].strip( + "dkim._domainkey IN TXT " + ) return "\n".join(lines) print("Checking your DKIM keys and DNS entries...") @@ -69,8 +71,9 @@ def show_dns(args, out): except subprocess.CalledProcessError: print("Please run `cmdeploy run` first.") return - dkim_entry = read_dkim_entries(out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.dkim.zone")) - + dkim_entry = read_dkim_entries( + out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.dkim.zone") + ) ipv6 = dns.get_ipv6() reverse_ipv6 = dns.check_ptr_record(ipv6, mail_domain) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 7cacd4e..316e933 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -44,13 +44,12 @@ def test_reject_forged_from(cmsetup, maildata, gencreds, lp, forgeaddr): @pytest.mark.parametrize("from_addr", ["fake@example.org", "fake@testrun.org"]) def test_reject_missing_dkim(cmsetup, maildata, from_addr): - """Test that emails with missing or wrong DKIM entries are rejected.""" + """Test that emails with missing or wrong DMARC, DKIM, and SPF 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.SMTPDataError): + with pytest.raises(smtplib.SMTPDataError, match="Spam message rejected"): s.sendmail(from_addr=from_addr, to_addrs=recipient.addr, msg=msg) - # assert response code == 500 or something @pytest.mark.slow