@@ -41,6 +41,7 @@ jest.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({
4141 startAuthorization : jest . fn ( ) ,
4242 exchangeAuthorization : jest . fn ( ) ,
4343 discoverOAuthProtectedResourceMetadata : jest . fn ( ) ,
44+ selectResourceURL : jest . fn ( ) ,
4445} ) ) ;
4546
4647// Import the functions to get their types
@@ -88,7 +89,7 @@ describe("AuthDebugger", () => {
8889 const defaultAuthState = EMPTY_DEBUGGER_STATE ;
8990
9091 const defaultProps = {
91- serverUrl : "https://example.com" ,
92+ serverUrl : "https://example.com/mcp " ,
9293 onBack : jest . fn ( ) ,
9394 authState : defaultAuthState ,
9495 updateAuthState : jest . fn ( ) ,
@@ -203,7 +204,7 @@ describe("AuthDebugger", () => {
203204
204205 // Should first discover and save OAuth metadata
205206 expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
206- new URL ( "https://example.com" ) ,
207+ new URL ( "https://example.com/ " ) ,
207208 ) ;
208209
209210 // Check that updateAuthState was called with the right info message
@@ -320,6 +321,7 @@ describe("AuthDebugger", () => {
320321 isInitiatingAuth : false ,
321322 resourceMetadata : null ,
322323 resourceMetadataError : null ,
324+ resource : null ,
323325 oauthTokens : null ,
324326 oauthStep : "metadata_discovery" ,
325327 latestError : null ,
@@ -361,7 +363,7 @@ describe("AuthDebugger", () => {
361363 } ) ;
362364
363365 expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
364- new URL ( "https://example.com" ) ,
366+ new URL ( "https://example.com/ " ) ,
365367 ) ;
366368 } ) ;
367369
@@ -496,11 +498,11 @@ describe("AuthDebugger", () => {
496498 it ( "should successfully fetch and display protected resource metadata" , async ( ) => {
497499 const updateAuthState = jest . fn ( ) ;
498500 const mockResourceMetadata = {
499- resource : "https://example.com/api " ,
501+ resource : "https://example.com/mcp " ,
500502 authorization_servers : [ "https://custom-auth.example.com" ] ,
501503 bearer_methods_supported : [ "header" , "body" ] ,
502- resource_documentation : "https://example.com/api /docs" ,
503- resource_policy_uri : "https://example.com/api /policy" ,
504+ resource_documentation : "https://example.com/mcp /docs" ,
505+ resource_policy_uri : "https://example.com/mcp /policy" ,
504506 } ;
505507
506508 // Mock successful metadata discovery
@@ -538,7 +540,7 @@ describe("AuthDebugger", () => {
538540 // Wait for the metadata to be fetched
539541 await waitFor ( ( ) => {
540542 expect ( mockDiscoverOAuthProtectedResourceMetadata ) . toHaveBeenCalledWith (
541- "https://example.com" ,
543+ "https://example.com/mcp " ,
542544 ) ;
543545 } ) ;
544546
@@ -584,7 +586,7 @@ describe("AuthDebugger", () => {
584586 // Wait for the metadata fetch to fail
585587 await waitFor ( ( ) => {
586588 expect ( mockDiscoverOAuthProtectedResourceMetadata ) . toHaveBeenCalledWith (
587- "https://example.com" ,
589+ "https://example.com/mcp " ,
588590 ) ;
589591 } ) ;
590592
@@ -594,15 +596,15 @@ describe("AuthDebugger", () => {
594596 expect . objectContaining ( {
595597 resourceMetadataError : mockError ,
596598 // Should use the original server URL as fallback
597- authServerUrl : new URL ( "https://example.com" ) ,
599+ authServerUrl : new URL ( "https://example.com/ " ) ,
598600 oauthStep : "client_registration" ,
599601 } ) ,
600602 ) ;
601603 } ) ;
602604
603605 // Verify that regular OAuth metadata discovery was still called
604606 expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
605- new URL ( "https://example.com" ) ,
607+ new URL ( "https://example.com/ " ) ,
606608 ) ;
607609 } ) ;
608610 } ) ;
0 commit comments