Skip to content

Commit 99be378

Browse files
committed
Test provider auth state for restored sessions
1 parent f663e93 commit 99be378

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,64 @@ describe('ACP server test', { timeout: 40_000 }, () => {
477477
expect(threadResumeSpy.mock.calls[1]![0].modelProvider).toBe("azure");
478478
});
479479

480+
it('tracks configured model provider auth state for resumed and loaded sessions', async () => {
481+
const mockFixture = createCodexMockTestFixture();
482+
const codexAcpAgent = mockFixture.getCodexAcpAgent();
483+
const codexAcpClient = mockFixture.getCodexAcpClient();
484+
const codexAppServerClient = mockFixture.getCodexAppServerClient();
485+
486+
vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false);
487+
const getAccountSpy = vi.spyOn(codexAcpClient, "getAccount").mockResolvedValue({
488+
account: null,
489+
requiresOpenaiAuth: true,
490+
});
491+
vi.spyOn(codexAppServerClient, "skillsExtraRootsSet").mockResolvedValue(undefined);
492+
vi.spyOn(codexAppServerClient, "listSkills").mockResolvedValue({data: []});
493+
vi.spyOn(codexAppServerClient, "configRead").mockResolvedValue({
494+
config: {
495+
model_provider: "azure",
496+
},
497+
} as any);
498+
const threadResumeSpy = vi.spyOn(codexAppServerClient, "threadResume").mockResolvedValue({
499+
thread: {id: "thread-id"} as any,
500+
model: "gpt-5",
501+
modelProvider: "azure",
502+
reasoningEffort: "medium",
503+
serviceTier: null,
504+
} as any);
505+
vi.spyOn(codexAppServerClient, "threadRead").mockResolvedValue({
506+
thread: {id: "thread-id", turns: []} as any,
507+
});
508+
vi.spyOn(codexAppServerClient, "listModels").mockResolvedValue({
509+
data: [createTestModel({id: "gpt-5"})],
510+
nextCursor: null,
511+
});
512+
513+
await codexAcpAgent.resumeSession({
514+
sessionId: "resume-id",
515+
cwd: "/workspace",
516+
});
517+
await codexAcpAgent.loadSession({
518+
sessionId: "load-id",
519+
cwd: "/workspace",
520+
mcpServers: [],
521+
});
522+
523+
expect(threadResumeSpy.mock.calls[0]![0].modelProvider).toBe("azure");
524+
expect(threadResumeSpy.mock.calls[1]![0].modelProvider).toBe("azure");
525+
expect(getAccountSpy).not.toHaveBeenCalled();
526+
expect(codexAcpAgent.getSessionState("resume-id")).toMatchObject({
527+
account: null,
528+
authConfigured: true,
529+
authProvider: "azure",
530+
});
531+
expect(codexAcpAgent.getSessionState("load-id")).toMatchObject({
532+
account: null,
533+
authConfigured: true,
534+
authProvider: "azure",
535+
});
536+
});
537+
480538
it('rejects malformed ACP additional directories', async () => {
481539
const mockFixture = createCodexMockTestFixture();
482540
const codexAcpClient = mockFixture.getCodexAcpClient();

0 commit comments

Comments
 (0)