test(display): integration test for the take-control WS-proxy + signed-token path (core#2261) #2269

Merged
hongming merged 1 commits from feat/core2261-takecontrol-wsproxy-test into main 2026-06-05 00:47:14 +00:00
Owner

Adds a server-side integration test for the desktop take-control WS-proxy path in workspace-server's DisplaySession handler. It covers the WS-1006 regression surface from core#2247 — the display websocket proxy upgrade + signed-token handshake + bidirectional byte flow — entirely without EC2/desktop/noVNC.

What it exercises

  • Positive: a valid signDisplaySessionToken(...) + active control lock + display-enabled workspace → the WS upgrade succeeds (HTTP 101), the fake websockify backend's RFB 003.008 greeting arrives through the reverse proxy, and a client→server byte echoes back (proves the bidirectional proxy chain end-to-end).
  • Negative (table-driven): missing token → 403; tampered/garbage token → 403; expired lock → 403; display.mode=none → 404; empty instance_id → 503; proxyPath != /websockify → 404. Each asserts the upgrade does not happen and that the rejection never leaks to the upstream backend.

How it's wired (no network/EC2)

  • The injectable displayForward package var is overridden to return a fake httptest websockify backend URL (gorilla/websocket upgrader that writes the RFB greeting then echoes), restored via t.Cleanup.
  • The two DB reads (loadWorkspaceDisplaySessionTarget, loadActiveDisplayControl) are mocked with sqlmock, mirroring the sibling workspace_display_control_test.go harness; DISPLAY_SESSION_SIGNING_SECRET is set via t.Setenv.
  • DisplaySession is mounted on a gin router behind httptest.NewServer, dialed by a real websocket.Dialer with Sec-WebSocket-Protocol: binary, molecule-display-token.<token>.

Complements the canvas reconnect unit tests (DisplayTab.test.tsx); the real auto-heal is the core#2261 reconciler. Deterministic, fast, short timeouts, all servers/conns closed via t.Cleanup.

Refs core#2261, core#2247.

DO NOT MERGE — heavy core SOP gate.

🤖 Generated with Claude Code

Adds a server-side integration test for the desktop **take-control WS-proxy path** in workspace-server's `DisplaySession` handler. It covers the **WS-1006 regression surface** from core#2247 — the display websocket proxy upgrade + signed-token handshake + bidirectional byte flow — entirely **without EC2/desktop/noVNC**. ## What it exercises - **Positive**: a valid `signDisplaySessionToken(...)` + active control lock + display-enabled workspace → the WS upgrade **succeeds (HTTP 101)**, the fake websockify backend's `RFB 003.008` greeting arrives **through the reverse proxy**, and a client→server byte **echoes back** (proves the bidirectional proxy chain end-to-end). - **Negative (table-driven)**: missing token → 403; tampered/garbage token → 403; expired lock → 403; `display.mode=none` → 404; empty `instance_id` → 503; `proxyPath != /websockify` → 404. Each asserts the upgrade does **not** happen and that the rejection never leaks to the upstream backend. ## How it's wired (no network/EC2) - The injectable `displayForward` package var is overridden to return a fake `httptest` websockify backend URL (gorilla/websocket upgrader that writes the RFB greeting then echoes), restored via `t.Cleanup`. - The two DB reads (`loadWorkspaceDisplaySessionTarget`, `loadActiveDisplayControl`) are mocked with sqlmock, mirroring the sibling `workspace_display_control_test.go` harness; `DISPLAY_SESSION_SIGNING_SECRET` is set via `t.Setenv`. - `DisplaySession` is mounted on a gin router behind `httptest.NewServer`, dialed by a real `websocket.Dialer` with `Sec-WebSocket-Protocol: binary, molecule-display-token.<token>`. Complements the canvas reconnect unit tests (`DisplayTab.test.tsx`); the real auto-heal is the core#2261 reconciler. Deterministic, fast, short timeouts, all servers/conns closed via `t.Cleanup`. Refs core#2261, core#2247. DO NOT MERGE — heavy core SOP gate. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
hongming added 1 commit 2026-06-05 00:40:52 +00:00
test(display): integration test for the take-control WS-proxy + signed-token path (core#2261)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Successful in 3s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 4s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 1s
Harness Replays / detect-changes (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 4s
E2E API Smoke Test / detect-changes (pull_request) Successful in 8s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 8s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
security-review / approved (pull_request_target) Failing after 5s
qa-review / approved (pull_request_target) Failing after 5s
gate-check-v3 / gate-check (pull_request_target) Successful in 6s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 9s
CI / Detect changes (pull_request) Successful in 14s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 13s
Harness Replays / Harness Replays (pull_request) Successful in 1s
E2E Chat / detect-changes (pull_request) Successful in 14s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 2s
CI / Canvas (Next.js) (pull_request) Successful in 4s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 3s
CI / Canvas Deploy Status (pull_request) Has been skipped
E2E Chat / E2E Chat (pull_request) Successful in 4s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m1s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 57s
sop-tier-check / tier-check (pull_request_target) Has been cancelled
sop-checklist / review-refire (pull_request_target) Has been skipped
qa-review / approved (pull_request_review) Has been skipped
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1m12s
security-review / approved (pull_request_review) Has been skipped
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 4s
sop-tier-check / tier-check (pull_request_review) Successful in 5s
CI / Platform (Go) (pull_request) Successful in 4m1s
CI / all-required (pull_request) Successful in 8s
audit-force-merge / audit (pull_request_target) Successful in 7s
d7484f7df4
Server-side integration test for the workspace-server DisplaySession
WS-proxy + signed-token handshake, covering the WS-1006 regression
surface (proxy upgrade + token validation + bidirectional bytes) from
core#2247 — without any EC2/desktop/noVNC.

Positive: valid signed token + active lock + enabled display upgrades
(HTTP 101), the fake websockify backend's RFB greeting arrives through
the proxy, and a client->server byte echoes back end-to-end.

Negative (table-driven): missing token (403), tampered token (403),
expired lock (403), display mode none (404), empty instance_id (503),
wrong proxyPath (404) — each asserts no upgrade and no leak to upstream.

displayForward is overridden to a fake httptest websockify backend and
DB reads are sqlmock-ed, mirroring the sibling display-control test
harness. Complements the canvas reconnect unit tests (DisplayTab).

Refs core#2261, core#2247.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hongming added the tier:low label 2026-06-05 00:42:16 +00:00
core-qa approved these changes 2026-06-05 00:42:18 +00:00
core-qa left a comment
Member

QA (core#2261 take-control WS-proxy test). Ran it myself: positive asserts 101 upgrade + RFB greeting through proxy + bidirectional echo; 6 rejections (missing/tampered/expired token, mode=none, empty instance_id, wrong path) each assert no-upgrade + never-reaches-upstream. Deterministic. Good fixture correction (mode=desktop-control/protocol=novnc). Approve.

QA (core#2261 take-control WS-proxy test). Ran it myself: positive asserts 101 upgrade + RFB greeting through proxy + bidirectional echo; 6 rejections (missing/tampered/expired token, mode=none, empty instance_id, wrong path) each assert no-upgrade + never-reaches-upstream. Deterministic. Good fixture correction (mode=desktop-control/protocol=novnc). Approve.
core-security approved these changes 2026-06-05 00:42:19 +00:00
core-security left a comment
Member

Security (core#2261). Test-only; no prod surface. Notably it locks in the token-auth guard: tampered/expired/missing signed tokens are proven to 403 and never reach the upstream proxy. Approve.

Security (core#2261). Test-only; no prod surface. Notably it locks in the token-auth guard: tampered/expired/missing signed tokens are proven to 403 and never reach the upstream proxy. Approve.
hongming merged commit d34d09db01 into main 2026-06-05 00:47:14 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2269