inspector/clients/cli/__tests__
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cliffhall 0ded02b34c fix(auth): revoke with the registration bound to the grant, not the current one (#2144)
Copilot review round 17.

`resolveClientInformation` mirrored `BaseOAuthClientProvider`, preferring the
preregistered entry. That order answers "who should I authenticate as now";
revocation asks "who minted this token", and the two diverge — the store lets a
preregistered client and an issuer-bound dynamic registration coexist, so after
a server is switched from DCR to a configured `oauth.clientId` an older DCR
grant was revoked with the configured client's credentials. RFC 7009 §2.2
answers 200 for a token the server does not recognise as the caller's, so that
reported `revoked` while the grant stayed live and the local record was already
gone — the worst available outcome.

The registration bound to the grant's issuer now wins, with the preregistered
entry as the fallback, which covers both directions: a token minted with the
configured client leaves the issuer slot empty, since the SDK writes it only
after DCR.

Stated in the comment rather than implied: this is best available evidence, not
proof. The store records client information per issuer, not per token, so
binding identity at save time remains the real fix and is a storage-shape
change beyond this PR.

Also fixed a CLI test comment still describing 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 07:01:20 -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): revoke with the registration bound to the grant, not the current one (#2144) 2026-08-28 07:01:20 -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.