test(codex): add coverage for native auth detection in environment probe

Add tests for codex_native_auth_present and codex_openai_api_key_missing
code paths. Also pass adapter-configured CODEX_HOME through to
readCodexAuthInfo so the probe respects per-adapter home directories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Devin Foley 2026-03-24 09:51:44 -07:00
parent a9dcea023b
commit 06b85d62b2
3 changed files with 65 additions and 3 deletions

View file

@ -107,8 +107,8 @@ function parsePlanAndEmailFromToken(idToken: string | null, accessToken: string
return { email: null, planType: null };
}
export async function readCodexAuthInfo(): Promise<CodexAuthInfo | null> {
const authPath = path.join(codexHomeDir(), "auth.json");
export async function readCodexAuthInfo(codexHome?: string): Promise<CodexAuthInfo | null> {
const authPath = path.join(codexHome ?? codexHomeDir(), "auth.json");
let raw: string;
try {
raw = await fs.readFile(authPath, "utf8");

View file

@ -109,7 +109,8 @@ export async function testEnvironment(
detail: `Detected in ${source}.`,
});
} else {
const codexAuth = await readCodexAuthInfo().catch(() => null);
const codexHome = isNonEmpty(env.CODEX_HOME) ? env.CODEX_HOME : undefined;
const codexAuth = await readCodexAuthInfo(codexHome).catch(() => null);
if (codexAuth) {
checks.push({
code: "codex_native_auth_present",