@@ -17,7 +17,7 @@ import {
1717} from "./oauth-client" ;
1818import { definePlugin } from "./plugin" ;
1919import { makeTestWorkspaceHarness , memoryCredentialsPlugin } from "./test-config" ;
20- import { serveOAuthTestServer } from "./testing/oauth-test-server" ;
20+ import { scopesFromAuthorizeUrl , serveOAuthTestServer } from "./testing/oauth-test-server" ;
2121
2222// First-party OAuth clients: host-operated apps declared in executor config
2323// (`firstPartyOAuthClients`), addressed as `first-party:<name>`. Resolved from
@@ -165,6 +165,40 @@ describe("first-party oauth clients", () => {
165165 } ,
166166 ) ;
167167
168+ it . effect ( "an authorization scope override supports scope-less provider app tokens" , ( ) =>
169+ Effect . scoped (
170+ Effect . gen ( function * ( ) {
171+ const server = yield * serveOAuthTestServer ( { scopes : [ "repo" ] } ) ;
172+ const { executor } = yield * makeTestWorkspaceHarness ( {
173+ plugins,
174+ firstPartyOAuthClients : [ { ...firstPartyClientFor ( server ) , authorizationScopes : [ ] } ] ,
175+ } ) ;
176+ yield * executor . acme . seed ( [ "repo" ] ) ;
177+
178+ const started = yield * executor . oauth . start ( {
179+ owner : "org" ,
180+ client : FIRST_PARTY ,
181+ clientOwner : "org" ,
182+ name : ConnectionName . make ( "github-app" ) ,
183+ integration : INTEG ,
184+ template : TEMPLATE ,
185+ } ) ;
186+ expect ( started . status ) . toBe ( "redirect" ) ;
187+ if ( started . status !== "redirect" ) return ;
188+ expect ( scopesFromAuthorizeUrl ( started . authorizationUrl ) ) . toEqual ( [ ] ) ;
189+
190+ const callback = yield * server . completeAuthorizationCodeFlow ( {
191+ authorizationUrl : started . authorizationUrl ,
192+ } ) ;
193+ const connection = yield * executor . oauth . complete ( {
194+ state : started . state ,
195+ code : callback . code ,
196+ } ) ;
197+ expect ( connection . oauthScope ) . toBeNull ( ) ;
198+ } ) ,
199+ ) ,
200+ ) ;
201+
168202 it . effect ( "refresh resolves the config-declared client (no oauth_client row exists)" , ( ) =>
169203 Effect . scoped (
170204 Effect . gen ( function * ( ) {
0 commit comments