From 20debfab90c5ab9ec2a6e403bae279b1d1254a7b Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 18 Apr 2026 07:34:53 -0700 Subject: [PATCH] test(auth): align codex bootstrap expectations --- .../codex/src/app-server/auth-bridge.test.ts | 4 ++ .../openai/openai-codex-cli-auth.test.ts | 44 ------------------- .../auth-profiles/external-oauth.test.ts | 1 - 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/extensions/codex/src/app-server/auth-bridge.test.ts b/extensions/codex/src/app-server/auth-bridge.test.ts index e15979c1f2a..1d99a5456fa 100644 --- a/extensions/codex/src/app-server/auth-bridge.test.ts +++ b/extensions/codex/src/app-server/auth-bridge.test.ts @@ -54,6 +54,7 @@ describe("bridgeCodexAppServerStartOptions", () => { const result = await bridgeCodexAppServerStartOptions({ startOptions: { + transport: "stdio", command: "codex", args: ["app-server"], headers: { authorization: "Bearer dev-token" }, @@ -92,6 +93,7 @@ describe("bridgeCodexAppServerStartOptions", () => { const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-app-server-")); tempDirs.push(agentDir); const startOptions = { + transport: "stdio" as const, command: "codex", args: ["app-server"], headers: { authorization: "Bearer dev-token" }, @@ -133,8 +135,10 @@ describe("bridgeCodexAppServerStartOptions", () => { await expect( bridgeCodexAppServerStartOptions({ startOptions: { + transport: "stdio", command: "codex", args: ["app-server"], + headers: {}, }, agentDir, }), diff --git a/extensions/openai/openai-codex-cli-auth.test.ts b/extensions/openai/openai-codex-cli-auth.test.ts index 2c528ff5f86..06659068366 100644 --- a/extensions/openai/openai-codex-cli-auth.test.ts +++ b/extensions/openai/openai-codex-cli-auth.test.ts @@ -123,50 +123,6 @@ describe("readOpenAICodexCliOAuthProfile", () => { expect(parsed).toBeNull(); }); - it("allows Codex CLI bootstrap when the stored default is expired", () => { - const accessToken = buildJwt({ - exp: Math.floor(Date.now() / 1000) + 600, - "https://api.openai.com/profile": { - email: "codex@example.com", - }, - }); - vi.spyOn(fs, "readFileSync").mockReturnValue( - JSON.stringify({ - auth_mode: "chatgpt", - tokens: { - access_token: accessToken, - refresh_token: "refresh-token", - account_id: "acct_123", - }, - }), - ); - - const parsed = readOpenAICodexCliOAuthProfile({ - store: { - version: 1, - profiles: { - [OPENAI_CODEX_DEFAULT_PROFILE_ID]: { - type: "oauth", - provider: "openai-codex", - access: "expired-local-access", - refresh: "expired-local-refresh", - expires: Date.now() - 60_000, - }, - }, - }, - }); - - expect(parsed).toMatchObject({ - profileId: OPENAI_CODEX_DEFAULT_PROFILE_ID, - credential: { - access: accessToken, - refresh: "refresh-token", - accountId: "acct_123", - email: "codex@example.com", - }, - }); - }); - it("refuses Codex CLI bootstrap when an expired local default belongs to a different account", () => { const accessToken = buildJwt({ exp: Math.floor(Date.now() / 1000) + 600, diff --git a/src/agents/auth-profiles/external-oauth.test.ts b/src/agents/auth-profiles/external-oauth.test.ts index 6f88462099e..99123f51885 100644 --- a/src/agents/auth-profiles/external-oauth.test.ts +++ b/src/agents/auth-profiles/external-oauth.test.ts @@ -131,7 +131,6 @@ describe("auth external oauth helpers", () => { refresh: "fresh-cli-refresh-token", expires: createUsableOAuthExpiry(), accountId: "acct-cli", - expires: createUsableOAuthExpiry(), }), );