Skip to content

Self-hosted monitoring for homelabs: host and container metrics and uptime checks from all your machines in one dashboard, with an optional AI agent that diagnoses incidents and suggests fixes.

fix(admin): remove placeholder settings that did nothing

karloks200519e449303cd3
diff --git a/.claude/skills/code-simplicity/code-simplicity.md b/.claude/skills/code-simplicity/code-simplicity.md
index 3e525a5..b08487b 100644
--- a/.claude/skills/code-simplicity/code-simplicity.md
+++ b/.claude/skills/code-simplicity/code-simplicity.md
@@ -13,6 +13,7 @@ Cilj je najmanji kod koji ispravno rješava zadatak i lako se čita i mijenja. K
2. **Bez nezatraženih parametara i opcija.** Ne dodaji konfiguraciju, zastavice ni parametre za scenarije koje nitko nije spomenuo.
3. **Obrada grešaka samo za stvarne ulaze.** Validiraj podatke koji dolaze izvana (korisnik, datoteka, mreža, API). Ne brani se od stanja koja se u kontekstu zadatka ne mogu dogoditi.
4. **Bez dodataka koji nisu tražени.** Ne dodaji logiranje, testove, dokumentaciju ni README izmjene osim ako su tražene. Komentar samo tamo gdje nešto nije očito iz koda.
+ Kad se testovi pišu (jer su traženi ili ih projekt zahtijeva), spremaju se u odgovarajuću mapu unutar `tests/` prema području koje štite (`accounts`, `collectors`, `monitoring`, `history`, `assistant`, `security`; popis je u `TESTS.md`, odjeljak "Where the tests live"), nikad izravno u `tests/`. Ako nijedna mapa ne odgovara, napravi novu i dodaj je u taj popis. Nazivi datoteka moraju biti jedinstveni kroz sve mape.
5. **Ne mijenjaj ono što nije dio zadatka.** Ako vidiš prostor za poboljšanje u susjednom kodu, spomeni ga u odgovoru, ali ga ne diraj.
6. **Složenija struktura zahtijeva objašnjenje.** Ako misliš da je potreban veći dizajn, prvo kratko objasni zašto i pitaj, pa tek onda piši.
diff --git a/.claude/skills/minimal-diff/minimal-diff.md b/.claude/skills/minimal-diff/minimal-diff.md
index a54b3b2..90dfcce 100644
--- a/.claude/skills/minimal-diff/minimal-diff.md
+++ b/.claude/skills/minimal-diff/minimal-diff.md
@@ -14,6 +14,7 @@ Mijenjaj samo ono što je potrebno za zadatak.
3. **Ne dodaji promjene koje nisu tražene**, uključujući popravke tuđih grešaka koje nisu u opsegu zadatka. Spomeni ih u odgovoru.
4. **Drži diff malim.** Ako izmjena zahtijeva više od očekivanog, zaustavi se i objasni zašto prije nastavka.
5. **Ne mijenjaj javna sučelja** (potpise funkcija, API odgovore, nazive polja) bez izričitog dopuštenja.
+6. **Test koji pratiš uz izmjenu ide u postojeću datoteku u odgovarajućoj mapi `tests/`** (vidi `TESTS.md`, "Where the tests live"). Novu datoteku napravi samo ako nijedna ne odgovara, u mapi područja, nikad izravno u `tests/`.
## Provjera prije predaje
diff --git a/TESTS.md b/TESTS.md
index ec77ec4..c3daf03 100644
--- a/TESTS.md
+++ b/TESTS.md
@@ -16,6 +16,7 @@ whether a failure matters before you upgrade or change your setup.
- [How the tests work](#how-the-tests-work)
- [What the tests do not cover](#what-the-tests-do-not-cover)
- [Words used below](#words-used-below)
+- [Where the tests live](#where-the-tests-live)
- [What each test file protects](#what-each-test-file-protects)
- [Every test, explained](#every-test-explained)
- [Adding a test](#adding-a-test)
@@ -48,9 +49,10 @@ Useful variations:
|---|---|
| `pytest -x` | Stop at the first failure. |
| `pytest -v` | List every test case with its result. |
-| `pytest tests/test_rules.py` | Run one file. |
+| `pytest tests/monitoring/test_rules.py` | Run one file. |
+| `pytest tests/history` | Run one folder (see [Where the tests live](#where-the-tests-live)). |
| `pytest -k "oom"` | Run only tests whose name contains `oom`. |
-| `pytest tests/test_rules.py::test_single_spike_does_not_alert` | Run one test. |
+| `pytest tests/monitoring/test_rules.py::test_single_spike_does_not_alert` | Run one test. |
| `pytest --lf` | Re-run only the tests that failed last time. |
| `pytest --collect-only -q` | List all tests without running them. |
@@ -120,6 +122,24 @@ docker compose logs --tail 20 collector # "Sent host metrics and N contai
| **Docker proxy** | The read-only middleman that is the only thing touching the Docker socket. |
| **Strict / open mode** | `COLLECTOR_ACCESS=strict` (server stack) or `open` (development stack). |
+## Where the tests live
+
+Tests are grouped by the part of the product they protect, not by which source file they call: several
+features (container checks, network checks, the system helper) are tested from the collector's
+side and the backend's side in one file, because the feature only works when both do.
+
+| Folder | What is in it |
+|---|---|
+| `tests/accounts/` | Sign-in, two-factor, sessions, passwords, roles and the admin settings. |
+| `tests/collectors/` | Adding and trusting collectors (enrollment, approval, pending servers, the dashboard's own machine), what they report and how it is validated, the filesystems they report, and the read-only Docker proxy. |
+| `tests/monitoring/` | What is watched and how it turns into incidents: the alert engine and its rules, system, container and network checks, the system helper and the container details. |
+| `tests/history/` | Long-term history: rollups, the history API, statistics and the database indexes behind them. |
+| `tests/assistant/` | The AI assistant: its fixed health checks, error messages and conversations. |
+| `tests/security/` | Tests written from security reviews that cut across areas: request size limits and the second review's findings. |
+
+`tests/conftest.py` (settings every test shares) and `tests/fakes.py` (the fake Redis) stay at the top.
+The chart helper tests for the frontend are separate, in `src/frontend/tests/`.
+
## What each test file protects
| File | Cases | Protects |
@@ -995,8 +1015,9 @@ they were checked by hand in a real browser.
## Adding a test
-1. Put it in the file for the area it belongs to, or a new `tests/test_<area>.py`
- (files must start with `test_`, functions with `test_`).
+1. Put it in the file for the area it belongs to, inside the matching folder of [Where the tests live](#where-the-tests-live),
+ or in a new `tests/<folder>/test_<area>.py` (files must start with `test_`, functions with `test_`). Never put a test
+ directly in `tests/`; if no folder fits, create one and add it to that table. File names must be unique across folders.
2. Follow the existing style: build a fresh in-memory database, call the code
directly, assert on the result. Look at a similar test and copy its setup.
3. For anything that handles outside input, add the awkward cases too (empty,
diff --git a/docs/development.md b/docs/development.md
index ba1e572..f17c114 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -93,5 +93,5 @@ src/
frontend/ React + Tailwind dashboard (Vite); charts.jsx and chartMath.js are the
charts (distributions.jsx: columns, donut, bars, heatmap), StatisticsPage.jsx,
FleetStatistics.jsx, ServerInsights.jsx and ContainerStatistics.jsx the page
-tests/ pytest suite
+tests/ pytest suite, in folders by area (accounts, collectors, monitoring, history, assistant, security); see TESTS.md
```
diff --git a/src/frontend/src/App.jsx b/src/frontend/src/App.jsx
index 2005346..fb798b1 100644
--- a/src/frontend/src/App.jsx
+++ b/src/frontend/src/App.jsx
@@ -1634,12 +1634,6 @@ const placeholderAdmin = {
{ name: 'PostgreSQL', status: 'ok', detail: '412 MB' },
{ name: 'Redis', status: 'ok', detail: '3 active sessions' },
],
- storage: [
- ['Host metrics', '1,204,332 rows'],
- ['Container metrics', '8,930,118 rows'],
- ['Incidents', '214 rows'],
- ['Audit log', '3,871 rows'],
- ],
audit: [
{ id: 1, time: '2026-09-25T01:58:00', actor: 'Admin', event: 'Signed in' },
{ id: 2, time: '2026-09-25T01:31:00', actor: 'system', event: 'New server requested to join: raspberrypi' },
@@ -1755,10 +1749,6 @@ function AdminUsersTab() {
<div className="space-y-5">
<TwoFactorPolicySetting />
- <AdminSection title="Registration" description="Controls whether new people can create an account.">
- <Toggle label="Allow registration" description="When off, only the first account can be created. Replaces ALLOW_REGISTRATION in .env." />
- </AdminSection>
-
<AdminSection title="Users" description="Change roles, disable accounts or sign someone out everywhere.">
<ul className="space-y-2 md:hidden">
{placeholderAdmin.users.map((account) => (
@@ -2109,16 +2099,7 @@ function IncidentThresholdsSection() {
function AdminAlertsTab() {
return (
- <div className="grid gap-5 xl:grid-cols-2">
- <AdminSection title="Webhook" description="Receives a JSON POST for every critical incident. Replaces ADMIN_ALERT_WEBHOOK_URL in .env." action={<SaveButton />}>
- <div className="space-y-3">
- <input type="url" placeholder="https://your-alert-endpoint.example/hook" aria-label="Webhook URL" className={inputClass} />
- <button type="button" className={secondaryButtonClass}>Send test alert</button>
- </div>
- </AdminSection>
-
- <IncidentThresholdsSection />
- </div>
+ <IncidentThresholdsSection />
)
}
@@ -2178,7 +2159,7 @@ function DataRetentionSection() {
function AdminSystemTab() {
return (
<div className="space-y-5">
- <div className="grid gap-5 xl:grid-cols-3">
+ <div className="grid gap-5 xl:grid-cols-2">
<AdminSection title="Services">
<div className="space-y-2">
{placeholderAdmin.services.map((service) => (
@@ -2191,14 +2172,6 @@ function AdminSystemTab() {
</AdminSection>
<DataRetentionSection />
-
- <AdminSection title="Database">
- <div className="space-y-2">
- {placeholderAdmin.storage.map(([label, value]) => (
- <div key={label} className="flex items-center justify-between text-sm"><span className="text-[#9aa0a6]">{label}</span><span className="text-white">{value}</span></div>
- ))}
- </div>
- </AdminSection>
</div>
<AdminSection title="Audit log" description="Who did what, and when.">
diff --git a/tests/test_account_security.py b/tests/accounts/test_account_security.py
similarity index 99%
rename from tests/test_account_security.py
rename to tests/accounts/test_account_security.py
index ec5b52c..79a9f8b 100644
--- a/tests/test_account_security.py
+++ b/tests/accounts/test_account_security.py
@@ -787,7 +787,7 @@ def test_a_reset_admin_is_asked_to_enrol_again_when_it_is_required(app):
def test_the_reset_script_asks_for_exactly_one_email():
- script = os.path.join(os.path.dirname(__file__), "..", "src", "backend", "reset_2fa.py")
+ script = os.path.join(os.path.dirname(__file__), "..", "..", "src", "backend", "reset_2fa.py")
source = open(script).read()
assert "reset_two_factor" in source and "len(argv) != 2" in source
diff --git a/tests/test_admin.py b/tests/accounts/test_admin.py
similarity index 100%
rename from tests/test_admin.py
rename to tests/accounts/test_admin.py
diff --git a/tests/test_auth_backend.py b/tests/accounts/test_auth_backend.py
similarity index 100%
rename from tests/test_auth_backend.py
rename to tests/accounts/test_auth_backend.py
diff --git a/tests/test_agent_errors.py b/tests/assistant/test_agent_errors.py
similarity index 100%
rename from tests/test_agent_errors.py
rename to tests/assistant/test_agent_errors.py
diff --git a/tests/test_agent_service.py b/tests/assistant/test_agent_service.py
similarity index 100%
rename from tests/test_agent_service.py
rename to tests/assistant/test_agent_service.py
diff --git a/tests/test_conversations.py b/tests/assistant/test_conversations.py
similarity index 100%
rename from tests/test_conversations.py
rename to tests/assistant/test_conversations.py
diff --git a/tests/test_health_checks.py b/tests/assistant/test_health_checks.py
similarity index 100%
rename from tests/test_health_checks.py
rename to tests/assistant/test_health_checks.py
diff --git a/tests/test_collector_mounts.py b/tests/collectors/test_collector_mounts.py
similarity index 100%
rename from tests/test_collector_mounts.py
rename to tests/collectors/test_collector_mounts.py
diff --git a/tests/test_dashboard_host.py b/tests/collectors/test_dashboard_host.py
similarity index 100%
rename from tests/test_dashboard_host.py
rename to tests/collectors/test_dashboard_host.py
diff --git a/tests/test_docker_proxy.py b/tests/collectors/test_docker_proxy.py
similarity index 100%
rename from tests/test_docker_proxy.py
rename to tests/collectors/test_docker_proxy.py
diff --git a/tests/test_enrollment.py b/tests/collectors/test_enrollment.py
similarity index 100%
rename from tests/test_enrollment.py
rename to tests/collectors/test_enrollment.py
diff --git a/tests/test_enrollment_limits.py b/tests/collectors/test_enrollment_limits.py
similarity index 100%
rename from tests/test_enrollment_limits.py
rename to tests/collectors/test_enrollment_limits.py
diff --git a/tests/test_ingest_validation.py b/tests/collectors/test_ingest_validation.py
similarity index 100%
rename from tests/test_ingest_validation.py
rename to tests/collectors/test_ingest_validation.py
diff --git a/tests/test_pending_collectors.py b/tests/collectors/test_pending_collectors.py
similarity index 100%
rename from tests/test_pending_collectors.py
rename to tests/collectors/test_pending_collectors.py
diff --git a/tests/test_history.py b/tests/history/test_history.py
similarity index 100%
rename from tests/test_history.py
rename to tests/history/test_history.py
diff --git a/tests/test_indexes.py b/tests/history/test_indexes.py
similarity index 100%
rename from tests/test_indexes.py
rename to tests/history/test_indexes.py
diff --git a/tests/test_rollups.py b/tests/history/test_rollups.py
similarity index 100%
rename from tests/test_rollups.py
rename to tests/history/test_rollups.py
diff --git a/tests/test_stats.py b/tests/history/test_stats.py
similarity index 100%
rename from tests/test_stats.py
rename to tests/history/test_stats.py
diff --git a/tests/test_alerts.py b/tests/monitoring/test_alerts.py
similarity index 100%
rename from tests/test_alerts.py
rename to tests/monitoring/test_alerts.py
diff --git a/tests/test_container_checks.py b/tests/monitoring/test_container_checks.py
similarity index 100%
rename from tests/test_container_checks.py
rename to tests/monitoring/test_container_checks.py
diff --git a/tests/test_container_detail.py b/tests/monitoring/test_container_detail.py
similarity index 100%
rename from tests/test_container_detail.py
rename to tests/monitoring/test_container_detail.py
diff --git a/tests/test_network_checks.py b/tests/monitoring/test_network_checks.py
similarity index 100%
rename from tests/test_network_checks.py
rename to tests/monitoring/test_network_checks.py
diff --git a/tests/test_rules.py b/tests/monitoring/test_rules.py
similarity index 100%
rename from tests/test_rules.py
rename to tests/monitoring/test_rules.py
diff --git a/tests/test_system_checks.py b/tests/monitoring/test_system_checks.py
similarity index 100%
rename from tests/test_system_checks.py
rename to tests/monitoring/test_system_checks.py
diff --git a/tests/test_system_helper.py b/tests/monitoring/test_system_helper.py
similarity index 100%
rename from tests/test_system_helper.py
rename to tests/monitoring/test_system_helper.py
diff --git a/tests/test_input_limits.py b/tests/security/test_input_limits.py
similarity index 100%
rename from tests/test_input_limits.py
rename to tests/security/test_input_limits.py
diff --git a/tests/test_second_review.py b/tests/security/test_second_review.py
similarity index 100%
rename from tests/test_second_review.py
rename to tests/security/test_second_review.py