@@ -324,6 +324,7 @@ describe("OAuth Authorization", () => {
324324 metadata : undefined ,
325325 clientInformation : validClientInfo ,
326326 redirectUrl : "http://localhost:3000/callback" ,
327+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
327328 }
328329 ) ;
329330
@@ -338,20 +339,8 @@ describe("OAuth Authorization", () => {
338339 expect ( authorizationUrl . searchParams . get ( "redirect_uri" ) ) . toBe (
339340 "http://localhost:3000/callback"
340341 ) ;
341- expect ( codeVerifier ) . toBe ( "test_verifier" ) ;
342- } ) ;
343-
344- it ( "includes resource parameter when provided" , async ( ) => {
345- const { authorizationUrl } = await startAuthorization (
346- "https://auth.example.com" ,
347- {
348- clientInformation : validClientInfo ,
349- redirectUrl : "http://localhost:3000/callback" ,
350- resource : new URL ( "https://api.example.com/mcp-server" ) ,
351- }
352- ) ;
353-
354342 expect ( authorizationUrl . searchParams . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
343+ expect ( codeVerifier ) . toBe ( "test_verifier" ) ;
355344 } ) ;
356345
357346 it ( "includes scope parameter when provided" , async ( ) => {
@@ -478,6 +467,7 @@ describe("OAuth Authorization", () => {
478467 authorizationCode : "code123" ,
479468 codeVerifier : "verifier123" ,
480469 redirectUri : "http://localhost:3000/callback" ,
470+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
481471 } ) ;
482472
483473 expect ( tokens ) . toEqual ( validTokens ) ;
@@ -500,26 +490,6 @@ describe("OAuth Authorization", () => {
500490 expect ( body . get ( "client_id" ) ) . toBe ( "client123" ) ;
501491 expect ( body . get ( "client_secret" ) ) . toBe ( "secret123" ) ;
502492 expect ( body . get ( "redirect_uri" ) ) . toBe ( "http://localhost:3000/callback" ) ;
503- } ) ;
504-
505- it ( "includes resource parameter in token exchange when provided" , async ( ) => {
506- mockFetch . mockResolvedValueOnce ( {
507- ok : true ,
508- status : 200 ,
509- json : async ( ) => validTokens ,
510- } ) ;
511-
512- const tokens = await exchangeAuthorization ( "https://auth.example.com" , {
513- clientInformation : validClientInfo ,
514- authorizationCode : "code123" ,
515- codeVerifier : "verifier123" ,
516- redirectUri : "http://localhost:3000/callback" ,
517- resource : new URL ( "https://api.example.com/mcp-server" ) ,
518- } ) ;
519-
520- expect ( tokens ) . toEqual ( validTokens ) ;
521-
522- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
523493 expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
524494 } ) ;
525495
@@ -588,6 +558,7 @@ describe("OAuth Authorization", () => {
588558 const tokens = await refreshAuthorization ( "https://auth.example.com" , {
589559 clientInformation : validClientInfo ,
590560 refreshToken : "refresh123" ,
561+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
591562 } ) ;
592563
593564 expect ( tokens ) . toEqual ( validTokensWithNewRefreshToken ) ;
@@ -608,24 +579,6 @@ describe("OAuth Authorization", () => {
608579 expect ( body . get ( "refresh_token" ) ) . toBe ( "refresh123" ) ;
609580 expect ( body . get ( "client_id" ) ) . toBe ( "client123" ) ;
610581 expect ( body . get ( "client_secret" ) ) . toBe ( "secret123" ) ;
611- } ) ;
612-
613- it ( "includes resource parameter in refresh token request when provided" , async ( ) => {
614- mockFetch . mockResolvedValueOnce ( {
615- ok : true ,
616- status : 200 ,
617- json : async ( ) => validTokensWithNewRefreshToken ,
618- } ) ;
619-
620- const tokens = await refreshAuthorization ( "https://auth.example.com" , {
621- clientInformation : validClientInfo ,
622- refreshToken : "refresh123" ,
623- resource : new URL ( "https://api.example.com/mcp-server" ) ,
624- } ) ;
625-
626- expect ( tokens ) . toEqual ( validTokensWithNewRefreshToken ) ;
627-
628- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
629582 expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
630583 } ) ;
631584
0 commit comments