mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
87 lines
3.7 KiB
Nix
87 lines
3.7 KiB
Nix
import ./make-test-python.nix {
|
|
name = "mailman";
|
|
|
|
nodes.machine =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [ mailutils ];
|
|
|
|
services.mailman.enable = true;
|
|
services.mailman.serve.enable = true;
|
|
services.mailman.siteOwner = "postmaster@example.com";
|
|
services.mailman.webHosts = [ "example.com" ];
|
|
|
|
services.postfix.enable = true;
|
|
services.postfix.destination = [
|
|
"example.com"
|
|
"example.net"
|
|
];
|
|
services.postfix.relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
|
|
services.postfix.config.local_recipient_maps = [
|
|
"hash:/var/lib/mailman/data/postfix_lmtp"
|
|
"proxy:unix:passwd.byname"
|
|
];
|
|
services.postfix.config.transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
|
|
|
|
users.users.user = {
|
|
isNormalUser = true;
|
|
};
|
|
|
|
virtualisation.memorySize = 2048;
|
|
|
|
specialisation.restApiPassFileSystem.configuration = {
|
|
services.mailman.restApiPassFile = "/var/lib/mailman/pass";
|
|
};
|
|
};
|
|
|
|
testScript =
|
|
{ nodes, ... }:
|
|
let
|
|
restApiPassFileSystem = "${nodes.machine.system.build.toplevel}/specialisation/restApiPassFileSystem";
|
|
in
|
|
''
|
|
def check_mail(_) -> bool:
|
|
status, _ = machine.execute("grep -q hello /var/spool/mail/user/new/*")
|
|
return status == 0
|
|
|
|
def try_api(_) -> bool:
|
|
status, _ = machine.execute("curl -s http://localhost:8001/")
|
|
return status == 0
|
|
|
|
def wait_for_api():
|
|
with machine.nested("waiting for Mailman REST API to be available"):
|
|
retry(try_api)
|
|
|
|
machine.wait_for_unit("mailman.service")
|
|
wait_for_api()
|
|
|
|
with subtest("subscription and delivery"):
|
|
creds = machine.succeed("su -s /bin/sh -c 'mailman info' mailman | grep '^REST credentials: ' | sed 's/^REST credentials: //'").strip()
|
|
machine.succeed(f"curl --fail-with-body -sLSu {creds} -d mail_host=example.com http://localhost:8001/3.1/domains")
|
|
machine.succeed(f"curl --fail-with-body -sLSu {creds} -d fqdn_listname=list@example.com http://localhost:8001/3.1/lists")
|
|
machine.succeed(f"curl --fail-with-body -sLSu {creds} -d list_id=list.example.com -d subscriber=root@example.com -d pre_confirmed=True -d pre_verified=True -d send_welcome_message=False http://localhost:8001/3.1/members")
|
|
machine.succeed(f"curl --fail-with-body -sLSu {creds} -d list_id=list.example.com -d subscriber=user@example.net -d pre_confirmed=True -d pre_verified=True -d send_welcome_message=False http://localhost:8001/3.1/members")
|
|
machine.succeed("mail -a 'From: root@example.com' -s hello list@example.com < /dev/null")
|
|
with machine.nested("waiting for mail from list"):
|
|
retry(check_mail)
|
|
|
|
with subtest("Postorius"):
|
|
machine.succeed("curl --fail-with-body -sILS http://localhost/")
|
|
|
|
with subtest("restApiPassFile"):
|
|
machine.succeed("echo secretpassword > /var/lib/mailman/pass")
|
|
machine.succeed("${restApiPassFileSystem}/bin/switch-to-configuration test >&2")
|
|
machine.succeed("grep secretpassword /etc/mailman.cfg")
|
|
machine.succeed("su -s /bin/sh -c 'mailman info' mailman | grep secretpassword")
|
|
wait_for_api()
|
|
machine.succeed("curl --fail-with-body -sLSu restadmin:secretpassword http://localhost:8001/3.1/domains")
|
|
machine.succeed("curl --fail-with-body -sILS http://localhost/")
|
|
|
|
with subtest("service locking"):
|
|
machine.fail("su -s /bin/sh -c 'mailman start' mailman")
|
|
machine.execute("systemctl kill --signal=SIGKILL mailman")
|
|
machine.succeed("systemctl restart mailman")
|
|
wait_for_api()
|
|
'';
|
|
}
|