Files
led-controller/test/api
jimmyandClaude Haiku 5.5 f0615dc1b7 feat: users, roles and per-area permissions, production demo image
The controller checks every route against the signed-in user's role, with
levels none, view, control and edit per area. Guests get the permissions
of a built-in guest role. Auth stays off until the first user exists;
LED_ADMIN_USER and LED_ADMIN_PASSWORD create the first admin.

Sessions are cookies, passwords are PBKDF2-SHA256, and logins lock per
username after five failures. The simulator's WebSocket checks the view
permission at handshake and per frame; /ws needs devices control. The web
UI gets a sign-in button, a sign-in prompt on refused changes, and a users
and roles screen.

Also: the device build gets the bridge include path and forward type it
was missing, Dockerfile.sim runs non-root, and Dockerfile.prod with
docker-compose.prod.yml runs the controller on an internal network behind
Caddy for HTTPS.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-17 00:29:04 +13:00
..

API tests

HTTP tests against a running controller, ported from the Python app's endpoint tests (tests/test_endpoints_pytest.py and tests/test_endpoints.py) on both the animation-engine and main lines, plus main's bundle, audio, group and sequence tests where they work over HTTP. They need pytest, requests and websocket-client.

make test-api HOST=10.1.1.180

or python3 -m pytest test/api --host <ip> (or set LED_HOST). Without a host every test is skipped.

The tests create and delete profiles, presets, zones and so on. The sequence tests switch mic timing off and run the beat clock at 200 BPM for a few seconds; mic timing is switched back on afterwards. Before the run they save every collection (GET /db/<name>), and afterwards they write each one back (PUT /db/<name>). Zone play and preset send do go out over ESP-NOW. They use made-up driver names (pytest-a, pytest-nobody) so real drivers ignore them.

Marking a missing feature

helpers.missing("<feature>") marks a test for behaviour the firmware does not have yet. It is a strict xfail: the test shows as x, and fails as XPASS(strict) once the feature works, so the marker gets removed. No test carries it now. python3 -m pytest test/api --host <ip> -rx lists marked tests.

Not ported

  • the model, engine and helper unit tests (tests/models/, tests/engine_tests/, most of main's tests/test_*.py), which test Python modules that have no C counterpart;
  • the Wi-Fi/TCP/UDP driver test servers and the bridge tests (the controller has no bridge or Wi-Fi driver transport).

The checks on exact driver messages became checks on status codes and replies, because ESP-NOW frames can't be captured from outside the board.

The Selenium UI tests are in test/browser/ (make test-browser HOST=<ip>).