1 import ../make-test-python.nix (
4 name = "maddy-unencrypted";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ onny ];
16 primaryDomain = "server";
18 ensureAccounts = [ "postmaster@server" ];
20 # Do not use this in production. This will make passwords world-readable
22 "postmaster@server".passwordFile = "${pkgs.writeText "postmaster" "test"}";
30 environment.systemPackages = [
31 (pkgs.writers.writePython3Bin "send-testmail" { } ''
33 from email.mime.text import MIMEText
35 msg = MIMEText("Hello World")
36 msg['Subject'] = 'Test'
37 msg['From'] = "postmaster@server"
38 msg['To'] = "postmaster@server"
39 with smtplib.SMTP('server', 587) as smtp:
40 smtp.login('postmaster@server', 'test')
41 smtp.sendmail('postmaster@server', 'postmaster@server', msg.as_string())
43 (pkgs.writers.writePython3Bin "test-imap" { } ''
46 with imaplib.IMAP4('server') as imap:
47 imap.login('postmaster@server', 'test')
49 status, refs = imap.search(None, 'ALL')
52 status, msg = imap.fetch(refs[0], 'BODY[TEXT]')
54 assert msg[0][1].strip() == b"Hello World"
62 server.wait_for_unit("maddy.service")
63 server.wait_for_open_port(143)
64 server.wait_for_open_port(587)
65 client.succeed("send-testmail")
66 client.succeed("test-imap")