1import ./make-test-python.nix (
2 { pkgs, ... }:
3 {
4 name = "kavita";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ misterio77 ];
7 };
8
9 nodes = {
10 kavita =
11 { config, pkgs, ... }:
12 {
13 services.kavita = {
14 enable = true;
15 tokenKeyFile = builtins.toFile "kavita.key" "d26ba694b455271a8872415830fb7b5c58f8da98f9ef7f58b2ca4c34bd406512";
16 };
17 };
18 };
19
20 testScript =
21 let
22 regUrl = "http://kavita:5000/api/Account/register";
23 loginUrl = "http://kavita:5000/api/Account/login";
24 localeUrl = "http://kavita:5000/api/locale";
25 in
26 ''
27 import json
28
29 kavita.start
30 kavita.wait_for_unit("kavita.service")
31
32 # Check that static assets are working
33 kavita.wait_until_succeeds("curl http://kavita:5000/site.webmanifest | grep Kavita")
34
35 # Check that registration is working
36 kavita.succeed("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
37 # But only for the first one
38 kavita.fail("""curl -fX POST ${regUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'""")
39
40 # Log in and retrieve token
41 session = json.loads(kavita.succeed("""curl -fX POST ${loginUrl} --json '{"username": "foo", "password": "correcthorsebatterystaple"}'"""))
42 # Check list of locales
43 locales = json.loads(kavita.succeed(f"curl -fX GET ${localeUrl} -H 'Authorization: Bearer {session['token']}'"))
44 assert len(locales) > 0, "expected a list of locales"
45 '';
46 }
47)