python312Packages.homematicip: 1.1.2 -> 1.1.3 (#356780)
[NixPkgs.git] / nixos / tests / cyrus-imap.nix
blob36145ed4748e42b9efff200ba93b532140929b09
1 { lib, pkgs, ... }:
3   name = "cyrus-imap";
5   meta = {
6     maintainers = with lib.maintainers; [ moraxyc ];
7   };
9   nodes.machine =
10     { pkgs, ... }:
11     {
12       environment.systemPackages = with pkgs; [
13         curl
14         sudo
15       ];
16       services.saslauthd = {
17         enable = true;
18         config = ''
19           DESC="SASL Authentication Daemon"
20           NAME="saslauthd"
21           MECH_OPTIONS=""
22           THREADS=5
23           START=yes
24           OPTIONS="-c -m /run/saslauthd"
25         '';
26       };
27       services.cyrus-imap = {
28         enable = true;
29         cyrusSettings = {
30           START = {
31             recover = {
32               cmd = [
33                 "ctl_cyrusdb"
34                 "-r"
35               ];
36             };
37           };
38           EVENTS = {
39             tlsprune = {
40               cmd = [ "tls_prune" ];
41               at = 400;
42             };
43             delprune = {
44               cmd = [
45                 "cyr_expire"
46                 "-E"
47                 "3"
48               ];
49               at = 400;
50             };
51             deleteprune = {
52               cmd = [
53                 "cyr_expire"
54                 "-E"
55                 "4"
56                 "-D"
57                 "28"
58               ];
59               at = 430;
60             };
61             expungeprune = {
62               cmd = [
63                 "cyr_expire"
64                 "-E"
65                 "4"
66                 "-X"
67                 "28"
68               ];
69               at = 445;
70             };
71             checkpoint = {
72               cmd = [
73                 "ctl_cyrusdb"
74                 "-c"
75               ];
76               period = 30;
77             };
78           };
79           SERVICES = {
80             http = {
81               cmd = [ "httpd" ];
82               listen = "80";
83               prefork = 0;
84             };
85             imap = {
86               cmd = [ "imapd" ];
87               listen = "143";
88               prefork = 0;
89             };
90             lmtpunix = {
91               cmd = [ "lmtpd" ];
92               listen = "/run/cyrus/lmtp";
93               prefork = 0;
94             };
95             notify = {
96               cmd = [ "notifyd" ];
97               listen = "/run/cyrus/notify";
98               proto = "udp";
99               prefork = 0;
100             };
101           };
102         };
103       };
104     };
106   testScript = ''
107     machine.wait_for_unit("saslauthd.service")
108     machine.wait_for_unit("cyrus-imap.service")
110     machine.wait_for_open_port(80)
111     machine.wait_for_open_port(143)
113     machine.succeed("echo 'secret' | ${lib.getExe' pkgs.cyrus_sasl.bin "saslpasswd2"} -p -c cyrus")
114     machine.succeed("chown cyrus /etc/sasldb2")
116     machine.succeed("sudo -ucyrus curl --fail --max-time 10 imap://cyrus:secret@localhost:143")
117     machine.fail("curl --fail --max-time 10 imap://cyrus:wrongsecret@localhost:143")
118     machine.fail("curl --fail --max-time 10 -X PROPFIND -H 'Depth: 1' 'http://localhost/dav/addressbooks/user/cyrus@localhost/Default'")
119   '';