nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

nixos/tests/postfix: add sasl authentication tests

this was tricky to get set up correctly. hopefully having it
documented in the tests will be helpful to future users (and help
ensure it keeps working for me).

+61
+61
nixos/tests/postfix.nix
··· 19 19 certs.${domain}.key 20 20 certs.${domain}.cert 21 21 ]; 22 + smtpd_sasl_auth_enable = "yes"; 23 + cyrus_sasl_config_path = 24 + let 25 + smtpdConf = pkgs.writeTextFile { 26 + name = "smtpd.conf"; 27 + destination = "/etc/sasl2/smtpd.conf"; 28 + text = '' 29 + pwcheck_method: saslauthd 30 + mech_list: PLAIN LOGIN 31 + ''; 32 + }; 33 + in 34 + "${smtpdConf}/etc/sasl2"; 22 35 }; 23 36 submissionsOptions = { 24 37 smtpd_sasl_auth_enable = "yes"; ··· 39 26 milter_macro_daemon_name = "ORIGINATING"; 40 27 }; 41 28 }; 29 + services.saslauthd.enable = true; 42 30 43 31 security.pki.certificateFiles = [ 44 32 certs.ca.cert 45 33 ]; 34 + security.pam.services = { 35 + # note: no 'd' on the end! 36 + smtp = { 37 + name = "smtp"; 38 + }; 39 + }; 46 40 47 41 networking.extraHosts = '' 48 42 127.0.0.1 ${domain} ··· 92 72 'Subject: Test SMTPS\n\nTest data.') 93 73 smtp.quit() 94 74 ''; 75 + 76 + auth = pkgs.writers.writePython3Bin "auth" { } '' 77 + import smtplib 78 + 79 + with smtplib.SMTP('${domain}') as smtp: 80 + smtp.ehlo() 81 + smtp.login("alice", "foobar") 82 + smtp.quit() 83 + ''; 84 + 85 + authStarttls = pkgs.writers.writePython3Bin "authStarttls" { } '' 86 + import smtplib 87 + import ssl 88 + 89 + ctx = ssl.create_default_context() 90 + 91 + with smtplib.SMTP('${domain}') as smtp: 92 + smtp.ehlo() 93 + smtp.starttls(context=ctx) 94 + smtp.ehlo() 95 + smtp.login("alice", "foobar") 96 + smtp.quit() 97 + ''; 98 + 99 + authSmtps = pkgs.writers.writePython3Bin "authSmtps" { } '' 100 + import smtplib 101 + import ssl 102 + 103 + ctx = ssl.create_default_context() 104 + 105 + with smtplib.SMTP_SSL('${domain}', context=ctx) as smtp: 106 + smtp.ehlo() 107 + smtp.login("alice", "foobar") 108 + smtp.quit() 109 + ''; 95 110 in 96 111 [ 97 112 sendTestMail 98 113 sendTestMailStarttls 99 114 sendTestMailSmtps 115 + auth 116 + authStarttls 117 + authSmtps 100 118 ]; 101 119 }; 102 120 ··· 143 85 machine.succeed("send-testmail") 144 86 machine.succeed("send-testmail-starttls") 145 87 machine.succeed("send-testmail-smtps") 88 + machine.succeed("auth") 89 + machine.succeed("authStarttls") 90 + machine.succeed("authSmtps") 146 91 ''; 147 92 }