fix(oauth): cap tls preflight timeout · openclaw/openclaw@f10bad9
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; |
2 | 3 | import { |
3 | 4 | formatOpenAIOAuthTlsPreflightFix, |
4 | 5 | runOpenAIOAuthTlsPreflight, |
@@ -18,6 +19,23 @@ describe("runOpenAIOAuthTlsPreflight", () => {
|
18 | 19 | expect(result).toEqual({ ok: true }); |
19 | 20 | }); |
20 | 21 | |
| 22 | +it("caps oversized probe timeouts before creating abort signals", async () => { |
| 23 | +const timeoutController = new AbortController(); |
| 24 | +const timeoutSpy = vi.spyOn(AbortSignal, "timeout").mockReturnValue(timeoutController.signal); |
| 25 | +const fetchImpl = vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) => { |
| 26 | +expect(init?.signal).toBe(timeoutController.signal); |
| 27 | +return new Response("", { status: 400 }); |
| 28 | +}) as unknown as typeof fetch; |
| 29 | + |
| 30 | +const result = await runOpenAIOAuthTlsPreflight({ |
| 31 | + fetchImpl, |
| 32 | +timeoutMs: Number.MAX_SAFE_INTEGER, |
| 33 | +}); |
| 34 | + |
| 35 | +expect(result).toEqual({ ok: true }); |
| 36 | +expect(timeoutSpy).toHaveBeenCalledWith(MAX_TIMER_TIMEOUT_MS); |
| 37 | +}); |
| 38 | + |
21 | 39 | it("classifies TLS trust failures from fetch cause code", async () => { |
22 | 40 | const tlsFetchImpl = vi.fn(async () => { |
23 | 41 | const cause = new Error("unable to get local issuer certificate") as Error & { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。