@@ -1125,7 +1125,7 @@ describe("OAuth Authorization", () => {
1125
1125
expect ( body . get ( "refresh_token" ) ) . toBe ( "refresh123" ) ;
1126
1126
} ) ;
1127
1127
1128
- it ( "handles empty resource parameter" , async ( ) => {
1128
+ it ( "handles derived resource parameter from serverUrl " , async ( ) => {
1129
1129
// Mock successful metadata discovery
1130
1130
mockFetch . mockImplementation ( ( url ) => {
1131
1131
const urlString = url . toString ( ) ;
@@ -1154,17 +1154,18 @@ describe("OAuth Authorization", () => {
1154
1154
( mockProvider . saveCodeVerifier as jest . Mock ) . mockResolvedValue ( undefined ) ;
1155
1155
( mockProvider . redirectToAuthorization as jest . Mock ) . mockResolvedValue ( undefined ) ;
1156
1156
1157
- // Call auth with empty resource parameter
1157
+ // Call auth with just serverUrl ( resource is derived from it)
1158
1158
const result = await auth ( mockProvider , {
1159
1159
serverUrl : "https://api.example.com/mcp-server" ,
1160
1160
} ) ;
1161
1161
1162
1162
expect ( result ) . toBe ( "REDIRECT" ) ;
1163
1163
1164
- // Verify that empty resource is not included in the URL
1164
+ // Verify that resource parameter is always included (derived from serverUrl)
1165
1165
const redirectCall = ( mockProvider . redirectToAuthorization as jest . Mock ) . mock . calls [ 0 ] ;
1166
1166
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" ) ;
1168
1169
} ) ;
1169
1170
1170
1171
it ( "handles resource with multiple fragments" , async ( ) => {
0 commit comments