1 import ./make-test-python.nix ({ ... }: {
5 services.tiddlywiki.enable = true;
8 boot.postBootCommands = ''
9 echo "username,password
10 somelogin,somesecret" > /var/lib/wikiusers.csv
12 services.tiddlywiki = {
16 credentials="../wikiusers.csv";
17 readers="(authenticated)";
27 with subtest("by default works without configuration"):
28 default.wait_for_unit("tiddlywiki.service")
30 with subtest("by default available on port 8080 without auth"):
31 default.wait_for_unit("tiddlywiki.service")
32 default.wait_for_open_port(8080)
33 # we output to /dev/null here to avoid a python UTF-8 decode error
34 # but the check will still fail if the service doesn't respond
35 default.succeed("curl --fail -o /dev/null 127.0.0.1:8080")
37 with subtest("by default creates empty wiki"):
38 default.succeed("test -f /var/lib/tiddlywiki/tiddlywiki.info")
40 with subtest("configured on port 3000 with basic auth"):
41 configured.wait_for_unit("tiddlywiki.service")
42 configured.wait_for_open_port(3000)
43 configured.fail("curl --fail -o /dev/null 127.0.0.1:3000")
45 "curl --fail -o /dev/null 127.0.0.1:3000 --user somelogin:somesecret"
48 with subtest("restart preserves changes"):
50 default.wait_for_unit("tiddlywiki.service")
53 'curl --fail --request PUT --header \'X-Requested-With:TiddlyWiki\' \
54 --data \'{ "title": "title", "text": "content" }\' \
55 --url 127.0.0.1:8080/recipes/default/tiddlers/somepage '
57 default.succeed("sleep 2")
60 default.systemctl("restart tiddlywiki.service")
61 default.wait_for_unit("tiddlywiki.service")
62 default.wait_for_open_port(8080)
64 # the change is preserved
66 "curl --fail -o /dev/null 127.0.0.1:8080/recipes/default/tiddlers/somepage"