mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 10:14:08 +00:00
fix: add CLIProxy account reauthentication
This commit is contained in:
1 parent
d212c72ad8
commit
5f1976f69c
16 files changed
+332
-34
No files matched your search
@@ -86,6 +86,47 @@ describe('useCliproxyAuthFlow', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('includes the selected account id when reauth starts from the dashboard', async () => {
|
||||
const fetchMock = vi.fn((input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
|
||||
if (url.includes('/codex/start-url')) {
|
||||
return Promise.resolve(
|
||||
createJsonResponse({
|
||||
success: true,
|
||||
authUrl: 'https://auth.example.com/codex?state=codex-reauth',
|
||||
state: 'codex-reauth',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (url.includes('/status?state=codex-reauth')) {
|
||||
return Promise.resolve(createJsonResponse({ status: 'wait' }));
|
||||
}
|
||||
|
||||
return Promise.reject(new Error(`Unexpected fetch: ${url}`));
|
||||
});
|
||||
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
const { result } = renderHook(() => useCliproxyAuthFlow(), { wrapper });
|
||||
|
||||
await act(async () => {
|
||||
await result.current.startAuth('codex', {
|
||||
accountId: 'existing@example.com',
|
||||
startEndpoint: 'start-url',
|
||||
});
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/cliproxy/auth/codex/start-url',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: expect.stringContaining('"accountId":"existing@example.com"'),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('surfaces manual OAuth start guidance from the dashboard API', async () => {
|
||||
const guidance = [
|
||||
'Start local CLIProxy first: ccs cliproxy start',
|
||||
|
||||
@@ -191,4 +191,41 @@ describe('AuthMonitor', () => {
|
||||
expect(within(getSummaryCard('Failed')).getByText('3')).toBeInTheDocument();
|
||||
expect(within(getSummaryCard('Success Rate')).getByText('80%')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows CLIProxy guidance when a large account pool has a high failure rate', () => {
|
||||
useAuthMonitorDataMock.mockReturnValue({
|
||||
...authMonitorData,
|
||||
accounts: Array.from({ length: 5 }, (_, index) => ({
|
||||
id: `codex-${index}`,
|
||||
email: `codex-${index}@example.com`,
|
||||
tokenFile: `/tmp/codex-${index}.json`,
|
||||
provider: 'codex',
|
||||
displayName: 'OpenAI Codex',
|
||||
isDefault: index === 0,
|
||||
successCount: index === 0 ? 1 : 0,
|
||||
failureCount: 5,
|
||||
color: '#10a37f',
|
||||
})),
|
||||
totalSuccess: 1,
|
||||
totalFailure: 25,
|
||||
totalRequests: 26,
|
||||
providerStats: [
|
||||
{
|
||||
provider: 'codex',
|
||||
displayName: 'OpenAI Codex',
|
||||
totalRequests: 26,
|
||||
successCount: 1,
|
||||
failureCount: 25,
|
||||
accountCount: 5,
|
||||
accounts: [],
|
||||
},
|
||||
],
|
||||
overallSuccessRate: 4,
|
||||
});
|
||||
|
||||
render(<AuthMonitor />);
|
||||
|
||||
expect(screen.getByText('High CLIProxy failure rate detected')).toBeInTheDocument();
|
||||
expect(screen.getByText(/ccs cliproxy routing/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user