1 import ../make-test-python.nix ({ pkgs, ... }: {
2 name = "maddy-unencrypted";
3 meta = with pkgs.lib.maintainers; { maintainers = [ onny ]; };
10 primaryDomain = "server";
12 ensureAccounts = [ "postmaster@server" ];
14 # Do not use this in production. This will make passwords world-readable
16 "postmaster@server".passwordFile = "${pkgs.writeText "postmaster" "test"}";
22 environment.systemPackages = [
23 (pkgs.writers.writePython3Bin "send-testmail" { } ''
25 from email.mime.text import MIMEText
27 msg = MIMEText("Hello World")
28 msg['Subject'] = 'Test'
29 msg['From'] = "postmaster@server"
30 msg['To'] = "postmaster@server"
31 with smtplib.SMTP('server', 587) as smtp:
32 smtp.login('postmaster@server', 'test')
33 smtp.sendmail('postmaster@server', 'postmaster@server', msg.as_string())
35 (pkgs.writers.writePython3Bin "test-imap" { } ''
38 with imaplib.IMAP4('server') as imap:
39 imap.login('postmaster@server', 'test')
41 status, refs = imap.search(None, 'ALL')
44 status, msg = imap.fetch(refs[0], 'BODY[TEXT]')
46 assert msg[0][1].strip() == b"Hello World"
54 server.wait_for_unit("maddy.service")
55 server.wait_for_open_port(143)
56 server.wait_for_open_port(587)
57 client.succeed("send-testmail")
58 client.succeed("test-imap")