File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,18 @@ describe("OAuth Authorization", () => {
6060 // Verify second call was made without header 
6161 expect ( mockFetch ) . toHaveBeenCalledTimes ( 2 ) ; 
6262 const  secondCallOptions  =  mockFetch . mock . calls [ 1 ] [ 1 ] ; 
63-  expect ( secondCallOptions ) . toBeUndefined ( ) ;  // No options means no headers 
63+  // The second call still has options but doesn't include MCP-Protocol-Version header 
64+  expect ( secondCallOptions ) . toBeDefined ( ) ; 
65+  expect ( secondCallOptions ?. headers ) . toBeUndefined ( ) ; 
6466 } ) ; 
6567
66-  it ( "returns undefined  when all fetch attempts fail" ,  async  ( )  =>  { 
68+  it ( "throws an error  when all fetch attempts fail" ,  async  ( )  =>  { 
6769 // Both requests fail 
6870 mockFetch . mockRejectedValueOnce ( new  Error ( "Network error" ) ) ; 
6971 mockFetch . mockRejectedValueOnce ( new  Error ( "Network error" ) ) ; 
7072
71-  const   metadata   =   await  discoverOAuthMetadata ( "https://auth.example.com" ) ; 
72-  expect ( metadata ) . toBeUndefined ( ) ; 
73+  await  expect ( discoverOAuthMetadata ( "https://auth.example.com" ) ) 
74+    . rejects . toThrow ( "Network error" ) ; 
7375 expect ( mockFetch ) . toHaveBeenCalledTimes ( 2 ) ; 
7476 } ) ; 
7577
Original file line number Diff line number Diff line change @@ -75,13 +75,13 @@ export function clientRegistrationHandler({
7575 } 
7676
7777 const  clientMetadata  =  parseResult . data ; 
78-  const  isPublicClient  =  clientMetadata . token_endpoint_auth_method  ! =='none' 
78+  const  isPublicClient  =  clientMetadata . token_endpoint_auth_method  = =='none' 
7979
8080 // Generate client credentials 
8181 const  clientId  =  crypto . randomUUID ( ) ; 
8282 const  clientSecret  =  isPublicClient 
83-  ? crypto . randomBytes ( 32 ) . toString ( 'hex' ) 
84-  : undefined ; 
83+  ? undefined 
84+  : crypto . randomBytes ( 32 ) . toString ( 'hex' ) ; 
8585 const  clientIdIssuedAt  =  Math . floor ( Date . now ( )  /  1000 ) ; 
8686
8787 // Calculate client secret expiry time 
                         You can’t perform that action at this time. 
           
                  
0 commit comments