From 0126fd947620409ad20d7eb6d8b4eb1ff38dfaef Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Thu, 29 Oct 2026 23:23:46 +0100 Subject: tests/stalwart-*: Hard disable them They will soon stop even evaluating (when we migrate away from raw `runTest` and require the `vhack.runTest`), so it's best if we don't even include them in the `byName` results. --- .../st/stalwart-email-dns/test.disabled.nix | 170 ++++++++++++++++++++ tests/by-name/st/stalwart-email-dns/test.nix | 170 -------------------- .../st/stalwart-email-http/test.disabled.nix | 103 ++++++++++++ tests/by-name/st/stalwart-email-http/test.nix | 103 ------------ .../by-name/st/stalwart-email-ip/test.disabled.nix | 177 +++++++++++++++++++++ tests/by-name/st/stalwart-email-ip/test.nix | 177 --------------------- 6 files changed, 450 insertions(+), 450 deletions(-) create mode 100644 tests/by-name/st/stalwart-email-dns/test.disabled.nix delete mode 100644 tests/by-name/st/stalwart-email-dns/test.nix create mode 100644 tests/by-name/st/stalwart-email-http/test.disabled.nix delete mode 100644 tests/by-name/st/stalwart-email-http/test.nix create mode 100644 tests/by-name/st/stalwart-email-ip/test.disabled.nix delete mode 100644 tests/by-name/st/stalwart-email-ip/test.nix diff --git a/tests/by-name/st/stalwart-email-dns/test.disabled.nix b/tests/by-name/st/stalwart-email-dns/test.disabled.nix new file mode 100644 index 0000000..33955d8 --- /dev/null +++ b/tests/by-name/st/stalwart-email-dns/test.disabled.nix @@ -0,0 +1,170 @@ +{ + nixos-lib, + pkgsUnstable, + nixpkgs-unstable, + vhackPackages, + pkgs, + extraModules, + nixLib, + ... +}: let + mail_server = import ./nodes/mail_server.nix {inherit extraModules pkgs vhackPackages;}; + inherit (mail_server) mkMailServer; + user = import ./nodes/user.nix {inherit pkgs vhackPackages;}; + inherit (user) mkUser; +in + nixos-lib.runTest { + # Wait until we actually use stalwart again + meta.broken = true; + + hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs + + name = "email-dns"; + + node = { + specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; + + # Use the nixpkgs as constructed by the `nixpkgs.*` options + pkgs = null; + }; + + nodes = { + acme = { + nodes, + lib, + ... + }: { + imports = [ + ../../../common/acme/server.nix + ../../../common/dns/client.nix + ]; + }; + + name_server = import ./nodes/name_server.nix {inherit extraModules;}; + + mail1_server = + mkMailServer "mail1" + { + class = "individual"; + name = "bob"; + secret = "{PLAIN}bob-password"; + email = ["bob@bob.com"]; + }; + + mail2_server = + mkMailServer "mail2" + { + class = "individual"; + name = "alice"; + secret = "{PLAIN}alice-password"; + email = ["alice@alice.com"]; + }; + + bob = mkUser "bob" "mail1"; + alice = mkUser "alice" "mail2"; + }; + + testScript = {...}: let + checkEmailEmpty = pkgs.writeShellScript "assert-empty-emails" '' + set -xe + + # fetchmail returns EXIT_CODE 1 when no new mail + fetchmail --verbose >&2 || [ "$?" -eq 1 ] || { + echo "Mail was not empty" >&2 + exit 1 + } + ''; + checkEmailNotEmpty = pkgs.writeShellScript "assert-empty-emails" '' + set -xe + + # fetchmail returns EXIT_CODE 1 when no new mail + fetchmail --verbose >&2 || [ "$?" -ne 1 ] || { + echo "No new mail" >&2 + exit 1 + } + ''; + checkSpamEmailNotEmpty = pkgs.writeShellScript "assert-empty-emails" '' + set -xe + + # fetchmail returns EXIT_CODE 1 when no new mail + fetchmail --folder JUNK --verbose >&2 || [ "$?" -ne 1 ] || { + echo "No new mail" >&2 + exit 1 + } + ''; + + acme = import ../../../common/acme {inherit pkgs;}; + in + acme.prepare ["mail1_server" "mail2_server" "alice" "bob"] + # Python + '' + from time import sleep + + mail1_server.wait_for_unit("stalwart-mail.service") + mail1_server.wait_for_open_port(993) # imap + mail1_server.wait_for_open_port(465) # smtp + mail2_server.wait_for_unit("stalwart-mail.service") + mail2_server.wait_for_open_port(993) # imap + mail2_server.wait_for_open_port(465) # smtp + + alice.wait_for_unit("multi-user.target") + bob.wait_for_unit("multi-user.target") + + name_server.wait_until_succeeds("stat /var/lib/acme/mta-sts.alice.com/cert.pem") + name_server.wait_until_succeeds("stat /var/lib/acme/mta-sts.bob.com/cert.pem") + + with subtest("Both mailserver successfully started all services"): + import json + def all_services_running(host): + (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json") + host_failed = json.loads(output) + assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}" + all_services_running(mail1_server) + all_services_running(mail2_server) + + with subtest("Both start without mail"): + alice.succeed("sudo -u alice ${checkEmailEmpty}") + bob.succeed("sudo -u bob ${checkEmailEmpty}") + + with subtest("Alice can send an empty email to bob"): + alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' + set -xe + + echo "" | msmtp --debug --account alice bob@bob.com >&2 + ''}") + + # Give `mail2_server` some time to send the email. + sleep(160) + + bob.succeed("sudo -u bob ${checkSpamEmailNotEmpty}") + + with subtest("Alice can send an non-empty email to bob"): + alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' + set -xe + + cat << EOF | msmtp --debug --account alice bob@bob.com >&2 + Subject: Hi bob, I'm Alice! + + Good day, Bob! + + This is an email. + It contains a subject and a body. + I also assert utf8 support by including my last name in this very message. + + XOXO + Alice van Dåligen. + + . + EOF + ''}") + + # Give `mail2_server` some time to send the email. + sleep(120) + + bob.succeed("sudo -u bob ${checkEmailNotEmpty}") + + mail1_server.copy_from_vm("/var/lib/", "server1") + mail2_server.copy_from_vm("/var/lib/", "server2") + bob.copy_from_vm("/home/bob/mail", "bob") + ''; + } diff --git a/tests/by-name/st/stalwart-email-dns/test.nix b/tests/by-name/st/stalwart-email-dns/test.nix deleted file mode 100644 index 33955d8..0000000 --- a/tests/by-name/st/stalwart-email-dns/test.nix +++ /dev/null @@ -1,170 +0,0 @@ -{ - nixos-lib, - pkgsUnstable, - nixpkgs-unstable, - vhackPackages, - pkgs, - extraModules, - nixLib, - ... -}: let - mail_server = import ./nodes/mail_server.nix {inherit extraModules pkgs vhackPackages;}; - inherit (mail_server) mkMailServer; - user = import ./nodes/user.nix {inherit pkgs vhackPackages;}; - inherit (user) mkUser; -in - nixos-lib.runTest { - # Wait until we actually use stalwart again - meta.broken = true; - - hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs - - name = "email-dns"; - - node = { - specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; - - # Use the nixpkgs as constructed by the `nixpkgs.*` options - pkgs = null; - }; - - nodes = { - acme = { - nodes, - lib, - ... - }: { - imports = [ - ../../../common/acme/server.nix - ../../../common/dns/client.nix - ]; - }; - - name_server = import ./nodes/name_server.nix {inherit extraModules;}; - - mail1_server = - mkMailServer "mail1" - { - class = "individual"; - name = "bob"; - secret = "{PLAIN}bob-password"; - email = ["bob@bob.com"]; - }; - - mail2_server = - mkMailServer "mail2" - { - class = "individual"; - name = "alice"; - secret = "{PLAIN}alice-password"; - email = ["alice@alice.com"]; - }; - - bob = mkUser "bob" "mail1"; - alice = mkUser "alice" "mail2"; - }; - - testScript = {...}: let - checkEmailEmpty = pkgs.writeShellScript "assert-empty-emails" '' - set -xe - - # fetchmail returns EXIT_CODE 1 when no new mail - fetchmail --verbose >&2 || [ "$?" -eq 1 ] || { - echo "Mail was not empty" >&2 - exit 1 - } - ''; - checkEmailNotEmpty = pkgs.writeShellScript "assert-empty-emails" '' - set -xe - - # fetchmail returns EXIT_CODE 1 when no new mail - fetchmail --verbose >&2 || [ "$?" -ne 1 ] || { - echo "No new mail" >&2 - exit 1 - } - ''; - checkSpamEmailNotEmpty = pkgs.writeShellScript "assert-empty-emails" '' - set -xe - - # fetchmail returns EXIT_CODE 1 when no new mail - fetchmail --folder JUNK --verbose >&2 || [ "$?" -ne 1 ] || { - echo "No new mail" >&2 - exit 1 - } - ''; - - acme = import ../../../common/acme {inherit pkgs;}; - in - acme.prepare ["mail1_server" "mail2_server" "alice" "bob"] - # Python - '' - from time import sleep - - mail1_server.wait_for_unit("stalwart-mail.service") - mail1_server.wait_for_open_port(993) # imap - mail1_server.wait_for_open_port(465) # smtp - mail2_server.wait_for_unit("stalwart-mail.service") - mail2_server.wait_for_open_port(993) # imap - mail2_server.wait_for_open_port(465) # smtp - - alice.wait_for_unit("multi-user.target") - bob.wait_for_unit("multi-user.target") - - name_server.wait_until_succeeds("stat /var/lib/acme/mta-sts.alice.com/cert.pem") - name_server.wait_until_succeeds("stat /var/lib/acme/mta-sts.bob.com/cert.pem") - - with subtest("Both mailserver successfully started all services"): - import json - def all_services_running(host): - (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json") - host_failed = json.loads(output) - assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}" - all_services_running(mail1_server) - all_services_running(mail2_server) - - with subtest("Both start without mail"): - alice.succeed("sudo -u alice ${checkEmailEmpty}") - bob.succeed("sudo -u bob ${checkEmailEmpty}") - - with subtest("Alice can send an empty email to bob"): - alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' - set -xe - - echo "" | msmtp --debug --account alice bob@bob.com >&2 - ''}") - - # Give `mail2_server` some time to send the email. - sleep(160) - - bob.succeed("sudo -u bob ${checkSpamEmailNotEmpty}") - - with subtest("Alice can send an non-empty email to bob"): - alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' - set -xe - - cat << EOF | msmtp --debug --account alice bob@bob.com >&2 - Subject: Hi bob, I'm Alice! - - Good day, Bob! - - This is an email. - It contains a subject and a body. - I also assert utf8 support by including my last name in this very message. - - XOXO - Alice van Dåligen. - - . - EOF - ''}") - - # Give `mail2_server` some time to send the email. - sleep(120) - - bob.succeed("sudo -u bob ${checkEmailNotEmpty}") - - mail1_server.copy_from_vm("/var/lib/", "server1") - mail2_server.copy_from_vm("/var/lib/", "server2") - bob.copy_from_vm("/home/bob/mail", "bob") - ''; - } diff --git a/tests/by-name/st/stalwart-email-http/test.disabled.nix b/tests/by-name/st/stalwart-email-http/test.disabled.nix new file mode 100644 index 0000000..42fd22b --- /dev/null +++ b/tests/by-name/st/stalwart-email-http/test.disabled.nix @@ -0,0 +1,103 @@ +{ + nixos-lib, + pkgsUnstable, + nixpkgs-unstable, + vhackPackages, + pkgs, + extraModules, + nixLib, + ... +}: let + mail_server = import ./nodes/mail_server.nix {inherit extraModules pkgs vhackPackages;}; + inherit (mail_server) mkMailServer; + user = import ./nodes/user.nix {inherit pkgs vhackPackages;}; + inherit (user) mkUser; +in + nixos-lib.runTest { + # Wait until we actually use stalwart again + meta.broken = true; + + hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs + + name = "email-http"; + + node = { + specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; + + # Use the nixpkgs as constructed by the `nixpkgs.*` options + pkgs = null; + }; + + nodes = { + acme = { + nodes, + lib, + ... + }: { + imports = [ + ../../../common/acme/server.nix + ../../../common/dns/client.nix + ]; + }; + + name_server = {nodes, ...}: { + imports = + extraModules + ++ [ + ../../../common/acme/client.nix + ../../../common/dns/server.nix + ]; + + vhack.dns.zones = { + "mail.server.com" = { + SOA = { + nameServer = "ns"; + adminEmail = "admin@server.com"; + serial = 2025012301; + }; + useOrigin = false; + + A = [ + nodes.mail_server.networking.primaryIPAddress + ]; + AAAA = [ + nodes.mail_server.networking.primaryIPv6Address + ]; + }; + }; + }; + + mail_server = mkMailServer "mail" null; + + bob = mkUser "bob" "mail"; + }; + + # TODO(@bpeetz): This test should also test the http JMAP features of stalwart-mail. <2025-04-12> + testScript = _: let + acme = import ../../../common/acme {inherit pkgs;}; + in + acme.prepare ["mail_server" "bob"] + # Python + '' + mail_server.wait_for_unit("stalwart-mail.service") + mail_server.wait_for_open_port(993) # imap + mail_server.wait_for_open_port(465) # smtp + + bob.wait_for_unit("multi-user.target") + + with subtest("The mailserver successfully started all services"): + import json + def all_services_running(host): + (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json") + host_failed = json.loads(output) + assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}" + all_services_running(mail_server) + + with subtest("Bob can use the self-service interface"): + bob.succeed("${pkgs.writeShellScript "check-self-service" '' + curl mail.server.com --location --output /home/bob/output.html; + ''}") + + bob.copy_from_vm("/home/bob", "") + ''; + } diff --git a/tests/by-name/st/stalwart-email-http/test.nix b/tests/by-name/st/stalwart-email-http/test.nix deleted file mode 100644 index 42fd22b..0000000 --- a/tests/by-name/st/stalwart-email-http/test.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ - nixos-lib, - pkgsUnstable, - nixpkgs-unstable, - vhackPackages, - pkgs, - extraModules, - nixLib, - ... -}: let - mail_server = import ./nodes/mail_server.nix {inherit extraModules pkgs vhackPackages;}; - inherit (mail_server) mkMailServer; - user = import ./nodes/user.nix {inherit pkgs vhackPackages;}; - inherit (user) mkUser; -in - nixos-lib.runTest { - # Wait until we actually use stalwart again - meta.broken = true; - - hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs - - name = "email-http"; - - node = { - specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; - - # Use the nixpkgs as constructed by the `nixpkgs.*` options - pkgs = null; - }; - - nodes = { - acme = { - nodes, - lib, - ... - }: { - imports = [ - ../../../common/acme/server.nix - ../../../common/dns/client.nix - ]; - }; - - name_server = {nodes, ...}: { - imports = - extraModules - ++ [ - ../../../common/acme/client.nix - ../../../common/dns/server.nix - ]; - - vhack.dns.zones = { - "mail.server.com" = { - SOA = { - nameServer = "ns"; - adminEmail = "admin@server.com"; - serial = 2025012301; - }; - useOrigin = false; - - A = [ - nodes.mail_server.networking.primaryIPAddress - ]; - AAAA = [ - nodes.mail_server.networking.primaryIPv6Address - ]; - }; - }; - }; - - mail_server = mkMailServer "mail" null; - - bob = mkUser "bob" "mail"; - }; - - # TODO(@bpeetz): This test should also test the http JMAP features of stalwart-mail. <2025-04-12> - testScript = _: let - acme = import ../../../common/acme {inherit pkgs;}; - in - acme.prepare ["mail_server" "bob"] - # Python - '' - mail_server.wait_for_unit("stalwart-mail.service") - mail_server.wait_for_open_port(993) # imap - mail_server.wait_for_open_port(465) # smtp - - bob.wait_for_unit("multi-user.target") - - with subtest("The mailserver successfully started all services"): - import json - def all_services_running(host): - (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json") - host_failed = json.loads(output) - assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}" - all_services_running(mail_server) - - with subtest("Bob can use the self-service interface"): - bob.succeed("${pkgs.writeShellScript "check-self-service" '' - curl mail.server.com --location --output /home/bob/output.html; - ''}") - - bob.copy_from_vm("/home/bob", "") - ''; - } diff --git a/tests/by-name/st/stalwart-email-ip/test.disabled.nix b/tests/by-name/st/stalwart-email-ip/test.disabled.nix new file mode 100644 index 0000000..c0b2d7e --- /dev/null +++ b/tests/by-name/st/stalwart-email-ip/test.disabled.nix @@ -0,0 +1,177 @@ +{ + nixos-lib, + pkgsUnstable, + nixpkgs-unstable, + vhackPackages, + pkgs, + extraModules, + nixLib, + ... +}: let + domain = "mail.server.test"; + + scripts = { + checkEmailEmpty = pkgs.writeShellScript "assert-empty-emails" '' + set -xe + + # fetchmail returns EXIT_CODE 1 when no new mail + fetchmail --nosslcertck --verbose >&2 || [ "$?" -eq 1 ] || { + echo "Expected exit code 1." >&2 + exit 1 + } + ''; + }; + + mkUser = user: {nodes, ...}: let + domainIp = nodes.server.networking.primaryIPAddress; + in { + environment.systemPackages = with pkgs; [ + fetchmail + msmtp + procmail + ]; + + users.users."${user}" = {isNormalUser = true;}; + + systemd.tmpfiles.rules = [ + "d /home/${user}/mail 0700 ${user} users - -" + "L /home/${user}/.fetchmailrc - - - - /etc/homeSetup/.fetchmailrc" + "L /home/${user}/.procmailrc - - - - /etc/homeSetup/.procmailrc" + "L /home/${user}/.msmtprc - - - - /etc/homeSetup/.msmtprc" + ]; + + environment.etc = { + "homeSetup/.fetchmailrc" = { + text = '' + poll "${domainIp}" protocol IMAP + username "${user}" + password "${user}-password" + ssl + mda procmail; + ''; + mode = "0600"; + inherit user; + }; + "homeSetup/.procmailrc" = { + text = '' + DEFAULT=$HOME/mail + ''; + mode = "0600"; + inherit user; + }; + "homeSetup/.msmtprc" = { + text = '' + account ${user} + host ${domainIp} + port 465 + from ${user}@${domain} + user ${user} + password ${user}-password + auth on + tls on + tls_starttls off + ''; + mode = "0600"; + inherit user; + }; + }; + }; +in + nixos-lib.runTest { + # Wait until we actually use stalwart again + meta.broken = true; + + hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs + + name = "email"; + + node = { + specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; + + # Use the nixpkgs as constructed by the `nixpkgs.*` options + pkgs = null; + }; + + nodes = { + server = {config, ...}: { + imports = + extraModules + ++ [ + ../../../../modules + ]; + + vhack = { + nginx = { + enable = true; + selfsign = true; + }; + + stalwart-mail = { + enable = true; + fqdn = domain; + admin = "mailto:admin@${domain}"; + security = null; + openFirewall = true; + principals = [ + { + class = "individual"; + name = "alice"; + secret = "{PLAIN}alice-password"; + email = ["alice@${domain}"]; + } + { + class = "individual"; + name = "bob"; + secret = "{PLAIN}bob-password"; + email = ["bob@${domain}"]; + } + ]; + }; + }; + }; + + alice = mkUser "alice"; + bob = mkUser "bob"; + }; + + testScript = {...}: + /* + python + */ + '' + start_all() + + server.wait_for_unit("stalwart-mail.service") + server.wait_for_open_port(993) # imap + server.wait_for_open_port(465) # smtp + + with subtest("Both start without mail"): + alice.succeed("sudo -u alice ${scripts.checkEmailEmpty}") + bob.succeed("sudo -u bob ${scripts.checkEmailEmpty}") + + with subtest("Alice can send an email to bob"): + alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' + set -xe + + cat << EOF | msmtp --debug --account alice --tls-certcheck=off bob@${domain} >&2 + Hi Bob! + + This is an email. + It contains a subject and a body. + + ALICE + EOF + ''}") + bob.succeed("sudo -u bob ${pkgs.writeShellScript "bob-receive" '' + set -xe + + fetchmail --nosslcertck --verbose >&2 || { + echo New Mail did not arrive + exit 1 + } + ''}") + + server.copy_from_vm("/var/lib/", "server") + bob.copy_from_vm("/home/bob/mail", "bob") + ''; + } diff --git a/tests/by-name/st/stalwart-email-ip/test.nix b/tests/by-name/st/stalwart-email-ip/test.nix deleted file mode 100644 index c0b2d7e..0000000 --- a/tests/by-name/st/stalwart-email-ip/test.nix +++ /dev/null @@ -1,177 +0,0 @@ -{ - nixos-lib, - pkgsUnstable, - nixpkgs-unstable, - vhackPackages, - pkgs, - extraModules, - nixLib, - ... -}: let - domain = "mail.server.test"; - - scripts = { - checkEmailEmpty = pkgs.writeShellScript "assert-empty-emails" '' - set -xe - - # fetchmail returns EXIT_CODE 1 when no new mail - fetchmail --nosslcertck --verbose >&2 || [ "$?" -eq 1 ] || { - echo "Expected exit code 1." >&2 - exit 1 - } - ''; - }; - - mkUser = user: {nodes, ...}: let - domainIp = nodes.server.networking.primaryIPAddress; - in { - environment.systemPackages = with pkgs; [ - fetchmail - msmtp - procmail - ]; - - users.users."${user}" = {isNormalUser = true;}; - - systemd.tmpfiles.rules = [ - "d /home/${user}/mail 0700 ${user} users - -" - "L /home/${user}/.fetchmailrc - - - - /etc/homeSetup/.fetchmailrc" - "L /home/${user}/.procmailrc - - - - /etc/homeSetup/.procmailrc" - "L /home/${user}/.msmtprc - - - - /etc/homeSetup/.msmtprc" - ]; - - environment.etc = { - "homeSetup/.fetchmailrc" = { - text = '' - poll "${domainIp}" protocol IMAP - username "${user}" - password "${user}-password" - ssl - mda procmail; - ''; - mode = "0600"; - inherit user; - }; - "homeSetup/.procmailrc" = { - text = '' - DEFAULT=$HOME/mail - ''; - mode = "0600"; - inherit user; - }; - "homeSetup/.msmtprc" = { - text = '' - account ${user} - host ${domainIp} - port 465 - from ${user}@${domain} - user ${user} - password ${user}-password - auth on - tls on - tls_starttls off - ''; - mode = "0600"; - inherit user; - }; - }; - }; -in - nixos-lib.runTest { - # Wait until we actually use stalwart again - meta.broken = true; - - hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs - - name = "email"; - - node = { - specialArgs = {inherit pkgsUnstable vhackPackages nixpkgs-unstable nixLib;}; - - # Use the nixpkgs as constructed by the `nixpkgs.*` options - pkgs = null; - }; - - nodes = { - server = {config, ...}: { - imports = - extraModules - ++ [ - ../../../../modules - ]; - - vhack = { - nginx = { - enable = true; - selfsign = true; - }; - - stalwart-mail = { - enable = true; - fqdn = domain; - admin = "mailto:admin@${domain}"; - security = null; - openFirewall = true; - principals = [ - { - class = "individual"; - name = "alice"; - secret = "{PLAIN}alice-password"; - email = ["alice@${domain}"]; - } - { - class = "individual"; - name = "bob"; - secret = "{PLAIN}bob-password"; - email = ["bob@${domain}"]; - } - ]; - }; - }; - }; - - alice = mkUser "alice"; - bob = mkUser "bob"; - }; - - testScript = {...}: - /* - python - */ - '' - start_all() - - server.wait_for_unit("stalwart-mail.service") - server.wait_for_open_port(993) # imap - server.wait_for_open_port(465) # smtp - - with subtest("Both start without mail"): - alice.succeed("sudo -u alice ${scripts.checkEmailEmpty}") - bob.succeed("sudo -u bob ${scripts.checkEmailEmpty}") - - with subtest("Alice can send an email to bob"): - alice.succeed("sudo -u alice ${pkgs.writeShellScript "alice-send" '' - set -xe - - cat << EOF | msmtp --debug --account alice --tls-certcheck=off bob@${domain} >&2 - Hi Bob! - - This is an email. - It contains a subject and a body. - - ALICE - EOF - ''}") - bob.succeed("sudo -u bob ${pkgs.writeShellScript "bob-receive" '' - set -xe - - fetchmail --nosslcertck --verbose >&2 || { - echo New Mail did not arrive - exit 1 - } - ''}") - - server.copy_from_vm("/var/lib/", "server") - bob.copy_from_vm("/home/bob/mail", "bob") - ''; - } -- cgit v1.3.1