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