File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,36 @@ describe("OAuth Authorization", () => {
177
177
await expect ( discoverOAuthProtectedResourceMetadata ( "https://resource.example.com" ) )
178
178
. rejects . toThrow ( ) ;
179
179
} ) ;
180
+
181
+ it ( "returns metadata when discovery succeeds with path" , async ( ) => {
182
+ mockFetch . mockResolvedValueOnce ( {
183
+ ok : true ,
184
+ status : 200 ,
185
+ json : async ( ) => validMetadata ,
186
+ } ) ;
187
+
188
+ const metadata = await discoverOAuthProtectedResourceMetadata ( "https://resource.example.com/path/name" ) ;
189
+ expect ( metadata ) . toEqual ( validMetadata ) ;
190
+ const calls = mockFetch . mock . calls ;
191
+ expect ( calls . length ) . toBe ( 1 ) ;
192
+ const [ url ] = calls [ 0 ] ;
193
+ expect ( url . toString ( ) ) . toBe ( "https://resource.example.com/.well-known/oauth-protected-resource/path/name" ) ;
194
+ } ) ;
195
+
196
+ it ( "preserves query parameters in path-aware discovery" , async ( ) => {
197
+ mockFetch . mockResolvedValueOnce ( {
198
+ ok : true ,
199
+ status : 200 ,
200
+ json : async ( ) => validMetadata ,
201
+ } ) ;
202
+
203
+ const metadata = await discoverOAuthProtectedResourceMetadata ( "https://resource.example.com/path?param=value" ) ;
204
+ expect ( metadata ) . toEqual ( validMetadata ) ;
205
+ const calls = mockFetch . mock . calls ;
206
+ expect ( calls . length ) . toBe ( 1 ) ;
207
+ const [ url ] = calls [ 0 ] ;
208
+ expect ( url . toString ( ) ) . toBe ( "https://resource.example.com/.well-known/oauth-protected-resource/path?param=value" ) ;
209
+ } ) ;
180
210
} ) ;
181
211
182
212
describe ( "discoverOAuthMetadata" , ( ) => {
You can’t perform that action at this time.
0 commit comments