mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
lint fixes, final touch
This commit is contained in:
@@ -60,7 +60,9 @@ def show_dns(args, out):
|
|||||||
continue
|
continue
|
||||||
line = line.replace("\t", " ")
|
line = line.replace("\t", " ")
|
||||||
lines.append(line)
|
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)
|
return "\n".join(lines)
|
||||||
|
|
||||||
print("Checking your DKIM keys and DNS entries...")
|
print("Checking your DKIM keys and DNS entries...")
|
||||||
@@ -69,8 +71,9 @@ def show_dns(args, out):
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print("Please run `cmdeploy run` first.")
|
print("Please run `cmdeploy run` first.")
|
||||||
return
|
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()
|
ipv6 = dns.get_ipv6()
|
||||||
reverse_ipv6 = dns.check_ptr_record(ipv6, mail_domain)
|
reverse_ipv6 = dns.check_ptr_record(ipv6, mail_domain)
|
||||||
|
|||||||
@@ -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"])
|
@pytest.mark.parametrize("from_addr", ["fake@example.org", "fake@testrun.org"])
|
||||||
def test_reject_missing_dkim(cmsetup, maildata, from_addr):
|
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]
|
recipient = cmsetup.gen_users(1)[0]
|
||||||
msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient.addr).as_string()
|
msg = maildata("plain.eml", from_addr=from_addr, to_addr=recipient.addr).as_string()
|
||||||
with smtplib.SMTP(cmsetup.maildomain, 25) as s:
|
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)
|
s.sendmail(from_addr=from_addr, to_addrs=recipient.addr, msg=msg)
|
||||||
# assert response code == 500 or something
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.slow
|
@pytest.mark.slow
|
||||||
|
|||||||
Reference in New Issue
Block a user