File tree Expand file tree Collapse file tree
hub/server/integrations/github/create-installation-access-token Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,6 +223,34 @@ describe("createInstallationAccessToken()", () => {
223223 await expect ( mintToken ( ) ) . rejects . toMatchObject ( { code : "permission_denied" } )
224224 } )
225225
226+ it ( "rejects a token that includes any additional permission" , async ( ) => {
227+ const mintToken = createInstallationAccessToken ( {
228+ appId : "123" ,
229+ installationId : "456" ,
230+ organization : "github" ,
231+ signer : { sign : vi . fn ( ) . mockResolvedValue ( "app-jwt" ) } ,
232+ fetch : vi
233+ . fn < typeof fetch > ( )
234+ . mockResolvedValueOnce ( successfulInstallationResponse ( ) )
235+ . mockResolvedValueOnce (
236+ new Response (
237+ JSON . stringify ( {
238+ expires_at : "2026-11-12T19:00:00.000Z" ,
239+ permissions : {
240+ contents : "write" ,
241+ organization_copilot_requests : "read" ,
242+ } ,
243+ token : "overprivileged-token" ,
244+ } ) ,
245+ { status : 201 , headers : { "content-type" : "application/json" } } ,
246+ ) ,
247+ ) ,
248+ now : ( ) => now ,
249+ } )
250+
251+ await expect ( mintToken ( ) ) . rejects . toMatchObject ( { code : "permission_denied" } )
252+ } )
253+
226254 it . each ( [ "installation" , "token" ] as const ) (
227255 "classifies an unreadable %s response as transient unavailability" ,
228256 async ( responseType ) => {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const responseSchema = z
1010 . object ( {
1111 organization_copilot_requests : z . literal ( "read" ) ,
1212 } )
13- . loose ( ) ,
13+ . strict ( ) ,
1414 token : z . string ( ) . min ( 1 ) . max ( 2_000 ) ,
1515 } )
1616 . loose ( )
You can’t perform that action at this time.
0 commit comments