about summary refs log tree commit diff
path: root/nixos/tests/calibre-web.nix
blob: 9832d54697872222c499c23e4590b022018d3726 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import ./make-test-python.nix (
  { pkgs, lib, ... }:

    let
      port = 3142;
      defaultPort = 8083;
    in
      with lib;
      {
        name = "calibre-web";
        meta.maintainers = with pkgs.lib.maintainers; [ pborzenkov ];

        nodes = {
          customized = { pkgs, ... }: {
            services.calibre-web = {
              enable = true;
              listen.port = port;
              options = {
                calibreLibrary = "/tmp/books";
                reverseProxyAuth = {
                  enable = true;
                  header = "X-User";
                };
              };
            };
            environment.systemPackages = [ pkgs.calibre ];
          };
        };
        testScript = ''
          start_all()

          customized.succeed(
              "mkdir /tmp/books && calibredb --library-path /tmp/books add -e --title test-book"
          )
          customized.succeed("systemctl restart calibre-web")
          customized.wait_for_unit("calibre-web.service")
          customized.wait_for_open_port(${toString port})
          customized.succeed(
              "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep test-book"
          )
        '';
      }
)