about summary refs log tree commit diff
path: root/nixpkgs/nixos/tests/kavita.nix
blob: f27b3fffbcf64013c4a5b5f4d7572f5ce6aa32b7 (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
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "kavita";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ misterio77 ];
  };

  nodes = {
    kavita = { config, pkgs, ... }: {
      services.kavita = {
        enable = true;
        port = 5000;
        tokenKeyFile = builtins.toFile "kavita.key" "QfpjFvjT83BLtZ74GE3U3Q==";
      };
    };
  };

  testScript = let
    regUrl = "http://kavita:5000/api/Account/register";
    payload = builtins.toFile "payload.json" (builtins.toJSON {
      username = "foo";
      password = "correcthorsebatterystaple";
      email = "foo@bar";
    });
  in ''
    kavita.start
    kavita.wait_for_unit("kavita.service")

    # Check that static assets are working
    kavita.wait_until_succeeds("curl http://kavita:5000/site.webmanifest | grep Kavita")

    # Check that registration is working
    kavita.succeed("curl -fX POST ${regUrl} --json @${payload}")
    # But only for the first one
    kavita.fail("curl -fX POST ${regUrl} --json @${payload}")
  '';
})