From 56f652b499ab3874d35537a002daf6fd5491d3a7 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 5 Jun 2026 02:17:15 +0100 Subject: [PATCH] test: pin oauth tls brew env --- src/commands/oauth-tls-preflight.test.ts | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/commands/oauth-tls-preflight.test.ts b/src/commands/oauth-tls-preflight.test.ts index 9c189a1ea4db..e2ef47fd1544 100644 --- a/src/commands/oauth-tls-preflight.test.ts +++ b/src/commands/oauth-tls-preflight.test.ts @@ -1,6 +1,7 @@ // OAuth TLS preflight tests cover timeout handling, TLS diagnostics, and suggested fixes. import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion"; import { beforeEach, describe, expect, it, vi } from "vitest"; +import { withEnv } from "../test-utils/env.js"; import { formatOpenAIOAuthTlsPreflightFix, runOpenAIOAuthTlsPreflight, @@ -10,7 +11,6 @@ import { describe("runOpenAIOAuthTlsPreflight", () => { beforeEach(() => { vi.clearAllMocks(); - vi.unstubAllEnvs(); }); it("returns ok when OpenAI auth endpoint is reachable", async () => { @@ -77,23 +77,24 @@ describe("runOpenAIOAuthTlsPreflight", () => { describe("formatOpenAIOAuthTlsPreflightFix", () => { it("includes remediation commands for TLS failures", () => { - vi.stubEnv("HOMEBREW_PREFIX", ""); - const text = formatOpenAIOAuthTlsPreflightFix({ - ok: false, - kind: "tls-cert", - code: "UNABLE_TO_GET_ISSUER_CERT_LOCALLY", - message: "unable to get local issuer certificate", + withEnv({ HOMEBREW_PREFIX: "" }, () => { + const text = formatOpenAIOAuthTlsPreflightFix({ + ok: false, + kind: "tls-cert", + code: "UNABLE_TO_GET_ISSUER_CERT_LOCALLY", + message: "unable to get local issuer certificate", + }); + expect(text).toContain( + "OpenAI OAuth prerequisites check failed: Node/OpenSSL cannot validate TLS certificates.", + ); + expect(text).toContain( + "Cause: UNABLE_TO_GET_ISSUER_CERT_LOCALLY (unable to get local issuer certificate)", + ); + expect(text).toContain("Fix (Homebrew Node/OpenSSL):"); + expect(text).toContain("- brew postinstall ca-certificates"); + expect(text).toContain("- brew postinstall openssl@3"); + expect(text).toContain("- Retry the OAuth login flow."); }); - expect(text).toContain( - "OpenAI OAuth prerequisites check failed: Node/OpenSSL cannot validate TLS certificates.", - ); - expect(text).toContain( - "Cause: UNABLE_TO_GET_ISSUER_CERT_LOCALLY (unable to get local issuer certificate)", - ); - expect(text).toContain("Fix (Homebrew Node/OpenSSL):"); - expect(text).toContain("- brew postinstall ca-certificates"); - expect(text).toContain("- brew postinstall openssl@3"); - expect(text).toContain("- Retry the OAuth login flow."); }); });