This commit is contained in:
Shelvacu
2025-04-09 20:04:22 -07:00
committed by Shelvacu on fw
parent 8e68fe88c8
commit c1c5f39a00
9 changed files with 92 additions and 18 deletions

View File

@@ -0,0 +1,87 @@
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from hints import *
import json
DATA_JSON = """
@data@
"""
DATA = json.loads(DATA_JSON)
relay_ip = DATA["relayIP"]
liam.succeed(DATA["checkSieve"])
start_all()
ns.wait_for_unit("bind.service")
ns.wait_for_open_port(53)
liam.wait_for_unit("nginx.service")
liam.wait_for_open_port(80)
liam.copy_from_host(DATA["acmeTest"], DATA["acmeTestDest"])
checker.wait_for_unit("network-online.target")
checker.succeed("wget http://liam.dis8.net/.well-known/acme-challenge/test")
liam.succeed("doveadm mailbox create -u shelvacu testFolder")
liam.wait_for_unit("postfix.service")
liam.wait_for_unit("dovecot2.service")
relay.wait_for_unit("mailpit.service")
# The order of these shouldn't matter, other than what fails first. Whatever is at the top is probably whatever I was working on most recently.
checks = f"""
--submission --mailfrom robot@vacu.store --rcptto someone@example.com --username vacustore --expect-mailpit-received --mailpit-url http://{relay_ip}:8025
--submission --mailfrom foobar@vacu.store --rcptto someone@example.com --username vacustore --expect-refused
--submission --mailfrom abc@shelvacu.com --rcptto someone@example.com --username vacustore --expect-refused
# test refilter
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to MagicRefilter --imap-dir com.shelvacu
# refilter doesnt activate on other folders
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to testFolder --imap-dir testFolder
--mailfrom whoeve2@example.com --rcptto sieve2est@shelvacu.com --username shelvacu --imap-move-to INBOX --imap-dir INBOX
# test the sieve script is working
--mailfrom whoever@example.com --rcptto sievetest@shelvacu.com --username shelvacu --imap-dir com.shelvacu
# refilter doesnt activate on julie's
--mailfrom blarg@example.com --rcptto julie@shelvacu.com --username julie --imap-move-to MagicRefilter --imap-dir MagicRefilter
--mailfrom asshole-spammer@example.com --rcptto whatever@shelvacu.com --header "List-unsubscribe: whatver" --username shelvacu --expect-flag spamish --imap-dir "com.shelvacu.#spamish"
--mailfrom shipment-tracking@amazon.com --rcptto amznbsns@shelvacu.com --subject "Your Amazon.com order has shipped (#123-1234)" --username shelvacu --imap-dir com.shelvacu --expect-flag \\\\Seen --expect-flag auto-marked-read --expect-flag amazon-ignore
--rcptto shelvacu@shelvacu.com --username shelvacu --smtp-starttls
--submission --mailfrom me@shelvacu.com --rcptto foo@example.com --username shelvacu --expect-mailpit-received --mailpit-url http://{relay_ip}:8025
--submission --mailfrom me@dis8.net --rcptto foo@example.com --username shelvacu --expect-mailpit-not-received --mailpit-url http://{relay_ip}:8025
# julie's emails should NOT get sieve'd like mine
--rcptto julie@shelvacu.com --username julie --imap-dir INBOX
--rcptto julie+stuff@shelvacu.com --username julie --imap-dir INBOX
--rcptto shelvacu@shelvacu.com --username shelvacu
--rcptto julie@shelvacu.com --username julie
--rcptto foobar@shelvacu.com --username shelvacu
--rcptto sales@theviolincase.com --username julie
--rcptto superwow@shop.theviolincase.com --username julie
--rcptto roboman@vacu.store --username shelvacu
--mailfrom bob@vacu.store --expect-refused
--mailfrom shelvacu@shelvacu.com --expect-refused
--mailfrom julie@shelvacu.com --expect-refused
--mailfrom @vacu.store --expect-refused
--mailfrom reject-spam-test@example.com --expect-refused
--submission --expect-refused --mailfrom julie@shelvacu.com --username shelvacu
--submission --expect-refused --mailfrom fubar@theviolincase.com --username shelvacu
--submission --expect-refused --mailfrom fubar@vacu.store --username julie
--submission --mailfrom shelvacu@shelvacu.com --rcptto foo@example.com --username shelvacu --password shelvacu --expect-sent
--submission --mailfrom shelvacu@shelvacu.com --rcptto foo@example.com --username shelvacu@shelvacu.com --password shelvacu --expect-sent
--submission --mailfrom foo@vacu.store --rcptto foo@example.com --username shelvacu --password shelvacu --expect-sent
--submission --mailfrom foo@vacu.store --rcptto foo@example.com --username shelvacu@shelvacu.com --password shelvacu --expect-sent
--submission --mailfrom foo@violingifts.com --rcptto foo@example.com --username julie --password julie --expect-sent
--submission --mailfrom foo@violingifts.com --rcptto foo@example.com --username julie@shelvacu.com --password julie --expect-sent
"""
for check in checks.split("\n"):
check = check.strip()
if check == "" or check[0] == "#":
continue
res = checker.succeed("mailtest " + check.strip())
print(res)