diff options
author | Léo Gaspard <leo@gaspard.io> | 2018-10-27 18:33:43 +0900 |
---|---|---|
committer | Léo Gaspard <leo@gaspard.io> | 2018-11-15 23:44:16 +0900 |
commit | 0483ce0eeeb7c859e58a287d6f1a0d4e959efffb (patch) | |
tree | 0e359369726917b9476f310a8a185b3a4570e378 /nixos/tests/rss2email.nix | |
parent | 4b5ffcb964b48c2754aa8964699b339840f507d3 (diff) |
rss2email module: init
Also adding `system-sendmail` package for sharing the code with other modules or packages needing it.
Diffstat (limited to 'nixos/tests/rss2email.nix')
-rw-r--r-- | nixos/tests/rss2email.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/nixos/tests/rss2email.nix b/nixos/tests/rss2email.nix new file mode 100644 index 0000000000000..492d47da9f56e --- /dev/null +++ b/nixos/tests/rss2email.nix @@ -0,0 +1,66 @@ +import ./make-test.nix { + name = "opensmtpd"; + + nodes = { + server = { pkgs, ... }: { + imports = [ common/user-account.nix ]; + services.nginx = { + enable = true; + virtualHosts."127.0.0.1".root = ./common/webroot; + }; + services.rss2email = { + enable = true; + to = "alice@localhost"; + interval = "1"; + config.from = "test@example.org"; + feeds = { + nixos = { url = "http://127.0.0.1/news-rss.xml"; }; + }; + }; + services.opensmtpd = { + enable = true; + extraServerArgs = [ "-v" ]; + serverConfiguration = '' + listen on 127.0.0.1 + action dovecot_deliver mda \ + "${pkgs.dovecot}/libexec/dovecot/deliver -d %{user.username}" + match from any for local action dovecot_deliver + ''; + }; + services.dovecot2 = { + enable = true; + enableImap = true; + mailLocation = "maildir:~/mail"; + protocols = [ "imap" ]; + }; + environment.systemPackages = let + checkMailLanded = pkgs.writeScriptBin "check-mail-landed" '' + #!${pkgs.python3.interpreter} + import imaplib + + with imaplib.IMAP4('127.0.0.1', 143) as imap: + imap.login('alice', 'foobar') + imap.select() + status, refs = imap.search(None, 'ALL') + print("=====> Result of search for all:", status, refs) + assert status == 'OK' + assert len(refs) > 0 + status, msg = imap.fetch(refs[0], 'BODY[TEXT]') + assert status == 'OK' + ''; + in [ pkgs.opensmtpd checkMailLanded ]; + }; + }; + + testScript = '' + startAll; + + $server->waitForUnit("network-online.target"); + $server->waitForUnit("opensmtpd"); + $server->waitForUnit("dovecot2"); + $server->waitForUnit("nginx"); + $server->waitForUnit("rss2email"); + + $server->waitUntilSucceeds('check-mail-landed >&2'); + ''; +} |