diff options
author | Antoine Eiche <lewo@abesis.fr> | 2021-01-28 23:58:08 +0100 |
---|---|---|
committer | lewo <lewo@abesis.fr> | 2021-02-06 08:17:43 +0000 |
commit | 5f431207b335424907f9da4a4fedde9bff2cea91 (patch) | |
tree | eebad8e516e6e5eb7a13bdc53cc73d582653ddc5 /tests | |
parent | 17eec31cae1d23e89888da1d0495c960ba624eaf (diff) |
postfix: forwarding emails of login accounts with keeping local copy
When a local account address is forwarded, the mails were not locally
kept. This was due to the way lookup tables were internally managed.
Instead of using lists to represent Postfix lookup tables, we now use
attribute sets: they can then be easily merged.
A regression test for
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/issues/
has been added: it sets a forward on a local address and ensure an
email sent to this address is locally kept.
Fixes #205
Diffstat (limited to 'tests')
-rw-r--r-- | tests/intern.nix | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/intern.nix b/tests/intern.nix index 1d1816b..b357ed9 100644 --- a/tests/intern.nix +++ b/tests/intern.nix @@ -33,6 +33,8 @@ let htpasswd -nbB "" "${password}" | cut -d: -f2 > $out ''; + hashedPasswordFile = hashPassword "my-password"; + passwordFile = pkgs.writeText "password" "my-password"; in pkgs.nixosTest { name = "intern"; @@ -45,20 +47,34 @@ pkgs.nixosTest { virtualisation.memorySize = 1024; + environment.systemPackages = [ + (pkgs.writeScriptBin "mail-check" '' + ${pkgs.python3}/bin/python ${../scripts/mail-check.py} $@ + '')]; + mailserver = { enable = true; fqdn = "mail.example.com"; domains = [ "example.com" ]; + localDnsResolver = false; loginAccounts = { "user1@example.com" = { - hashedPassword = "$6$/z4n8AQl6K$kiOkBTWlZfBd7PvF5GsJ8PmPgdZsFGN1jPGZufxxr60PoR0oUsrvzm2oQiflyz5ir9fFJ.d/zKm/NgLXNUsNX/"; + hashedPasswordFile = hashedPasswordFile; + }; + "user2@example.com" = { + hashedPasswordFile = hashedPasswordFile; }; "send-only@example.com" = { hashedPasswordFile = hashPassword "send-only"; sendOnly = true; }; }; + forwards = { + # user2@example.com is a local account and its mails are + # also forwarded to user1@example.com + "user2@example.com" = "user1@example.com"; + }; vmailGroupName = "vmail"; vmailUID = 5000; @@ -71,6 +87,45 @@ pkgs.nixosTest { machine.start() machine.wait_for_unit("multi-user.target") + # Regression test for https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/issues/205 + with subtest("mail forwarded can are locally kept"): + # A mail sent to user2@example.com is in the user1@example.com mailbox + 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 user2@example.com", + "--src-password-file ${passwordFile}", + "--dst-password-file ${passwordFile}", + "--ignore-dkim-spf", + ] + ) + ) + # A mail sent to user2@example.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@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") |