English
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 (theconfig()function — a SOCKS inbound on loopback, outbounds, groups), startsOURS_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 and404on a path without a version; responses matching the schemadocs/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 (theexplainCLI), forexample.yamlanddiagram.yaml.
sh
python3 tests/run.py -- python3 tests/dashboard/test_admin.py
python3 tests/run.py -- python3 tests/dashboard/test_demo.pyOURS_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.pySet CHROMIUM_BINARY if Chromium is outside PATH. OURS_BINARY and CARGO_TARGET_DIR work as above. The other scenarios are run by hand:
- Start headless Chromium with
--remote-debugging-port=18773(the CDP address can be changed withCDP_URL, by defaulthttp://127.0.0.1:18773/json). - 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. node tests/dashboard/<scenario>.mjs. Screenshots go toARTIFACT_DIR(by default/tmp/dashboard-browser-evidence).
| Scenario | Against what | What it checks |
|---|---|---|
demo-browser.mjs | demo.py with example.yaml | the demo label, the DNS rules, a layout without overlaps, changes are forbidden |
direction-drag.mjs | demo.py with example.yaml | the direction of the graph, all edges, dragging the background |
diagram.mjs | demo.py --config tests/dashboard/diagram.yaml | rules in their order, DNS hijack, fakeip, finals |
browser.mjs | a live run -c <test_admin config> --dashboard | the editor, a draft, preview → apply, connections and their trace, mobile width |
basic-auth.mjs | a live run with admin.users (ADMIN_USER/ADMIN_PASSWORD, by default admin/secret) | Basic authentication instead of a token |
graph-theme.mjs | a live run … --dashboard | the block grid, group placement, a selector choice, panning |
diagram-edit.mjs | a live run … --dashboard | editing rules and DNS servers as a draft, apply, rollback |
connections.mjs | a live run … --dashboard with a long destination or outbound tag | the connections table at 1280 and 390 px and with ~4350 connections |
draft-offline.mjs | a live run … --dashboard | the "no connection" state and leaving a changed draft |
texts.mjs | a live run … --dashboard, the rule domain_suffix: blocked.test → to: block, two connections through SOCKS: an open one and one to blocked.test:443 | server texts in Russian, durations and event links |
first-open.mjs | a live run … --dashboard without admin.users | the login form, accepted hosts and ports |
phone.mjs | a live run … --dashboard (applies a group member with a long tag) | no sideways scrolling at 390 px |
graph-zoom.mjs | a live run … --dashboard (a large config only as a draft) | fitting and zooming a large graph |
graph-groups.mjs | a 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.mjs | a live run … --dashboard | an 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
localStoragewhen leaving it. Live scenarios have their own port per process, the demo — a shared9091: a scenario that needs the default fit callsfitGraph()or clearslocalStorage(Storage.clearDataForOrigin). graph-checks.mjsis 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.mjsrequires 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.