Skip to content

Commit 72cb9a7

Browse files
committed
add tests
1 parent 3bdecfc commit 72cb9a7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/client/auth.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,36 @@ describe("OAuth Authorization", () => {
177177
await expect(discoverOAuthProtectedResourceMetadata("https://resource.example.com"))
178178
.rejects.toThrow();
179179
});
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+
});
180210
});
181211

182212
describe("discoverOAuthMetadata", () => {

0 commit comments

Comments
 (0)