1 import ./make-test-python.nix ({ pkgs, lib, ...}:
5 meta.maintainers = with lib.maintainers; [ minijackson ];
9 { services.shiori.enable = true; };
12 authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
19 url = "http://example.org";
20 title = "Example Bookmark";
23 insertBookmarkJSON = pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
27 machine.wait_for_unit("shiori.service")
28 machine.wait_for_open_port(8080)
29 machine.succeed("curl --fail http://localhost:8080/")
30 machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
32 with subtest("login"):
33 auth_json = machine.succeed(
34 "curl --fail --location http://localhost:8080/api/login "
35 "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
37 auth_ret = json.loads(auth_json)
38 session_id = auth_ret["session"]
40 with subtest("bookmarks"):
41 with subtest("first use no bookmarks"):
42 bookmarks_json = machine.succeed(
44 "curl --fail --location http://localhost:8080/api/bookmarks "
45 "-H 'X-Session-Id:{}'"
49 if json.loads(bookmarks_json)["bookmarks"] != []:
50 raise Exception("Shiori have a bookmark on first use")
52 with subtest("insert bookmark"):
55 "curl --fail --location http://localhost:8080/api/bookmarks "
56 "-X POST -H 'X-Session-Id:{}' "
57 "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
61 with subtest("get inserted bookmark"):
62 bookmarks_json = machine.succeed(
64 "curl --fail --location http://localhost:8080/api/bookmarks "
65 "-H 'X-Session-Id:{}'"
69 bookmarks = json.loads(bookmarks_json)["bookmarks"]
70 if len(bookmarks) != 1:
71 raise Exception("Shiori didn't save the bookmark")
73 bookmark = bookmarks[0]
75 bookmark["url"] != "${insertBookmark.url}"
76 or bookmark["title"] != "${insertBookmark.title}"
78 raise Exception("Inserted bookmark doesn't have same URL or title")