From e09c54ce6b30f851c66890bcb3d29aa7014af82e Mon Sep 17 00:00:00 2001 From: gileri Date: Sun, 22 Dec 2024 15:46:58 +0100 Subject: [PATCH] tt-rss: More comprehensive test --- nixos/tests/web-apps/tt-rss.nix | 21 ++++++++++++++++++- .../tt/tt-rss-plugin-auth-ldap/package.nix | 5 +++++ .../tt/tt-rss-theme-feedly/package.nix | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/nixos/tests/web-apps/tt-rss.nix b/nixos/tests/web-apps/tt-rss.nix index 7bd4413d7286..af9753bd138e 100644 --- a/nixos/tests/web-apps/tt-rss.nix +++ b/nixos/tests/web-apps/tt-rss.nix @@ -10,13 +10,32 @@ import ../make-test-python.nix ( enable = true; virtualHost = "localhost"; selfUrlPath = "http://localhost/"; + pluginPackages = with pkgs; [ + tt-rss-plugin-auth-ldap + ]; singleUserMode = true; + themePackages = with pkgs; [ tt-rss-theme-feedly ]; }; }; testScript = '' + import json + import re machine.wait_for_unit("tt-rss.service") - machine.succeed("curl -sSfL http://localhost/ | grep 'Tiny Tiny RSS'") + + matches = re.search('__csrf_token = "([^"]*)"', machine.succeed("curl -sSfL --cookie cjar --cookie-jar cjar -sSfL http://localhost/")) + if matches is None: + assert False, "CSRF token not found" + csrf_token = matches.group(1) + + # Ensure themes are loaded. No API found for these, so it's a crude check. + preference_page = machine.succeed("curl -sSfL --cookie cjar --cookie-jar cjar http://localhost/backend.php?op=Pref_Prefs") + assert "feedly" in preference_page + + 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"] + expected_plugins = ["auth_ldap"]; + found_plugins = [p["name"] for p in plugins if p["name"] in expected_plugins] + assert len(found_plugins) == len(expected_plugins), f"Expected plugins {expected_plugins}, found {found_plugins}" ''; } ) diff --git a/pkgs/by-name/tt/tt-rss-plugin-auth-ldap/package.nix b/pkgs/by-name/tt/tt-rss-plugin-auth-ldap/package.nix index c3d7f206e5b3..713fd3978416 100644 --- a/pkgs/by-name/tt/tt-rss-plugin-auth-ldap/package.nix +++ b/pkgs/by-name/tt/tt-rss-plugin-auth-ldap/package.nix @@ -1,5 +1,6 @@ { lib, + nixosTests, stdenv, fetchFromGitHub, }: @@ -19,6 +20,10 @@ stdenv.mkDerivation { install -D plugins/auth_ldap/init.php $out/auth_ldap/init.php ''; + passthru = { + tests = { inherit (nixosTests) tt-rss; }; + }; + meta = with lib; { description = "Plugin for TT-RSS to authenticate users via ldap"; license = licenses.asl20; diff --git a/pkgs/by-name/tt/tt-rss-theme-feedly/package.nix b/pkgs/by-name/tt/tt-rss-theme-feedly/package.nix index 18e14aae380d..b211d25c17a5 100644 --- a/pkgs/by-name/tt/tt-rss-theme-feedly/package.nix +++ b/pkgs/by-name/tt/tt-rss-theme-feedly/package.nix @@ -1,5 +1,6 @@ { lib, + nixosTests, stdenv, fetchFromGitHub, }: @@ -23,6 +24,10 @@ stdenv.mkDerivation rec { cp -ra feedly *.css $out ''; + passthru = { + tests = { inherit (nixosTests) tt-rss; }; + }; + meta = with lib; { description = "Feedly theme for Tiny Tiny RSS"; license = licenses.mit;