1 import ./make-test-python.nix ({ pkgs, lib, ... }:
5 meta.maintainers = with lib.maintainers; [ minijackson ];
7 nodes.machine = { ... }: { services.shiori.enable = true; };
10 authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
17 url = "http://example.org";
18 title = "Example Bookmark";
22 pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
26 machine.wait_for_unit("shiori.service")
27 machine.wait_for_open_port(8080)
28 machine.succeed("curl --fail http://localhost:8080/")
29 machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
31 # The test code below no longer works because the API authentication has changed.
33 #with subtest("login"):
34 # auth_json = machine.succeed(
35 # "curl --fail --location http://localhost:8080/api/login "
36 # "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
38 # auth_ret = json.loads(auth_json)
39 # session_id = auth_ret["session"]
41 #with subtest("bookmarks"):
42 # with subtest("first use no bookmarks"):
43 # bookmarks_json = machine.succeed(
45 # "curl --fail --location http://localhost:8080/api/bookmarks "
46 # "-H 'X-Session-Id:{}'"
47 # ).format(session_id)
50 # if json.loads(bookmarks_json)["bookmarks"] != []:
51 # raise Exception("Shiori have a bookmark on first use")
53 # with subtest("insert bookmark"):
56 # "curl --fail --location http://localhost:8080/api/bookmarks "
57 # "-X POST -H 'X-Session-Id:{}' "
58 # "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
59 # ).format(session_id)
62 # with subtest("get inserted bookmark"):
63 # bookmarks_json = machine.succeed(
65 # "curl --fail --location http://localhost:8080/api/bookmarks "
66 # "-H 'X-Session-Id:{}'"
67 # ).format(session_id)
70 # bookmarks = json.loads(bookmarks_json)["bookmarks"]
71 # if len(bookmarks) != 1:
72 # raise Exception("Shiori didn't save the bookmark")
74 # bookmark = bookmarks[0]
76 # bookmark["url"] != "${insertBookmark.url}"
77 # or bookmark["title"] != "${insertBookmark.title}"
79 # raise Exception("Inserted bookmark doesn't have same URL or title")