@@ -46,11 +46,11 @@ describe("OAuth Authorization", () => {
4646    it ( "returns metadata when first fetch fails but second without MCP header succeeds" ,  async  ( )  =>  { 
4747      // Set up a counter to control behavior 
4848      let  callCount  =  0 ; 
49-        
49+ 
5050      // Mock implementation that changes behavior based on call count 
5151      mockFetch . mockImplementation ( ( _url ,  _options )  =>  { 
5252        callCount ++ ; 
53-          
53+ 
5454        if  ( callCount  ===  1 )  { 
5555          // First call with MCP header - fail with TypeError (simulating CORS error) 
5656          // We need to use TypeError specifically because that's what the implementation checks for 
@@ -68,22 +68,22 @@ describe("OAuth Authorization", () => {
6868      // Should succeed with the second call 
6969      const  metadata  =  await  discoverOAuthMetadata ( "https://auth.example.com" ) ; 
7070      expect ( metadata ) . toEqual ( validMetadata ) ; 
71-        
71+ 
7272      // Verify both calls were made 
7373      expect ( mockFetch ) . toHaveBeenCalledTimes ( 2 ) ; 
74-        
74+ 
7575      // Verify first call had MCP header 
7676      expect ( mockFetch . mock . calls [ 0 ] [ 1 ] ?. headers ) . toHaveProperty ( "MCP-Protocol-Version" ) ; 
7777    } ) ; 
7878
7979    it ( "throws an error when all fetch attempts fail" ,  async  ( )  =>  { 
8080      // Set up a counter to control behavior 
8181      let  callCount  =  0 ; 
82-        
82+ 
8383      // Mock implementation that changes behavior based on call count 
8484      mockFetch . mockImplementation ( ( _url ,  _options )  =>  { 
8585        callCount ++ ; 
86-          
86+ 
8787        if  ( callCount  ===  1 )  { 
8888          // First call - fail with TypeError 
8989          return  Promise . reject ( new  TypeError ( "First failure" ) ) ; 
@@ -96,7 +96,7 @@ describe("OAuth Authorization", () => {
9696      // Should fail with the second error 
9797      await  expect ( discoverOAuthMetadata ( "https://auth.example.com" ) ) 
9898        . rejects . toThrow ( "Second failure" ) ; 
99-          
99+ 
100100      // Verify both calls were made 
101101      expect ( mockFetch ) . toHaveBeenCalledTimes ( 2 ) ; 
102102    } ) ; 
@@ -250,6 +250,7 @@ describe("OAuth Authorization", () => {
250250        clientInformation : validClientInfo , 
251251        authorizationCode : "code123" , 
252252        codeVerifier : "verifier123" , 
253+         redirectUri : "http://localhost:3000/callback" , 
253254      } ) ; 
254255
255256      expect ( tokens ) . toEqual ( validTokens ) ; 
@@ -271,6 +272,7 @@ describe("OAuth Authorization", () => {
271272      expect ( body . get ( "code_verifier" ) ) . toBe ( "verifier123" ) ; 
272273      expect ( body . get ( "client_id" ) ) . toBe ( "client123" ) ; 
273274      expect ( body . get ( "client_secret" ) ) . toBe ( "secret123" ) ; 
275+       expect ( body . get ( "redirect_uri" ) ) . toBe ( "http://localhost:3000/callback" ) ; 
274276    } ) ; 
275277
276278    it ( "validates token response schema" ,  async  ( )  =>  { 
@@ -288,6 +290,7 @@ describe("OAuth Authorization", () => {
288290          clientInformation : validClientInfo , 
289291          authorizationCode : "code123" , 
290292          codeVerifier : "verifier123" , 
293+           redirectUri : "http://localhost:3000/callback" , 
291294        } ) 
292295      ) . rejects . toThrow ( ) ; 
293296    } ) ; 
@@ -303,6 +306,7 @@ describe("OAuth Authorization", () => {
303306          clientInformation : validClientInfo , 
304307          authorizationCode : "code123" , 
305308          codeVerifier : "verifier123" , 
309+           redirectUri : "http://localhost:3000/callback" , 
306310        } ) 
307311      ) . rejects . toThrow ( "Token exchange failed" ) ; 
308312    } ) ; 
0 commit comments