From 28bfef89ba7cda05e15eaefcfa1ba4371a4a526f Mon Sep 17 00:00:00 2001 From: emilylange Date: Sun, 12 Apr 2026 04:07:01 +0200 Subject: [PATCH] tests: test `mailserver.loginAccounts..sieveScript` --- tests/internal.nix | 24 +++++++++++++++++++++++- tests/lib/redirect.sieve | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/lib/redirect.sieve diff --git a/tests/internal.nix b/tests/internal.nix index e9fe366..a4d6d4d 100644 --- a/tests/internal.nix +++ b/tests/internal.nix @@ -61,7 +61,7 @@ in nodes = { machine = - { pkgs, ... }: + { pkgs, lib, ... }: { imports = [ ./../default.nix @@ -111,6 +111,7 @@ in }; "user3@example.com" = { passwordFile = "/run/passwords/user3"; + sieveScript = lib.readFile ./lib/redirect.sieve; }; "user4@example.com" = { hashedPasswordFile = hashedPasswordFileWithScheme; @@ -292,6 +293,27 @@ in ) ) + with subtest("user's static Sieve script is being executed"): + # user3@example.com has a cfg.sieveScript that forwards every + # mail sent from user1@example.com back to user1@example.com + machine.succeed( + " ".join( + [ + "mail-check send-and-read", + "--smtp-port 587", + "--smtp-starttls", + "--smtp-host localhost", + "--imap-host localhost", + "--imap-username user1@example.com", + "--from-addr user1@example.com", + "--to-addr user3@example.com", + "--src-password-file ${passwordFile}", + "--dst-password-file ${passwordFile}", + "--ignore-dkim-spf", + ] + ) + ) + with subtest("imap port 143 is closed and imaps is serving SSL"): machine.wait_for_closed_port(143) machine.wait_for_open_port(993) diff --git a/tests/lib/redirect.sieve b/tests/lib/redirect.sieve new file mode 100644 index 0000000..4f13810 --- /dev/null +++ b/tests/lib/redirect.sieve @@ -0,0 +1,3 @@ +if address :is "from" "user1@example.com" { + redirect "user1@example.com"; +}