at master 1.2 kB view raw
1import ./make-test-python.nix { 2 name = "postfix"; 3 4 nodes.machine = 5 { pkgs, ... }: 6 { 7 imports = [ common/user-account.nix ]; 8 services.postfix = { 9 enable = true; 10 enableSubmissions = true; 11 submissionsOptions = { 12 smtpd_tls_security_level = "none"; 13 }; 14 }; 15 16 environment.systemPackages = 17 let 18 checkConfig = pkgs.writeScriptBin "check-config" '' 19 #!${pkgs.python3.interpreter} 20 import sys 21 22 state = 1 23 success = False 24 25 with open("/etc/postfix/master.cf") as masterCf: 26 for line in masterCf: 27 if state == 1 and line.startswith("submissions"): 28 state = 2 29 elif state == 2 and line.startswith(" ") and "smtpd_tls_security_level=encrypt" in line: 30 success = True 31 elif state == 2 and not line.startswith(" "): 32 state == 3 33 if not success: 34 sys.exit(1) 35 ''; 36 37 in 38 [ checkConfig ]; 39 }; 40 41 testScript = '' 42 machine.wait_for_unit("postfix.service") 43 machine.succeed("check-config") 44 ''; 45}