nixVersions.stable: 2.15 -> 2.17
[NixPkgs.git] / nixos / tests / freshrss-pgsql.nix
blob055bd51ed43d78a724d2ee6978278c5a7fb9c514
1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2   name = "freshrss";
3   meta.maintainers = with lib.maintainers; [ etu stunkymonkey ];
5   nodes.machine = { pkgs, ... }: {
6     services.freshrss = {
7       enable = true;
8       baseUrl = "http://localhost";
9       passwordFile = pkgs.writeText "password" "secret";
10       dataDir = "/srv/freshrss";
11       database = {
12         type = "pgsql";
13         port = 5432;
14         user = "freshrss";
15         passFile = pkgs.writeText "db-password" "db-secret";
16       };
17     };
19     services.postgresql = {
20       enable = true;
21       ensureDatabases = [ "freshrss" ];
22       ensureUsers = [
23         {
24           name = "freshrss";
25           ensurePermissions = {
26             "DATABASE freshrss" = "ALL PRIVILEGES";
27           };
28         }
29       ];
30       initialScript = pkgs.writeText "postgresql-password" ''
31         CREATE ROLE freshrss WITH LOGIN PASSWORD 'db-secret' CREATEDB;
32       '';
33     };
35     systemd.services."freshrss-config" = {
36       requires = [ "postgresql.service" ];
37       after = [ "postgresql.service" ];
38     };
39   };
41   testScript = ''
42     machine.wait_for_unit("multi-user.target")
43     machine.wait_for_open_port(5432)
44     machine.wait_for_open_port(80)
45     response = machine.succeed("curl -vvv -s -H 'Host: freshrss' http://127.0.0.1:80/i/")
46     assert '<title>Login ยท FreshRSS</title>' in response, "Login page didn't load successfully"
47   '';