python312Packages.dissect-extfs: 3.11 -> 3.12
[NixPkgs.git] / nixos / tests / shiori.nix
blobba9b42235df2823c855f7951d8b06fca76362426
1 import ./make-test-python.nix ({ pkgs, lib, ... }:
3   {
4     name = "shiori";
5     meta.maintainers = with lib.maintainers; [ minijackson ];
7     nodes.machine = { ... }: { services.shiori.enable = true; };
9     testScript = let
10       authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
11         username = "shiori";
12         password = "gopher";
13         owner = true;
14       });
16       insertBookmark = {
17         url = "http://example.org";
18         title = "Example Bookmark";
19       };
21       insertBookmarkJSON =
22         pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
23     in ''
24       #import json
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}"
37       #    )
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(
44       #            (
45       #                "curl --fail --location http://localhost:8080/api/bookmarks "
46       #                "-H 'X-Session-Id:{}'"
47       #            ).format(session_id)
48       #        )
50       #        if json.loads(bookmarks_json)["bookmarks"] != []:
51       #            raise Exception("Shiori have a bookmark on first use")
53       #    with subtest("insert bookmark"):
54       #        machine.succeed(
55       #            (
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)
60       #        )
62       #    with subtest("get inserted bookmark"):
63       #        bookmarks_json = machine.succeed(
64       #            (
65       #                "curl --fail --location http://localhost:8080/api/bookmarks "
66       #                "-H 'X-Session-Id:{}'"
67       #            ).format(session_id)
68       #        )
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]
75       #        if (
76       #            bookmark["url"] != "${insertBookmark.url}"
77       #            or bookmark["title"] != "${insertBookmark.title}"
78       #        ):
79       #            raise Exception("Inserted bookmark doesn't have same URL or title")
80     '';
81   })