@@ -324,6 +324,7 @@ describe("OAuth Authorization", () => {
324
324
metadata : undefined ,
325
325
clientInformation : validClientInfo ,
326
326
redirectUrl : "http://localhost:3000/callback" ,
327
+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
327
328
}
328
329
) ;
329
330
@@ -338,20 +339,8 @@ describe("OAuth Authorization", () => {
338
339
expect ( authorizationUrl . searchParams . get ( "redirect_uri" ) ) . toBe (
339
340
"http://localhost:3000/callback"
340
341
) ;
341
- expect ( codeVerifier ) . toBe ( "test_verifier" ) ;
342
- } ) ;
343
-
344
- it ( "includes resource parameter when provided" , async ( ) => {
345
- const { authorizationUrl } = await startAuthorization (
346
- "https://auth.example.com" ,
347
- {
348
- clientInformation : validClientInfo ,
349
- redirectUrl : "http://localhost:3000/callback" ,
350
- resource : new URL ( "https://api.example.com/mcp-server" ) ,
351
- }
352
- ) ;
353
-
354
342
expect ( authorizationUrl . searchParams . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
343
+ expect ( codeVerifier ) . toBe ( "test_verifier" ) ;
355
344
} ) ;
356
345
357
346
it ( "includes scope parameter when provided" , async ( ) => {
@@ -478,6 +467,7 @@ describe("OAuth Authorization", () => {
478
467
authorizationCode : "code123" ,
479
468
codeVerifier : "verifier123" ,
480
469
redirectUri : "http://localhost:3000/callback" ,
470
+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
481
471
} ) ;
482
472
483
473
expect ( tokens ) . toEqual ( validTokens ) ;
@@ -500,26 +490,6 @@ describe("OAuth Authorization", () => {
500
490
expect ( body . get ( "client_id" ) ) . toBe ( "client123" ) ;
501
491
expect ( body . get ( "client_secret" ) ) . toBe ( "secret123" ) ;
502
492
expect ( body . get ( "redirect_uri" ) ) . toBe ( "http://localhost:3000/callback" ) ;
503
- } ) ;
504
-
505
- it ( "includes resource parameter in token exchange when provided" , async ( ) => {
506
- mockFetch . mockResolvedValueOnce ( {
507
- ok : true ,
508
- status : 200 ,
509
- json : async ( ) => validTokens ,
510
- } ) ;
511
-
512
- const tokens = await exchangeAuthorization ( "https://auth.example.com" , {
513
- clientInformation : validClientInfo ,
514
- authorizationCode : "code123" ,
515
- codeVerifier : "verifier123" ,
516
- redirectUri : "http://localhost:3000/callback" ,
517
- resource : new URL ( "https://api.example.com/mcp-server" ) ,
518
- } ) ;
519
-
520
- expect ( tokens ) . toEqual ( validTokens ) ;
521
-
522
- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
523
493
expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
524
494
} ) ;
525
495
@@ -588,6 +558,7 @@ describe("OAuth Authorization", () => {
588
558
const tokens = await refreshAuthorization ( "https://auth.example.com" , {
589
559
clientInformation : validClientInfo ,
590
560
refreshToken : "refresh123" ,
561
+ resource : new URL ( "https://api.example.com/mcp-server" ) ,
591
562
} ) ;
592
563
593
564
expect ( tokens ) . toEqual ( validTokensWithNewRefreshToken ) ;
@@ -608,24 +579,6 @@ describe("OAuth Authorization", () => {
608
579
expect ( body . get ( "refresh_token" ) ) . toBe ( "refresh123" ) ;
609
580
expect ( body . get ( "client_id" ) ) . toBe ( "client123" ) ;
610
581
expect ( body . get ( "client_secret" ) ) . toBe ( "secret123" ) ;
611
- } ) ;
612
-
613
- it ( "includes resource parameter in refresh token request when provided" , async ( ) => {
614
- mockFetch . mockResolvedValueOnce ( {
615
- ok : true ,
616
- status : 200 ,
617
- json : async ( ) => validTokensWithNewRefreshToken ,
618
- } ) ;
619
-
620
- const tokens = await refreshAuthorization ( "https://auth.example.com" , {
621
- clientInformation : validClientInfo ,
622
- refreshToken : "refresh123" ,
623
- resource : new URL ( "https://api.example.com/mcp-server" ) ,
624
- } ) ;
625
-
626
- expect ( tokens ) . toEqual ( validTokensWithNewRefreshToken ) ;
627
-
628
- const body = mockFetch . mock . calls [ 0 ] [ 1 ] . body as URLSearchParams ;
629
582
expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
630
583
} ) ;
631
584
0 commit comments