Skip to content

Commit

Permalink
Merge pull request #68 from griff/fix-email-tests
Browse files Browse the repository at this point in the history
email: Support webmail without TLS and fix test
  • Loading branch information
qknight authored Apr 8, 2020
2 parents 5a1ed62 + 88eaa6f commit 3a0767f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 5 additions & 3 deletions modules/services/email/nixcloud-email.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ let
proxyOptions = {
domain = "${extraFQDN}";
port = port;
TLS = "${primaryFQDN}";
TLS = lib.mkIf cfg.enableTLS "${primaryFQDN}";
http.mode = if cfg.enableTLS then "redirect_to_https" else "on";
https.mode = if cfg.enableTLS then "on" else "off";
};
};
# unique set of primary FQDN and additional domains in nixcloud.email, prefixed with `mail.` depending on `autoMailDomain`
Expand Down Expand Up @@ -297,8 +299,6 @@ in {

config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.mkIf cfg.enableTLS {
nixcloud.reverse-proxy.enable = true;

systemd.services.postfix.after = [ "nixcloud.TLS-certificates.target" ];
systemd.services.postfix.wants = [ "nixcloud.TLS-certificates.target" ];

Expand Down Expand Up @@ -492,6 +492,8 @@ in {
];
};

nixcloud.reverse-proxy.enable = cfg.enableTLS || cfg.webmail.enable;

services.mailUsers.users = cfg.users;

nixcloud.tests.wanted = [ ./test ];
Expand Down
6 changes: 2 additions & 4 deletions modules/services/email/test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ in {
'');
};

testScript = let
rcSearchFor = "<title>Roundcube</title>";
in ''
testScript = ''
startAll;
$dns->waitForUnit('bind.service');
$mail1->waitForUnit('multi-user.target');
Expand All @@ -197,7 +195,7 @@ in {
$mail2->waitForOpenPort(80);
$mail1->waitForOpenPort(8993);
$mail2->waitForOpenPort(8993);
$mail1->succeed('curl -L https://mail.example.org/ | grep -qF "${rcSearchFor}"');
$mail1->succeed('curl -L http://mail.example.org/ | grep -qF "<title>Roundcube"');
# Check spam learning
$mail2->waitUntilSucceeds("journalctl -u dovecot2 | grep learn-spam.sh >&2");
$mail2->succeed('journalctl -u rspamd | grep "csession; rspamd_controller_learn_fin_task: </run/rspamd/worker-controller.sock> learned message as spam" >&2');
Expand Down

0 comments on commit 3a0767f

Please sign in to comment.