about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-11-08 23:06:06 +0100
committerGitHub <noreply@github.com>2019-11-08 23:06:06 +0100
commit3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8 (patch)
tree10f35237b393e67a5547d7bbd51c429befe5628b
parent54b04766188387f055e1582ddc6e62d13226d98e (diff)
parent26acc9e63d9151b331651cc658276a6ba1d628ee (diff)
downloadnixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar.gz
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar.bz2
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar.lz
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar.xz
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.tar.zst
nixlib-3928e7f6b1d597d20bf4bf23a2b633e1a7c061f8.zip
Merge pull request #73063 from minijackson/shiori-things
shiori: update modSha256, update test to python, do more tests
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/shiori.nix76
-rw-r--r--pkgs/servers/web-apps/shiori/default.nix2
3 files changed, 72 insertions, 7 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 636c4e93e9b3..9db505a27d41 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -244,6 +244,7 @@ in
   rxe = handleTest ./rxe.nix {};
   samba = handleTest ./samba.nix {};
   sddm = handleTest ./sddm.nix {};
+  shiori = handleTest ./shiori.nix {};
   signal-desktop = handleTest ./signal-desktop.nix {};
   simple = handleTest ./simple.nix {};
   slim = handleTest ./slim.nix {};
diff --git a/nixos/tests/shiori.nix b/nixos/tests/shiori.nix
index 0022a7220fe2..a5771262c6f2 100644
--- a/nixos/tests/shiori.nix
+++ b/nixos/tests/shiori.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ lib, ...}:
+import ./make-test-python.nix ({ pkgs, lib, ...}:
 
 {
   name = "shiori";
@@ -8,10 +8,74 @@ import ./make-test.nix ({ lib, ...}:
     { ... }:
     { services.shiori.enable = true; };
 
-  testScript = ''
-    $machine->waitForUnit('shiori.service');
-    $machine->waitForOpenPort('8080');
-    $machine->succeed("curl --fail http://localhost:8080/");
-    $machine->succeed("curl --fail --location http://localhost:8080/ | grep -qi shiori");
+  testScript = let
+    authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
+      username = "shiori";
+      password = "gopher";
+      remember = 1; # hour
+      owner = true;
+    });
+
+  insertBookmark = {
+    url = "http://example.org";
+    title = "Example Bookmark";
+  };
+
+  insertBookmarkJSON = pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
+  in ''
+    import json
+
+    machine.wait_for_unit("shiori.service")
+    machine.wait_for_open_port(8080)
+    machine.succeed("curl --fail http://localhost:8080/")
+    machine.succeed("curl --fail --location http://localhost:8080/ | grep -qi shiori")
+
+    with subtest("login"):
+        auth_json = machine.succeed(
+            "curl --fail --location http://localhost:8080/api/login "
+            "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
+        )
+        auth_ret = json.loads(auth_json)
+        session_id = auth_ret["session"]
+
+    with subtest("bookmarks"):
+        with subtest("first use no bookmarks"):
+            bookmarks_json = machine.succeed(
+                (
+                    "curl --fail --location http://localhost:8080/api/bookmarks "
+                    "-H 'X-Session-Id:{}'"
+                ).format(session_id)
+            )
+
+            if json.loads(bookmarks_json)["bookmarks"] != []:
+                raise Exception("Shiori have a bookmark on first use")
+
+        with subtest("insert bookmark"):
+            machine.succeed(
+                (
+                    "curl --fail --location http://localhost:8080/api/bookmarks "
+                    "-X POST -H 'X-Session-Id:{}' "
+                    "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
+                ).format(session_id)
+            )
+
+        with subtest("get inserted bookmark"):
+            bookmarks_json = machine.succeed(
+                (
+                    "curl --fail --location http://localhost:8080/api/bookmarks "
+                    "-H 'X-Session-Id:{}'"
+                ).format(session_id)
+            )
+
+            bookmarks = json.loads(bookmarks_json)["bookmarks"]
+            if len(bookmarks) != 1:
+                raise Exception("Shiori didn't save the bookmark")
+
+            bookmark = bookmarks[0]
+            if (
+                bookmark["url"] != "${insertBookmark.url}"
+                or bookmark["title"] != "${insertBookmark.title}"
+            ):
+                raise Exception("Inserted bookmark doesn't have same URL or title")
   '';
 })
diff --git a/pkgs/servers/web-apps/shiori/default.nix b/pkgs/servers/web-apps/shiori/default.nix
index 5cf54ff14ba3..dd4cdc08287b 100644
--- a/pkgs/servers/web-apps/shiori/default.nix
+++ b/pkgs/servers/web-apps/shiori/default.nix
@@ -4,7 +4,7 @@ buildGoModule rec {
   pname = "shiori";
   version = "1.5.0";
 
-  modSha256 = "142raxqh6mipw0dyhzgc8ha6vn74wdin25qrl1nkd68mpcvsbblg";
+  modSha256 = "1z6q5lv0j433p8lc3nxlw1rds5x1kvs1vzl63jf3disxw7ppyai3";
 
   src = fetchFromGitHub {
     owner = "go-shiori";