about summary refs log tree commit diff
path: root/nixos/tests/postfix-raise-smtpd-tls-security-level.nix
diff options
context:
space:
mode:
authorEric Wolf <1983821+typetetris@users.noreply.github.com>2020-07-06 03:37:56 +0200
committerGitHub <noreply@github.com>2020-07-06 03:37:56 +0200
commit8af58eda1202bc9df98add36dbca118f88a2b0b7 (patch)
tree5f56c333b2fe00fcdf7d4139686f17cbf8c9b9bc /nixos/tests/postfix-raise-smtpd-tls-security-level.nix
parent152a29fef8d7856a68bfc6dbe2d16d38a01dc261 (diff)
postfix: Add submissions option for postfix and test (#91691)
RFC 8314 suggests, for end user submission of
mails, SMTP over TLS on port 465 should be used.

Closes #91690
Diffstat (limited to 'nixos/tests/postfix-raise-smtpd-tls-security-level.nix')
-rw-r--r--nixos/tests/postfix-raise-smtpd-tls-security-level.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/nixos/tests/postfix-raise-smtpd-tls-security-level.nix b/nixos/tests/postfix-raise-smtpd-tls-security-level.nix
new file mode 100644
index 0000000000000..bfe02865553f5
--- /dev/null
+++ b/nixos/tests/postfix-raise-smtpd-tls-security-level.nix
@@ -0,0 +1,44 @@
+let 
+  certs = import ./common/acme/server/snakeoil-certs.nix;
+in
+import ./make-test-python.nix {
+  name = "postfix";
+
+  machine = { pkgs, ... }: {
+    imports = [ common/user-account.nix ];
+    services.postfix = {
+      enable = true;
+      enableSubmissions = true;
+      submissionsOptions = {
+        smtpd_tls_security_level = "none";
+      };
+    };
+
+    environment.systemPackages = let
+      checkConfig = pkgs.writeScriptBin "check-config" ''
+        #!${pkgs.python3.interpreter}
+        import sys
+
+        state = 1
+        success = False
+
+        with open("/etc/postfix/master.cf") as masterCf:
+          for line in masterCf:
+            if state == 1 and line.startswith("submissions"):
+              state = 2
+            elif state == 2 and line.startswith(" ") and "smtpd_tls_security_level=encrypt" in line:
+              success = True
+            elif state == 2 and not line.startswith(" "):
+              state == 3
+        if not success:
+          sys.exit(1)
+      '';
+
+    in [ checkConfig ];
+  };
+
+  testScript = ''
+    machine.wait_for_unit("postfix.service")
+    machine.succeed("check-config")
+  '';
+}