mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Merge 4d30621c8c into c80e6e2474
This commit is contained in:
commit
96dc59d294
2 changed files with 35 additions and 1 deletions
|
|
@ -118,6 +118,40 @@ describe("loginCall - storeLoginToken integration", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("exchangeLoginCode - storeLoginToken integration", () => {
|
||||
const originalFetch = global.fetch;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
global.fetch = originalFetch;
|
||||
});
|
||||
|
||||
it("calls storeLoginToken when exchange response includes token", async () => {
|
||||
global.fetch = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ token: "sso-jwt" }),
|
||||
}) as unknown as typeof global.fetch;
|
||||
const { storeLoginToken } = await import("@/utils/cookieUtils");
|
||||
const token = await Networking.exchangeLoginCode("some-login-code");
|
||||
expect(token).toBe("sso-jwt");
|
||||
expect(storeLoginToken).toHaveBeenCalledWith("sso-jwt");
|
||||
});
|
||||
|
||||
it("does not call storeLoginToken when exchange response has no token", async () => {
|
||||
global.fetch = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({}),
|
||||
}) as unknown as typeof global.fetch;
|
||||
const { storeLoginToken } = await import("@/utils/cookieUtils");
|
||||
const token = await Networking.exchangeLoginCode("some-login-code");
|
||||
expect(token).toBeUndefined();
|
||||
expect(storeLoginToken).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("modelInfoCall", () => {
|
||||
let currentFetch: typeof global.fetch;
|
||||
|
||||
|
|
|
|||
|
|
@ -7000,7 +7000,7 @@ export const exchangeLoginCode = async (code: string, workerBaseUrl?: string | n
|
|||
|
||||
const data = await response.json();
|
||||
if (data.token) {
|
||||
document.cookie = `token=${data.token}; path=/; SameSite=Lax`;
|
||||
storeLoginToken(data.token);
|
||||
}
|
||||
return data.token;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue