Repository navigation
test(oauth): check OAuth scopes against a live server - #1188
Merged
Merged
Conversation
EhabY
force-pushed
the
test/vsc-24-oauth-scope-suite
branch
4 times, most recently
from
November 12, 2026 15:07
f4df09b to
c02b81e
Compare
Signs a member in and refreshes the token through the extension's OAuth code against a server that enforces scopes, then probes every Coder API request and stream the extension makes, plus the requests `coder ssh` and `coder start` send. A unit test scans src/ with the TypeScript checker and fails when a CoderApi method the extension calls has no probe. The live suite has its own Vitest config, so `pnpm test` leaves it out. It runs on PRs against the pinned v2.38.0 release and nightly against coder-preview:latest.
EhabY
force-pushed
the
test/vsc-24-oauth-scope-suite
branch
from
November 13, 2026 15:20
c02b81e to
ddef224
Compare
jeremyruppel
left a comment
There was a problem hiding this comment.
Thanks for this, the scan in oauthScopeProbes.test.ts is a nice way to keep the probes complete. There's one bug that makes three stream probes always pass, plus two small things inline.
Drafted with Coder Agents.
jeremyruppel
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of VSC-24. Follows #1138, which changed the scopes the extension requests. This PR checks them against a live server.
Why
Released servers ignore requested scopes, so unit tests can't show that the extension requests enough. A missing scope shows up only against a server that enforces scopes, and sometimes only as an empty list, a closed socket, or a CLI warning.
What catches what
pnpm test, every PR, about 1.5 seconds:test/unit/oauthScopeProbes.test.tsuses the TypeScript checker to find everyCoderApirequest or stream method thatsrc/references, including through destructuring andPick<CoderApi, ...>. It fails when a method has no probe and no listed reason inunprobedMethods, or when either list is stale.pnpm test:scopes, on PRs that touch the code the probes run, about 50 seconds:coder sshmakes for an owned and a shared workspace, and runs the one-build update andcoder startthrough the extension'supdateWorkspaceandstartWorkspace.coder-preview:latest: catches server changes before a release, and reports failures in a "Nightly OAuth scope test failed" issue.PRs use v2.38.0, pinned by digest: the first release that enforces requested scopes.
Where the lines go
+1089/-4. Almost all of it is new test code;
src/changes only by exportingrawDataToString. Start withprobes.ts: it lists what the suite checks, and everything undersupport/exists to run it.test/scopes/probes.tstest/scopes/oauthScopes.test.tstest/scopes/support/deployment.tstest/scopes/support/oauthLogin.tstest/scopes/support/workspaces.ts,template.tftest/scopes/support/workspaceActions.tscoder sshrequests, the one-build update, andcoder startwith the CLI the server servestest/scopes/support/streams.tstest/scopes/support/server.tstest/unit/oauthScopeProbes.test.tsprobes.tscomplete.github/workflows/oauth-scopes.yamltest/scopes/compose.yaml,test/scopes/vitest.config.mtspackage.json,pnpm-workspace.yamldocs/TESTING.mdsection,test:scopesscriptNot covered
coder starton a shared workspace fails server-side: Shared workspaces: scoped tokens can't runcoder start, anduse-role users can't report usage coder#30423.startWorkspaceandstopWorkspace, used only by the tasks panel, which needs the tasks API that servers enforcing scopes no longer serve.🤖 Generated with Claude Code