cloudaxe-opencode/packages/opencode/test/server
Kit Langton da5e29b320 fix(server): read auth Config from Flag for HttpApi/Hono parity
HttpApi auth middleware was reading ServerAuth.Config via Effect's generated
defaultLayer, which resolves Config.string('OPENCODE_SERVER_PASSWORD') once
and is memoized by Layer identity. Subsequent runtime mutation of process.env
(or Flag.OPENCODE_SERVER_PASSWORD) was never observed, so the middleware kept
serving 401 even when auth was disabled at runtime.

Hono's AuthMiddleware reads Flag.OPENCODE_SERVER_PASSWORD per request, so it
picks up mutations immediately. With Hono still the production default and
HttpApi gated by OPENCODE_EXPERIMENTAL_HTTPAPI, the gap was masked by tests
that flipped the flag back to Hono for no-auth scenarios.

Override ServerAuth.Config.defaultLayer to read Flag.* via Layer.sync at
layer-build time. Each fresh listener (memoMap) picks up current Flag values.
This matches Hono behavior across listeners; per-request mutation within a
single listener is not preserved (would require reading Flag in the middleware
itself, which is a separate concern).

Tests:
- httpapi-listen: parameterize 'tickets optional when auth disabled' across
  both backends to lock in parity.
- httpapi-raw-route-auth + httpapi-ui: switch from ConfigProvider injection
  (which is now a no-op since defaultLayer is Flag-backed, not Config-backed)
  to ServerAuth.Config.layer({...}) for explicit overrides, or Flag mutation
  for tests that exercise the production read path.

46/46 auth + PTY tests pass.
2026-05-04 00:13:02 -04:00
..
AGENTS.md test: cover HttpApi instance context middleware (#25032) 2026-04-29 21:24:45 -04:00
auth.test.ts fix(auth): respect server username in clients (#25596) 2026-05-03 19:28:31 +05:30
global-bus.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
global-session-list.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-authorization.test.ts fix(server): support desktop PTY websockets with HttpApi (#25598) 2026-05-03 18:23:29 +00:00
httpapi-bridge.test.ts feat(server): Server.openapi() backed by HttpApi spec, parity-checked against Hono output (#25545) 2026-05-03 09:06:23 -04:00
httpapi-config.test.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
httpapi-cors.test.ts chore: generate 2026-05-01 01:28:37 +00:00
httpapi-event.test.ts Refactor v2 session events as schemas (#24512) 2026-05-02 22:09:48 -04:00
httpapi-experimental.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-file.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-instance-context.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-instance.legacy.test.ts test(httpapi): add route exerciser 2026-05-02 20:31:21 -04:00
httpapi-instance.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-json-parity.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-listen.test.ts fix(server): read auth Config from Flag for HttpApi/Hono parity 2026-05-04 00:13:02 -04:00
httpapi-mcp-oauth.test.ts fix(server): support desktop PTY websockets with HttpApi (#25598) 2026-05-03 18:23:29 +00:00
httpapi-mcp.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-parity.test.ts fix(httpapi): pagination Link header echoes request host (#25527) 2026-05-02 23:19:33 -04:00
httpapi-provider.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-pty-websocket.test.ts test: port instance HttpApi path/vcs read coverage to Effect 2026-04-30 11:07:00 -04:00
httpapi-pty.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
httpapi-raw-route-auth.test.ts fix(server): read auth Config from Flag for HttpApi/Hono parity 2026-05-04 00:13:02 -04:00
httpapi-sdk.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-session.test.ts chore: generate 2026-05-03 02:10:52 +00:00
httpapi-sync.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
httpapi-tui.test.ts feat(server): Server.openapi() backed by HttpApi spec, parity-checked against Hono output (#25545) 2026-05-03 09:06:23 -04:00
httpapi-ui.test.ts fix(server): read auth Config from Flag for HttpApi/Hono parity 2026-05-04 00:13:02 -04:00
httpapi-workspace-routing.test.ts refactor: rename workspace adapters (#25272) 2026-05-01 07:36:52 -04:00
httpapi-workspace.test.ts Replace Instance.disposeAll/load with fixture helper (#25418) 2026-05-02 10:56:15 -04:00
project-init-git.test.ts Delete Instance.dispose and Instance.reload (#25427) 2026-05-02 11:44:16 -04:00
proxy-util.test.ts Refactor HttpApi workspace routing and proxy boundaries (#25006) 2026-04-29 16:50:54 -04:00
session-actions.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-list.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-messages.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
session-select.test.ts Normalize instance lifecycle wiring (#25501) 2026-05-02 20:39:20 -04:00
trace-attributes.test.ts refactor(server): align route-span attrs with OTel semantic conventions (#23198) 2026-04-18 00:29:26 +00:00
workspace-proxy.test.ts chore: generate 2026-04-30 23:37:58 +00:00
workspace-routing.test.ts refactor(server): extract Hono-coupled utilities to backend-neutral modules (#25542) 2026-05-03 12:58:34 +00:00