Skip to content

Dashboard: tests/dashboard ​

The Admin API and the browser dashboard (ui) are checked as a black box: Python — the HTTP contracts, .mjs — a real browser through the Chrome DevTools Protocol.

Python ​

  • test_admin.py — API contracts against a live process: it writes a configuration (the config() function — a SOCKS inbound on loopback, outbounds, groups), starts OURS_BINARY run -c <file> --dashboard 127.0.0.1:<port> and checks: authorization, Host, Origin, the CSP of static files; limits and smuggling of raw HTTP; route simulation on the active rules; editing an object without changing the rest of the YAML and the active configuration; preview, apply, rollback; a revision conflict; a selector and closing a connection; saving and an external reload; the event history; UDP observation; group probes with real HTTP checks; the API version and 404 on a path without a version; responses matching the schema docs/usage/admin-api.json; that a long probe does not delay other requests.
  • test_demo.py — the demo data are checked against the real routing engine (the explain CLI), for example.yaml and diagram.yaml.
sh
python3 tests/run.py -- python3 tests/dashboard/test_admin.py
python3 tests/run.py -- python3 tests/dashboard/test_demo.py

OURS_BINARY defaults to debug/ours in $CARGO_TARGET_DIR, or without it — in the repository root's target/.

Demo: demo.py ​

Read-only: no proxy listeners, TPROXY or packet injection. Connections and counters are synthetic, rule traces come from the real explain against pinned rule-set snapshots (tests/dashboard/rule-sets/: *.json sources, compiled *.srs and their hashes in snapshots.json). It serves static files from app/ui/assets and the read resources of /api/v1/ (status, config, connections, groups, events, subscriptions); modifying requests, except /api/v1/route, get 403.

sh
python3 tests/dashboard/demo.py [--binary …] [--config tests/dashboard/example.yaml] [--port 9091]

It prints DEMO …: http://127.0.0.1:<port>/#token=<token>.

Browser (.mjs) ​

test_browser.py runs three scenarios: browser, diagram-edit and draft-offline. It starts headless Chromium with a temporary profile and a fresh ours process for each scenario. It requires Node with built-in WebSocket support, Chromium and a built dashboard-enabled ours binary.

The scenarios read and change the page through the names in page.mjs (state, tab(), selectObject(), setSource()…): they are installed before the page loads, over the modules the dashboard exposes as window.ours, and every write is applied to the DOM at once. page.mjs sets the dashboard language to Russian (dashboard-lang) unless one is stored, because the scenarios check Russian texts.

sh
python3 tests/run.py -- python3 tests/dashboard/test_browser.py

Set CHROMIUM_BINARY if Chromium is outside PATH. OURS_BINARY and CARGO_TARGET_DIR work as above. The other scenarios are run by hand:

  1. Start headless Chromium with --remote-debugging-port=18773 (the CDP address can be changed with CDP_URL, by default http://127.0.0.1:18773/json).
  2. Start the object under test and write the URL with the token it prints into the file DASHBOARD_URL_FILE (by default /tmp/dashboard-live-url). The scripts do not print the URL and the token.
  3. node tests/dashboard/<scenario>.mjs. Screenshots go to ARTIFACT_DIR (by default /tmp/dashboard-browser-evidence).
ScenarioAgainst whatWhat it checks
demo-browser.mjsdemo.py with example.yamlthe demo label, the DNS rules, a layout without overlaps, changes are forbidden
direction-drag.mjsdemo.py with example.yamlthe direction of the graph, all edges, dragging the background
diagram.mjsdemo.py --config tests/dashboard/diagram.yamlrules in their order, DNS hijack, fakeip, finals
browser.mjsa live run -c <test_admin config> --dashboardthe editor, a draft, preview → apply, connections and their trace, mobile width
basic-auth.mjsa live run with admin.users (ADMIN_USER/ADMIN_PASSWORD, by default admin/secret)Basic authentication instead of a token
graph-theme.mjsa live run … --dashboardthe block grid, group placement, a selector choice, panning
diagram-edit.mjsa live run … --dashboardediting rules and DNS servers as a draft, apply, rollback
connections.mjsa live run … --dashboard with a long destination or outbound tagthe connections table at 1280 and 390 px and with ~4350 connections
draft-offline.mjsa live run … --dashboardthe "no connection" state and leaving a changed draft
texts.mjsa live run … --dashboard, the rule domain_suffix: blocked.test → to: block, two connections through SOCKS: an open one and one to blocked.test:443server texts in Russian, durations and event links
first-open.mjsa live run … --dashboard without admin.usersthe login form, accepted hosts and ports
phone.mjsa live run … --dashboard (applies a group member with a long tag)no sideways scrolling at 390 px
graph-zoom.mjsa live run … --dashboard (a large config only as a draft)fitting and zooming a large graph
graph-groups.mjsa live run … --dashboard (applies groups of eight members: manual, delay with pick: 3 and pick: 7, probes — to the scenario's local HTTP server)collapsed and expanded groups, the saved zoom and position
config-errors.mjsa live run … --dashboardan error with a position leads to its line in the editor
  • The dashboard asks for confirmation when leaving a page with a changed draft. A scenario that leaves the draft changed after keyboard or mouse input through CDP will delay the navigation of the next one; scenarios end with a draft equal to the active configuration.
  • The graph view (zoom, position, expanded groups) is saved in the page origin's localStorage when leaving it. Live scenarios have their own port per process, the demo — a shared 9091: a scenario that needs the default fit calls fitGraph() or clears localStorage (Storage.clearDataForOrigin).
  • graph-checks.mjs is not a scenario but graph geometry helpers injected into the page.
  • For live scenarios — a fresh process for each: they change the configuration (apply, rollback), and the next one must start from the original.
  • browser.mjs requires at least one live connection: before running it, send traffic through the configuration's SOCKS inbound (for example, curl --socks5 127.0.0.1:<port> …), otherwise the connections tab has nothing to show.

GPL-3.0-or-later