@@ -1125,7 +1125,7 @@ describe("OAuth Authorization", () => {
11251125 expect ( body . get ( "refresh_token" ) ) . toBe ( "refresh123" ) ;
11261126 } ) ;
11271127
1128- it ( "handles empty resource parameter" , async ( ) => {
1128+ it ( "handles derived resource parameter from serverUrl " , async ( ) => {
11291129 // Mock successful metadata discovery
11301130 mockFetch . mockImplementation ( ( url ) => {
11311131 const urlString = url . toString ( ) ;
@@ -1154,17 +1154,18 @@ describe("OAuth Authorization", () => {
11541154 ( mockProvider . saveCodeVerifier as jest . Mock ) . mockResolvedValue ( undefined ) ;
11551155 ( mockProvider . redirectToAuthorization as jest . Mock ) . mockResolvedValue ( undefined ) ;
11561156
1157- // Call auth with empty resource parameter
1157+ // Call auth with just serverUrl ( resource is derived from it)
11581158 const result = await auth ( mockProvider , {
11591159 serverUrl : "https://api.example.com/mcp-server" ,
11601160 } ) ;
11611161
11621162 expect ( result ) . toBe ( "REDIRECT" ) ;
11631163
1164- // Verify that empty resource is not included in the URL
1164+ // Verify that resource parameter is always included (derived from serverUrl)
11651165 const redirectCall = ( mockProvider . redirectToAuthorization as jest . Mock ) . mock . calls [ 0 ] ;
11661166 const authUrl : URL = redirectCall [ 0 ] ;
1167- expect ( authUrl . searchParams . has ( "resource" ) ) . toBe ( false ) ;
1167+ expect ( authUrl . searchParams . has ( "resource" ) ) . toBe ( true ) ;
1168+ expect ( authUrl . searchParams . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
11681169 } ) ;
11691170
11701171 it ( "handles resource with multiple fragments" , async ( ) => {
0 commit comments