comments
This commit is contained in:
parent
65a139a5ae
commit
1dd5a34447
@ -260,6 +260,43 @@ describe('RxResumeClient', () => {
|
||||
expect(token).toBe('alt-token-field');
|
||||
});
|
||||
|
||||
it('extracts token from set-cookie header when missing from body', async () => {
|
||||
const mockFetch = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: {
|
||||
get: vi.fn().mockReturnValue(null),
|
||||
getSetCookie: vi
|
||||
.fn()
|
||||
.mockReturnValue(['Authentication=cookie-token; Path=/; HttpOnly']),
|
||||
},
|
||||
json: async () => ({}),
|
||||
});
|
||||
vi.stubGlobal('fetch', mockFetch);
|
||||
|
||||
const token = await client.login('test@example.com', 'password123');
|
||||
|
||||
expect(token).toBe('cookie-token');
|
||||
});
|
||||
|
||||
it('extracts token from set-cookie string header fallback', async () => {
|
||||
const mockFetch = vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: {
|
||||
get: vi
|
||||
.fn()
|
||||
.mockReturnValue('Authentication=string-token; Path=/; HttpOnly'),
|
||||
},
|
||||
json: async () => ({}),
|
||||
});
|
||||
vi.stubGlobal('fetch', mockFetch);
|
||||
|
||||
const token = await client.login('test@example.com', 'password123');
|
||||
|
||||
expect(token).toBe('string-token');
|
||||
});
|
||||
|
||||
it('throws error on login failure', async () => {
|
||||
const mockFetch = vi.fn().mockResolvedValue({
|
||||
ok: false,
|
||||
|
||||
@ -34,8 +34,6 @@ async function executeWithKeyRetries(url: string, options: RequestInit): Promise
|
||||
? rawApiKey.split(',').map(k => k.trim())
|
||||
: [rawApiKey];
|
||||
|
||||
let lastError: Error | null = null;
|
||||
|
||||
// Start from the last working key index
|
||||
for (let attempt = 0; attempt < apiKeys.length; attempt++) {
|
||||
const i = (lastWorkingKeyIndex + attempt) % apiKeys.length;
|
||||
@ -74,9 +72,7 @@ async function executeWithKeyRetries(url: string, options: RequestInit): Promise
|
||||
}
|
||||
return response.text();
|
||||
} catch (error) {
|
||||
lastError = error as Error;
|
||||
|
||||
// If it was already handled by the 401 check above, it won't reach here
|
||||
// If it was already handled by the 401 check above, it won't reach here
|
||||
// because of the 'continue'. This catch is for network errors or unexpected throw.
|
||||
throw error;
|
||||
}
|
||||
@ -94,7 +90,7 @@ async function executeWithKeyRetries(url: string, options: RequestInit): Promise
|
||||
`);
|
||||
}
|
||||
|
||||
throw lastError || new Error('All Reactive Resume API keys failed.');
|
||||
throw new Error('All Reactive Resume API keys failed.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const resumeProjectsSchema = z.object({
|
||||
maxProjects: z.number().int().min(1).max(100),
|
||||
maxProjects: z.number().int().min(0).max(100),
|
||||
lockedProjectIds: z.array(z.string().trim().min(1)).max(200),
|
||||
aiSelectableProjectIds: z.array(z.string().trim().min(1)).max(200),
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user