about summary refs log tree commit diff
path: root/nixos/tests/rspamd.nix
diff options
context:
space:
mode:
authorBrian Olsen <brian@maven-group.org>2018-11-06 00:40:52 +0100
committerBrian Olsen <brian@maven-group.org>2018-11-09 01:31:27 +0100
commite01605be153906394cd35cd728e8e7c7fbce473e (patch)
treeb5e1a2832c3a7544d4768f532e800afea847c39e /nixos/tests/rspamd.nix
parentfba69f388bbb7ab9f79b646e55ef1ef78daa1213 (diff)
downloadnixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar.gz
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar.bz2
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar.lz
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar.xz
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.tar.zst
nixlib-e01605be153906394cd35cd728e8e7c7fbce473e.zip
nixos/rspamd: Add options for postfix integration
The `rmilter` module has options for configuring `postfix` to use it but
since that module is deprecated because rspamd now has a builtin worker
that supports the milter protocol this commit adds similar `postfix`
integration options directly to the `rspamd` module.
Diffstat (limited to 'nixos/tests/rspamd.nix')
-rw-r--r--nixos/tests/rspamd.nix44
1 files changed, 44 insertions, 0 deletions
diff --git a/nixos/tests/rspamd.nix b/nixos/tests/rspamd.nix
index ccfe8f7bb0d8..076632a70bab 100644
--- a/nixos/tests/rspamd.nix
+++ b/nixos/tests/rspamd.nix
@@ -181,4 +181,48 @@ in
       $machine->log($machine->succeed("cat /etc/tests/muh.eml | rspamc -h 127.0.0.1:11334 symbols | grep NO_MUH"));
     '';
   };
+  postfixIntegration = makeTest {
+    name = "rspamd-postfix-integration";
+    machine = {
+      environment.systemPackages = with pkgs; [ msmtp ];
+      environment.etc."tests/gtube.eml".text = ''
+        From: Sheep1<bah@example.com>
+        To: Sheep2<tester@example.com>
+        Subject: Evil cows
+
+        I find cows to be evil don't you?
+
+        XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
+      '';
+      environment.etc."tests/example.eml".text = ''
+        From: Sheep1<bah@example.com>
+        To: Sheep2<tester@example.com>
+        Subject: Evil cows
+
+        I find cows to be evil don't you?
+      '';
+      users.users.tester.password = "test";
+      services.postfix = {
+        enable = true;
+        destination = ["example.com"];
+      };
+      services.rspamd = {
+        enable = true;
+        postfix.enable = true;
+      };
+    };
+    testScript = ''
+      ${initMachine}
+      $machine->waitForOpenPort(11334);
+      $machine->waitForOpenPort(25);
+      ${checkSocket "/run/rspamd/rspamd-milter.sock" "rspamd" "postfix" "660" }
+      $machine->log($machine->succeed("rspamc -h 127.0.0.1:11334 stat"));
+      $machine->log($machine->succeed("msmtp --host=localhost -t --read-envelope-from < /etc/tests/example.eml"));
+      $machine->log($machine->fail("msmtp --host=localhost -t --read-envelope-from < /etc/tests/gtube.eml"));
+
+      $machine->waitUntilFails('[ "$(postqueue -p)" != "Mail queue is empty" ]');
+      $machine->fail("journalctl -u postfix | grep -i error >&2");
+      $machine->fail("journalctl -u postfix | grep -i warning >&2");
+    '';
+  };
 }