@@ -41,6 +41,7 @@ jest.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({
41
41
startAuthorization : jest . fn ( ) ,
42
42
exchangeAuthorization : jest . fn ( ) ,
43
43
discoverOAuthProtectedResourceMetadata : jest . fn ( ) ,
44
+ selectResourceURL : jest . fn ( ) ,
44
45
} ) ) ;
45
46
46
47
// Import the functions to get their types
@@ -88,7 +89,7 @@ describe("AuthDebugger", () => {
88
89
const defaultAuthState = EMPTY_DEBUGGER_STATE ;
89
90
90
91
const defaultProps = {
91
- serverUrl : "https://example.com" ,
92
+ serverUrl : "https://example.com/mcp " ,
92
93
onBack : jest . fn ( ) ,
93
94
authState : defaultAuthState ,
94
95
updateAuthState : jest . fn ( ) ,
@@ -203,7 +204,7 @@ describe("AuthDebugger", () => {
203
204
204
205
// Should first discover and save OAuth metadata
205
206
expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
206
- new URL ( "https://example.com" ) ,
207
+ new URL ( "https://example.com/ " ) ,
207
208
) ;
208
209
209
210
// Check that updateAuthState was called with the right info message
@@ -320,6 +321,7 @@ describe("AuthDebugger", () => {
320
321
isInitiatingAuth : false ,
321
322
resourceMetadata : null ,
322
323
resourceMetadataError : null ,
324
+ resource : null ,
323
325
oauthTokens : null ,
324
326
oauthStep : "metadata_discovery" ,
325
327
latestError : null ,
@@ -361,7 +363,7 @@ describe("AuthDebugger", () => {
361
363
} ) ;
362
364
363
365
expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
364
- new URL ( "https://example.com" ) ,
366
+ new URL ( "https://example.com/ " ) ,
365
367
) ;
366
368
} ) ;
367
369
@@ -496,11 +498,11 @@ describe("AuthDebugger", () => {
496
498
it ( "should successfully fetch and display protected resource metadata" , async ( ) => {
497
499
const updateAuthState = jest . fn ( ) ;
498
500
const mockResourceMetadata = {
499
- resource : "https://example.com/api " ,
501
+ resource : "https://example.com/mcp " ,
500
502
authorization_servers : [ "https://custom-auth.example.com" ] ,
501
503
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" ,
504
506
} ;
505
507
506
508
// Mock successful metadata discovery
@@ -538,7 +540,7 @@ describe("AuthDebugger", () => {
538
540
// Wait for the metadata to be fetched
539
541
await waitFor ( ( ) => {
540
542
expect ( mockDiscoverOAuthProtectedResourceMetadata ) . toHaveBeenCalledWith (
541
- "https://example.com" ,
543
+ "https://example.com/mcp " ,
542
544
) ;
543
545
} ) ;
544
546
@@ -584,7 +586,7 @@ describe("AuthDebugger", () => {
584
586
// Wait for the metadata fetch to fail
585
587
await waitFor ( ( ) => {
586
588
expect ( mockDiscoverOAuthProtectedResourceMetadata ) . toHaveBeenCalledWith (
587
- "https://example.com" ,
589
+ "https://example.com/mcp " ,
588
590
) ;
589
591
} ) ;
590
592
@@ -594,15 +596,15 @@ describe("AuthDebugger", () => {
594
596
expect . objectContaining ( {
595
597
resourceMetadataError : mockError ,
596
598
// Should use the original server URL as fallback
597
- authServerUrl : new URL ( "https://example.com" ) ,
599
+ authServerUrl : new URL ( "https://example.com/ " ) ,
598
600
oauthStep : "client_registration" ,
599
601
} ) ,
600
602
) ;
601
603
} ) ;
602
604
603
605
// Verify that regular OAuth metadata discovery was still called
604
606
expect ( mockDiscoverOAuthMetadata ) . toHaveBeenCalledWith (
605
- new URL ( "https://example.com" ) ,
607
+ new URL ( "https://example.com/ " ) ,
606
608
) ;
607
609
} ) ;
608
610
} ) ;
0 commit comments