1import ../make-test-python.nix (
2 { ... }:
3 {
4 name = "tt-rss-nixos";
5
6 nodes.machine =
7 { pkgs, ... }:
8 {
9 services.tt-rss = {
10 enable = true;
11 virtualHost = "localhost";
12 selfUrlPath = "http://localhost/";
13 pluginPackages = with pkgs; [
14 tt-rss-plugin-auth-ldap
15 tt-rss-plugin-feediron
16 ];
17 plugins = [
18 "auth_internal"
19 "feediron"
20 "note"
21 ];
22 singleUserMode = true;
23 themePackages = with pkgs; [ tt-rss-theme-feedly ];
24 };
25 };
26
27 testScript = ''
28 import json
29 import re
30 machine.wait_for_unit("tt-rss.service")
31
32 matches = re.search('__csrf_token = "([^"]*)"', machine.succeed("curl -sSfL --cookie cjar --cookie-jar cjar -sSfL http://localhost/"))
33 if matches is None:
34 assert False, "CSRF token not found"
35 csrf_token = matches.group(1)
36
37 # Ensure themes are loaded. No API found for these, so it's a crude check.
38 preference_page = machine.succeed("curl -sSfL --cookie cjar --cookie-jar cjar http://localhost/backend.php?op=Pref_Prefs")
39 assert "feedly" in preference_page
40
41 plugins = json.loads(machine.succeed(f"curl -sSfL --cookie cjar --cookie-jar cjar 'http://localhost/backend.php' -X POST --data-raw 'op=Pref_Prefs&method=getPluginsList&csrf_token={csrf_token}'"))["plugins"]
42 expected_plugins = ["auth_internal", "auth_ldap", "feediron", "note"];
43 found_plugins = [p["name"] for p in plugins if p["name"] in expected_plugins]
44 assert len(found_plugins) == len(expected_plugins), f"Expected plugins {expected_plugins}, found {found_plugins}"
45 '';
46 }
47)