diff options
author | Jean-Baptiste Giraudeau <jb@giraudeau.info> | 2023-09-28 16:13:00 +0200 |
---|---|---|
committer | Jean-Baptiste Giraudeau <jb@giraudeau.info> | 2023-09-28 16:13:00 +0200 |
commit | 84783b661ecf33927c534b6476beb74ea3308968 (patch) | |
tree | f191ad3a4a56a922d21491a1b632be593635732c | |
parent | 93221e4b2544ec111014d30dcba3616623369295 (diff) |
Add tests for regex (PCRE) aliases
-rw-r--r-- | tests/internal.nix | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/tests/internal.nix b/tests/internal.nix index 02609fd..564b71a 100644 --- a/tests/internal.nix +++ b/tests/internal.nix @@ -55,7 +55,7 @@ pkgs.nixosTest { mailserver = { enable = true; fqdn = "mail.example.com"; - domains = [ "example.com" ]; + domains = [ "example.com" "domain.com" ]; localDnsResolver = false; loginAccounts = { @@ -64,6 +64,7 @@ pkgs.nixosTest { }; "user2@example.com" = { hashedPasswordFile = hashedPasswordFile; + aliasesRegexp = [''/^user2.*@domain\.com$/'']; }; "send-only@example.com" = { hashedPasswordFile = hashPassword "send-only"; @@ -126,6 +127,46 @@ pkgs.nixosTest { ) ) + with subtest("regex email alias are received"): + # A mail sent to user2-regex-alias@domain.com is in the user2@example.com mailbox + machine.succeed( + " ".join( + [ + "mail-check send-and-read", + "--smtp-port 587", + "--smtp-starttls", + "--smtp-host localhost", + "--imap-host localhost", + "--imap-username user2@example.com", + "--from-addr user1@example.com", + "--to-addr user2-regex-alias@domain.com", + "--src-password-file ${passwordFile}", + "--dst-password-file ${passwordFile}", + "--ignore-dkim-spf", + ] + ) + ) + + with subtest("user can send from regex email alias"): + # A mail sent from user2-regex-alias@domain.com, using user2@example.com credentials is received + machine.succeed( + " ".join( + [ + "mail-check send-and-read", + "--smtp-port 587", + "--smtp-starttls", + "--smtp-host localhost", + "--imap-host localhost", + "--smtp-username user2@example.com", + "--from-addr user2-regex-alias@domain.com", + "--to-addr user1@example.com", + "--src-password-file ${passwordFile}", + "--dst-password-file ${passwordFile}", + "--ignore-dkim-spf", + ] + ) + ) + with subtest("vmail gid is set correctly"): machine.succeed("getent group vmail | grep 5000") |