test(auth): align codex bootstrap expectations

This commit is contained in:
Vincent Koc
2026-04-18 07:34:53 -07:00
committed by Peter Steinberger
parent 78288e37ed
commit 20debfab90
3 changed files with 4 additions and 45 deletions

View File

@@ -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,
}),

View File

@@ -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,

View File

@@ -131,7 +131,6 @@ describe("auth external oauth helpers", () => {
refresh: "fresh-cli-refresh-token",
expires: createUsableOAuthExpiry(),
accountId: "acct-cli",
expires: createUsableOAuthExpiry(),
}),
);