inspector/clients/cli/__tests__
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cliffhall a4ee263365 fix(auth): refuse a grant whose authorization server cannot be established (#2144)
Copilot review round 15.

The issuer check still failed open for the legacy unkeyed grant. "Unkeyed"
means its authorization server is UNKNOWN, not that the cached endpoint is
proven to own it: server metadata is a single slot a later discovery
overwrites, while a pre-SEP-2352 token survives until the first issuer-stamped
save. So a clear could post an old bearer credential to an authorization server
that never minted it.

Such a grant is now cleared without being revoked, and reported as such with a
message saying re-authorizing makes future clears revocable. The cost is that
a pre-issuer-binding entry gets no revocation — which is exactly the behavior
it had before this feature existed, so nothing regresses — and it earns
revocation back on the next authorization. Not sending is the only answer that
cannot be wrong.

Every seed in the suite is now issuer-bound, which is what a real flow writes;
the two tests that were about the legacy grant now assert the refusal, since
that is the behavior worth pinning.

Also renamed the CLI test that still described the pre-round-13 ordering.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177mPHAdECD18nLLCTwR5rh
Signed-off-by: cliffhall <cliff@futurescale.com>
2026-08-28 06:18:58 -04:00
..
helpers fix(cli): apply a server's persisted mcp.json metadata 2026-08-24 19:32:23 -04:00
app-info.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00
clear-stored-auth-for-relogin.test.ts fix(auth): refuse a grant whose authorization server cannot be established (#2144) 2026-08-28 06:18:58 -04:00
cli-oauth-navigation.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
cli.test.ts test(proxy): isolate proxy env per file; word the guard failure by candidate source 2026-08-23 23:00:28 -04:00
cliOAuth.test.ts test(cli,tui): typecheck the __tests__ dirs (#1791) (#1799) 2026-07-27 12:05:35 -04:00
e2e.test.ts test(cli,tui): add in-process source coverage gates (#1484) (#1502) 2026-06-20 15:05:58 -04:00
emit-result.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
error-handler.test.ts fix: walk contentSchema, await the error envelope, correct the README claim 2026-08-25 03:26:39 -04:00
format-json.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00
format-output.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
headers.test.ts feat: port CLI, TUI, and launcher from v1.5 into v2 (#1452) 2026-06-14 20:27:49 -04:00
metadata.test.ts fix(cli): apply a server's persisted mcp.json metadata 2026-08-24 19:32:23 -04:00
method-types.test.ts feat: allow complex JSON values in request _meta 2026-08-23 12:23:40 -04:00
methods.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
oauth-interactive.test.ts test(cli,tui): typecheck the __tests__ dirs (#1791) (#1799) 2026-07-27 12:05:35 -04:00
oauth-runner.test.ts Guided-auth removal, OAuth smoke testing, and TUI/CLI support (#1531) 2026-06-29 15:35:51 -04:00
open-url.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
programmatic-ergonomics.test.ts feat: allow complex JSON values in request _meta 2026-08-23 12:23:40 -04:00
README.md CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
relogin-revocation.test.ts fix(auth): refuse a grant whose authorization server cannot be established (#2144) 2026-08-28 06:18:58 -04:00
run-method-mocks.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
run-method.test.ts fix: invoke the registered SIGINT listener directly in run-method.test instead of emitting a process-wide signal 2026-08-12 08:57:35 -07:00
schema-lint-report.test.ts fix: scan only subschema positions, await stderr, show the whole report 2026-08-25 03:10:37 -04:00
servers-list.test.ts fix: redact secrets nested inside metadata in servers/show 2026-08-23 14:03:40 -04:00
stored-auth.test.ts fix(oauth): walk the candidates in the CLI refresh path too 2026-08-26 00:34:27 -04:00
style.test.ts CLI: catalog listing, auth flags, and OAuth browser UX (#1782) 2026-07-26 16:55:25 -04:00
tools.test.ts cli: Wave 3 — programmatic review path (rollup of #1573–#1575) (#1655) 2026-07-11 22:14:23 -04:00

CLI Tests

Tests live under __tests__/ and run via Vitest.

  • Most tests import runCli() in-process (see helpers/cli-runner.ts) so clients/cli/src is measured under the coverage gate. Suite-wide helpers/mock-open-url.ts (vitest setupFiles) mocks open-url so an armed interactive OAuth path cannot launch a real browser.
  • e2e.test.ts (and root scripts/smoke-cli.mjs) spawn the built binary for shebang / process.exit paths — pretest builds test-servers + the CLI bundle first.

Scripts (from clients/cli/)

npm test                  # pretest build + all tests
npm run test:cli          # subset: cli.test.ts
npm run test:cli-tools    # subset: tools.test.ts
npm run test:cli-headers  # subset: headers.test.ts
npm run test:cli-metadata # subset: metadata.test.ts
npm run test:coverage     # build + ≥90 per-file coverage gate
npm run validate          # format:check && lint && typecheck && test

Test files

File Focus
cli.test.ts Core connect / method / config matrix
tools.test.ts tools/call argument coercion
headers.test.ts --header merging
metadata.test.ts --metadata / --tool-metadata
methods.test.ts Method allow-list / rejection
app-info.test.ts --app-info probe paths
format-json.test.ts --format json envelopes
format-output.test.ts Text/json writers
emit-result.test.ts Result emission helpers
method-types.test.ts ONE_SHOT_METHODS / guards
run-method.test.ts Handler dispatch against a real test server
run-method-mocks.test.ts Handler edge cases with mocks
servers-list.test.ts servers/list / servers/show + redaction
cliOAuth.test.ts Connect / mid-RPC OAuth recovery
cli-oauth-navigation.test.ts OSC 8, arm/disarm, MCP_AUTO_OPEN_ENABLED
open-url.test.ts open package wrapper
oauth-runner.test.ts Runner client-config / CIMD flags
oauth-interactive.test.ts Loopback callback OAuth (in-process)
stored-auth.test.ts --use-stored-auth / handoff / wait
clear-stored-auth-for-relogin.test.ts Dual-key --relogin clear
programmatic-ergonomics.test.ts Flag conflicts, timeouts, ergonomics
error-handler.test.ts Exit codes / error shaping
style.test.ts ANSI / OSC 8 helpers
e2e.test.ts Out-of-process binary smoke
helpers/assertions.test.ts Assertion helpers

Helpers

Helper Role
helpers/cli-runner.ts In-process runCli with stdout/stderr capture
helpers/mock-open-url.ts Suite-wide open-url mock (vitest setupFiles)
helpers/assertions.ts expectCliSuccess / expectCliFailure / output matchers
helpers/fixtures.ts Temp config / client.json factories

OAuth interactive tests stub or drive the loopback callback in-process rather than requiring a real browser.