
























@@ -89,11 +89,11 @@ function expectPersistedOpenAICodexProfileWithoutInlineTokens(
8989credential: AuthProfileStore["profiles"][string],
9090metadata: Record<string, unknown> = {},
9191): void {
92-expect(credential).toMatchObject({
93- type: "oauth",
94- provider: "openai-codex",
95-...metadata,
96-});
92+expect(credential?.type).toBe("oauth");
93+expect(credential?.provider).toBe("openai-codex");
94+for (const [key, value] of Object.entries(metadata)) {
95+expect(credential?.[key as keyof typeof credential]).toBe(value);
96+}
9797expect(credential).not.toHaveProperty("access");
9898expect(credential).not.toHaveProperty("refresh");
9999expect(credential).not.toHaveProperty("idToken");
@@ -305,12 +305,7 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
305305});
306306expect(JSON.stringify(persisted)).not.toContain("rotated-cli-access-token");
307307expect(JSON.stringify(persisted)).not.toContain("rotated-cli-refresh-token");
308-expect(persisted.profiles[profileId]).not.toEqual(
309-expect.objectContaining({
310-provider: "openai-codex",
311-access: "expired-access-token",
312-}),
313-);
308+expect(persisted.profiles[profileId]).not.toHaveProperty("access");
314309});
315310316311it("ignores mismatched fresh Codex CLI credentials when canonical local auth is bound to another account", async () => {
@@ -368,13 +363,10 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
368363});
369364expect(JSON.stringify(persisted)).not.toContain("fresh-local-access-token");
370365expect(JSON.stringify(persisted)).not.toContain("fresh-local-refresh-token");
371-expect(persisted.profiles[profileId]).not.toEqual(
372-expect.objectContaining({
373-access: "fresh-cli-access-token",
374-refresh: "fresh-cli-refresh-token",
375-accountId: "acct-external",
376-}),
377-);
366+const persistedProfile = requireOAuthProfile(persisted, profileId);
367+expect(persistedProfile.accountId).toBe("acct-local");
368+expect(persistedProfile).not.toHaveProperty("access");
369+expect(persistedProfile).not.toHaveProperty("refresh");
378370});
379371380372it("keeps the canonical refresh token when imported Codex CLI state is expired", async () => {
@@ -433,11 +425,7 @@ describe("resolveApiKeyForProfile openai-codex refresh fallback", () => {
433425expectPersistedOpenAICodexProfileWithoutInlineTokens(persisted.profiles[profileId]);
434426expect(JSON.stringify(persisted)).not.toContain("fresh-access-token");
435427expect(JSON.stringify(persisted)).not.toContain("fresh-refresh-token");
436-expect(persisted.profiles[profileId]).not.toEqual(
437-expect.objectContaining({
438-refresh: "fresh-cli-refresh-token",
439-}),
440-);
428+expect(persisted.profiles[profileId]).not.toHaveProperty("refresh");
441429});
442430443431it("adopts fresher stored credentials after refresh_token_reused", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。