





















11// OAuth TLS preflight tests cover timeout handling, TLS diagnostics, and suggested fixes.
22import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";
33import { beforeEach, describe, expect, it, vi } from "vitest";
4-import { withEnv } from "../test-utils/env.js";
54import {
65formatOpenAIOAuthTlsPreflightFix,
76runOpenAIOAuthTlsPreflight,
87shouldRunOpenAIOAuthTlsPrerequisites,
98} from "../plugins/provider-openai-chatgpt-oauth-tls.js";
9+import { withEnv } from "../test-utils/env.js";
10101111describe("runOpenAIOAuthTlsPreflight", () => {
1212beforeEach(() => {
1313vi.clearAllMocks();
1414});
15151616it("returns ok when OpenAI auth endpoint is reachable", async () => {
17-const fetchImpl = vi.fn(
18- async () => new Response("", { status: 400 }),
19-) as unknown as typeof fetch;
17+const response = new Response("reachable", { status: 400 });
18+const cancel = vi.spyOn(response.body!, "cancel").mockResolvedValue(undefined);
19+const fetchImpl = vi.fn(async () => response) as unknown as typeof fetch;
2020const result = await runOpenAIOAuthTlsPreflight({ fetchImpl, timeoutMs: 20 });
2121expect(result).toEqual({ ok: true });
22+expect(cancel).toHaveBeenCalledOnce();
2223});
23242425it("caps oversized probe timeouts before creating abort signals", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。