🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Status page detail honors global view
Omega (QA)91cf863545b7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3171b20..b70b899 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,8 @@- _Files: `backend/oidc_handler.py`, `tests/test_oidc_pkce.py`_- **Dependency updates: Authlib 1.9.5 and Apprise 2.2.0 (#291, #256):** Authlib moves from 1.9.2 to 1.9.5, three upstream security releases: 1.9.3 refuses form_post responses to non-http(s) redirect URIs in the implicit and hybrid grants, 1.9.4 fixes ID-JAG user resolution for multi-tenant providers, and 1.9.5 completes the fix for CVE-2026-114615 by refusing public keys and certificates as HMAC secrets. Warracker uses Authlib as an OIDC client rather than an authorization server, so these are taken as auth-stack hygiene alongside the new PKCE support. Apprise moves from 1.13.1 to 2.2.0, a major release carrying the upstream security fix GHSA-cfp4-m43r-v9q4 and a dozen new notification services. Behavior changes in Apprise 2 that touch notifications: `notify()` returns a detailed result object instead of True/False/None, deliveries to multiple targets run in parallel by default, and retries are tracked per target. Warracker reads the result the same way it always has, sent only when every target was delivered to, and the handler now coerces the result to a plain bool, so test, custom, and expiration notifications behave identically for callers. The deprecated Apprise options removed in 2.0 were not in use.- _Files: `backend/requirements.txt`, `backend/apprise_handler.py`, `tests/test_apprise_notify_result.py`_+- **Status page detail now honors global view:** with global view on, a plain user could see another user's warranty row on the status page but expanding it failed, because the detail endpoint restricted non-admins to their own warranties and ignored the global view setting, so no detail panel or Edit button appeared. The endpoint now follows the same rule as the warranty list: with global view enabled and not restricted to admins, any authenticated user may view any warranty. With global view off, or restricted to admins, non-owners are still turned away as before. Editing another user's warranty remains owner and admin only.+ - _Files: `backend/warranties_routes.py`, `tests/test_debug_warranty_global_view.py`_## 1.0.6 - 2026-11-10diff --git a/backend/warranties_routes.py b/backend/warranties_routes.pyindex cfa76ea..352b6ef 100644--- a/backend/warranties_routes.py+++ b/backend/warranties_routes.py@@ -2293,8 +2293,21 @@ def get_warranty_debug(warranty_id):conn = get_db_connection()with conn.cursor() as cur:+ # Admins may view any warranty. Non-admins may too when global+ # view is enabled and not restricted to admins, matching the+ # list and claims endpoints and the shared-instance design:+ # with global view on, any user sees all users' information.+ # Otherwise a non-admin is restricted to their own warranties.+ can_view_all = is_admin+ if not is_admin:+ cur.execute("SELECT key, value FROM site_settings WHERE key IN ('global_view_enabled', 'global_view_admin_only')")+ settings = {row[0]: row[1] for row in cur.fetchall()}+ global_view_enabled = settings.get('global_view_enabled', 'true').lower() == 'true'+ admin_only = settings.get('global_view_admin_only', 'false').lower() == 'true'+ can_view_all = global_view_enabled and not admin_only+# Check if warranty exists and user has access to it- if is_admin:+ if can_view_all:cur.execute('''SELECT w.id, w.product_name, w.purchase_date, w.expiration_date, w.invoice_path, w.manual_path, w.other_document_path,w.product_url, w.notes, w.purchase_price, w.user_id, w.created_at, w.updated_at, w.is_lifetime,diff --git a/tests/test_debug_warranty_global_view.py b/tests/test_debug_warranty_global_view.pynew file mode 100644index 0000000..6e8a390--- /dev/null+++ b/tests/test_debug_warranty_global_view.py@@ -0,0 +1,106 @@+"""Global view handling on GET /api/debug/warranty/<id> (status page detail).++With global view on, a plain user expanding another user's row on the+status page must get the detail payload, matching the list endpoint.+With global view off, or restricted to admins, non-owners stay 404.+Owners and admins are unaffected by the global view settings.+"""+from types import SimpleNamespace++import pytest+++def _global_view(db_connection):+ """Set the two global view settings, restoring prior values after."""+ conn = db_connection+ with conn.cursor() as cur:+ cur.execute(+ "SELECT key, value FROM site_settings "+ "WHERE key IN ('global_view_enabled', 'global_view_admin_only')"+ )+ saved = dict(cur.fetchall())++ def _set(enabled, admin_only):+ with conn.cursor() as cur:+ for key, value in (+ ("global_view_enabled", enabled),+ ("global_view_admin_only", admin_only),+ ):+ cur.execute(+ "INSERT INTO site_settings (key, value) VALUES (%s, %s) "+ "ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value",+ (key, value),+ )+ conn.commit()++ yield _set++ with conn.cursor() as cur:+ for key in ("global_view_enabled", "global_view_admin_only"):+ if key in saved:+ cur.execute(+ "UPDATE site_settings SET value = %s WHERE key = %s",+ (saved[key], key),+ )+ else:+ cur.execute("DELETE FROM site_settings WHERE key = %s", (key,))+ conn.commit()++[email protected](scope="module")+def scenario(client, admin_user, user_factory, warranty_factory):+ owner = user_factory()+ other = user_factory()+ r = warranty_factory(owner["headers"], product_name="DebugViewWidget")+ assert r.status_code == 201, r.get_data(as_text=True)+ return SimpleNamespace(+ admin=admin_user["headers"],+ owner=owner["headers"],+ other=other["headers"],+ wid=r.get_json()["id"],+ )+++def test_non_owner_global_view_on(client, scenario, _global_view):+ _global_view("true", "false")+ r = client.get(f"/api/debug/warranty/{scenario.wid}", headers=scenario.other)+ assert r.status_code == 200, r.get_data(as_text=True)+ body = r.get_json()+ assert body["product_name"] == "DebugViewWidget"+ assert "serial_numbers" in body and "tags" in body+++def test_non_owner_global_view_off(client, scenario, _global_view):+ _global_view("false", "false")+ r = client.get(f"/api/debug/warranty/{scenario.wid}", headers=scenario.other)+ assert r.status_code == 404+++def test_non_owner_global_view_admin_only(client, scenario, _global_view):+ _global_view("true", "true")+ r = client.get(f"/api/debug/warranty/{scenario.wid}", headers=scenario.other)+ assert r.status_code == 404+++def test_owner_with_global_view_off(client, scenario, _global_view):+ _global_view("false", "false")+ r = client.get(f"/api/debug/warranty/{scenario.wid}", headers=scenario.owner)+ assert r.status_code == 200+++def test_admin_with_global_view_off(client, scenario, _global_view):+ _global_view("false", "false")+ r = client.get(f"/api/debug/warranty/{scenario.wid}", headers=scenario.admin)+ assert r.status_code == 200+++def test_unauthenticated(client, scenario):+ r = client.get(f"/api/debug/warranty/{scenario.wid}")+ assert r.status_code == 401+++def test_missing_warranty_global_view_on(client, scenario, _global_view):+ _global_view("true", "false")+ r = client.get("/api/debug/warranty/999999", headers=scenario.other)+ assert r.status_code == 404