@@ -354,18 +354,6 @@ describe("OAuth Authorization", () => {
354354 expect ( authorizationUrl . searchParams . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
355355 } ) ;
356356
357- it ( "excludes resource parameter when not provided" , async ( ) => {
358- const { authorizationUrl } = await startAuthorization (
359- "https://auth.example.com" ,
360- {
361- clientInformation : validClientInfo ,
362- redirectUrl : "http://localhost:3000/callback" ,
363- }
364- ) ;
365-
366- expect ( authorizationUrl . searchParams . has ( "resource" ) ) . toBe ( false ) ;
367- } ) ;
368-
369357 it ( "includes scope parameter when provided" , async ( ) => {
370358 const { authorizationUrl } = await startAuthorization (
371359 "https://auth.example.com" ,
@@ -535,24 +523,6 @@ describe("OAuth Authorization", () => {
535523 expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
536524 } ) ;
537525
538- it ( "excludes resource parameter from token exchange when not provided" , async ( ) => {
539- mockFetch . mockResolvedValueOnce ( {
540- ok : true ,
541- status : 200 ,
542- json : async ( ) => validTokens ,
543- } ) ;
544-
545- await exchangeAuthorization ( "https://auth.example.com" , {
546- clientInformation : validClientInfo ,
547- authorizationCode : "code123" ,
548- codeVerifier : "verifier123" ,
549- redirectUri : "http://localhost:3000/callback" ,
550- } ) ;
551-
552- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
553- expect ( body . has ( "resource" ) ) . toBe ( false ) ;
554- } ) ;
555-
556526 it ( "validates token response schema" , async ( ) => {
557527 mockFetch . mockResolvedValueOnce ( {
558528 ok : true ,
@@ -659,22 +629,6 @@ describe("OAuth Authorization", () => {
659629 expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
660630 } ) ;
661631
662- it ( "excludes resource parameter from refresh token request when not provided" , async ( ) => {
663- mockFetch . mockResolvedValueOnce ( {
664- ok : true ,
665- status : 200 ,
666- json : async ( ) => validTokensWithNewRefreshToken ,
667- } ) ;
668-
669- await refreshAuthorization ( "https://auth.example.com" , {
670- clientInformation : validClientInfo ,
671- refreshToken : "refresh123" ,
672- } ) ;
673-
674- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
675- expect ( body . has ( "resource" ) ) . toBe ( false ) ;
676- } ) ;
677-
678632 it ( "exchanges refresh token for new tokens and keep existing refresh token if none is returned" , async ( ) => {
679633 mockFetch . mockResolvedValueOnce ( {
680634 ok : true ,
@@ -1136,47 +1090,5 @@ describe("OAuth Authorization", () => {
11361090 // Verify that the two resources are different (critical for security)
11371091 expect ( authUrl1 . searchParams . get ( "resource" ) ) . not . toBe ( authUrl2 . searchParams . get ( "resource" ) ) ;
11381092 } ) ;
1139-
1140- it ( "preserves query parameters in resource URI" , async ( ) => {
1141- // Mock successful metadata discovery
1142- mockFetch . mockImplementation ( ( url ) => {
1143- const urlString = url . toString ( ) ;
1144- if ( urlString . includes ( "/.well-known/oauth-authorization-server" ) ) {
1145- return Promise . resolve ( {
1146- ok : true ,
1147- status : 200 ,
1148- json : async ( ) => ( {
1149- issuer : "https://auth.example.com" ,
1150- authorization_endpoint : "https://auth.example.com/authorize" ,
1151- token_endpoint : "https://auth.example.com/token" ,
1152- response_types_supported : [ "code" ] ,
1153- code_challenge_methods_supported : [ "S256" ] ,
1154- } ) ,
1155- } ) ;
1156- }
1157- return Promise . resolve ( { ok : false , status : 404 } ) ;
1158- } ) ;
1159-
1160- // Mock provider methods
1161- ( mockProvider . clientInformation as jest . Mock ) . mockResolvedValue ( {
1162- client_id : "test-client" ,
1163- client_secret : "test-secret" ,
1164- } ) ;
1165- ( mockProvider . tokens as jest . Mock ) . mockResolvedValue ( undefined ) ;
1166- ( mockProvider . saveCodeVerifier as jest . Mock ) . mockResolvedValue ( undefined ) ;
1167- ( mockProvider . redirectToAuthorization as jest . Mock ) . mockResolvedValue ( undefined ) ;
1168-
1169- // Call auth with resource containing query parameters
1170- const result = await auth ( mockProvider , {
1171- serverUrl : "https://api.example.com/mcp-server?param=value&another=test" ,
1172- } ) ;
1173-
1174- expect ( result ) . toBe ( "REDIRECT" ) ;
1175-
1176- // Verify query parameters are preserved (only fragment is removed)
1177- const redirectCall = ( mockProvider . redirectToAuthorization as jest . Mock ) . mock . calls [ 0 ] ;
1178- const authUrl : URL = redirectCall [ 0 ] ;
1179- expect ( authUrl . searchParams . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server?param=value&another=test" ) ;
1180- } ) ;
11811093 } ) ;
11821094} ) ;
0 commit comments