@@ -849,7 +849,7 @@ describe("OAuth Authorization", () => {
849
849
} ) ;
850
850
851
851
expect ( result ) . toBe ( "REDIRECT" ) ;
852
-
852
+
853
853
// Verify the authorization URL includes the resource parameter
854
854
expect ( mockProvider . redirectToAuthorization ) . toHaveBeenCalledWith (
855
855
expect . objectContaining ( {
@@ -866,7 +866,7 @@ describe("OAuth Authorization", () => {
866
866
// Mock successful metadata discovery and token exchange
867
867
mockFetch . mockImplementation ( ( url ) => {
868
868
const urlString = url . toString ( ) ;
869
-
869
+
870
870
if ( urlString . includes ( "/.well-known/oauth-authorization-server" ) ) {
871
871
return Promise . resolve ( {
872
872
ok : true ,
@@ -891,7 +891,7 @@ describe("OAuth Authorization", () => {
891
891
} ) ,
892
892
} ) ;
893
893
}
894
-
894
+
895
895
return Promise . resolve ( { ok : false , status : 404 } ) ;
896
896
} ) ;
897
897
@@ -912,11 +912,11 @@ describe("OAuth Authorization", () => {
912
912
expect ( result ) . toBe ( "AUTHORIZED" ) ;
913
913
914
914
// Find the token exchange call
915
- const tokenCall = mockFetch . mock . calls . find ( call =>
915
+ const tokenCall = mockFetch . mock . calls . find ( call =>
916
916
call [ 0 ] . toString ( ) . includes ( "/token" )
917
917
) ;
918
918
expect ( tokenCall ) . toBeDefined ( ) ;
919
-
919
+
920
920
const body = tokenCall ! [ 1 ] . body as URLSearchParams ;
921
921
expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
922
922
expect ( body . get ( "code" ) ) . toBe ( "auth-code-123" ) ;
@@ -926,7 +926,7 @@ describe("OAuth Authorization", () => {
926
926
// Mock successful metadata discovery and token refresh
927
927
mockFetch . mockImplementation ( ( url ) => {
928
928
const urlString = url . toString ( ) ;
929
-
929
+
930
930
if ( urlString . includes ( "/.well-known/oauth-authorization-server" ) ) {
931
931
return Promise . resolve ( {
932
932
ok : true ,
@@ -950,7 +950,7 @@ describe("OAuth Authorization", () => {
950
950
} ) ,
951
951
} ) ;
952
952
}
953
-
953
+
954
954
return Promise . resolve ( { ok : false , status : 404 } ) ;
955
955
} ) ;
956
956
@@ -973,29 +973,29 @@ describe("OAuth Authorization", () => {
973
973
expect ( result ) . toBe ( "AUTHORIZED" ) ;
974
974
975
975
// Find the token refresh call
976
- const tokenCall = mockFetch . mock . calls . find ( call =>
976
+ const tokenCall = mockFetch . mock . calls . find ( call =>
977
977
call [ 0 ] . toString ( ) . includes ( "/token" )
978
978
) ;
979
979
expect ( tokenCall ) . toBeDefined ( ) ;
980
-
980
+
981
981
const body = tokenCall ! [ 1 ] . body as URLSearchParams ;
982
982
expect ( body . get ( "resource" ) ) . toBe ( "https://api.example.com/mcp-server" ) ;
983
983
expect ( body . get ( "grant_type" ) ) . toBe ( "refresh_token" ) ;
984
984
expect ( body . get ( "refresh_token" ) ) . toBe ( "refresh123" ) ;
985
985
} ) ;
986
986
987
- it ( "skips default PRM resource validation when custom validateProtectedResourceMetadata is provided" , async ( ) => {
988
- const mockValidateProtectedResourceMetadata = jest . fn ( ) . mockResolvedValue ( undefined ) ;
987
+ it ( "skips default PRM resource validation when custom validateResourceURL is provided" , async ( ) => {
988
+ const mockValidateResourceURL = jest . fn ( ) . mockResolvedValue ( undefined ) ;
989
989
const providerWithCustomValidation = {
990
990
...mockProvider ,
991
- validateProtectedResourceMetadata : mockValidateProtectedResourceMetadata ,
991
+ validateResourceURL : mockValidateResourceURL ,
992
992
} ;
993
993
994
994
// Mock protected resource metadata with mismatched resource URL
995
995
// This would normally throw an error in default validation, but should be skipped
996
996
mockFetch . mockImplementation ( ( url ) => {
997
997
const urlString = url . toString ( ) ;
998
-
998
+
999
999
if ( urlString . includes ( "/.well-known/oauth-protected-resource" ) ) {
1000
1000
return Promise . resolve ( {
1001
1001
ok : true ,
@@ -1018,7 +1018,7 @@ describe("OAuth Authorization", () => {
1018
1018
} ) ,
1019
1019
} ) ;
1020
1020
}
1021
-
1021
+
1022
1022
return Promise . resolve ( { ok : false , status : 404 } ) ;
1023
1023
} ) ;
1024
1024
@@ -1037,12 +1037,12 @@ describe("OAuth Authorization", () => {
1037
1037
} ) ;
1038
1038
1039
1039
expect ( result ) . toBe ( "REDIRECT" ) ;
1040
-
1040
+
1041
1041
// Verify custom validation method was called
1042
- expect ( mockValidateProtectedResourceMetadata ) . toHaveBeenCalledWith ( {
1043
- resource : "https://different-resource .example.com/mcp-server" ,
1044
- authorization_servers : [ "https://auth .example.com" ] ,
1045
- } ) ;
1042
+ expect ( mockValidateResourceURL ) . toHaveBeenCalledWith (
1043
+ "https://api .example.com/mcp-server" ,
1044
+ "https://different-resource .example.com/mcp-server"
1045
+ ) ;
1046
1046
} ) ;
1047
1047
} ) ;
1048
1048
} ) ;
0 commit comments