mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-17 13:00:48 +00:00
* Secrets: add inline allowlist review set * Secrets: narrow detect-secrets file exclusions * Secrets: exclude Docker fingerprint false positive * Secrets: allowlist test and docs false positives * Secrets: refresh baseline after allowlist updates * Secrets: fix gateway chat fixture pragma * Secrets: format pre-commit config * Android: keep talk mode fixture JSON valid * Feishu: rely on client timeout injection * Secrets: allowlist provider auth test fixtures * Secrets: allowlist onboard search fixtures * Secrets: allowlist onboard mode fixture * Secrets: allowlist gateway auth mode fixture * Secrets: allowlist APNS wake test key * Secrets: allowlist gateway reload fixtures * Secrets: allowlist moonshot video fixture * Secrets: allowlist auto audio fixture * Secrets: allowlist tiny audio fixture * Secrets: allowlist embeddings fixtures * Secrets: allowlist resolve fixtures * Secrets: allowlist target registry pattern fixtures * Secrets: allowlist gateway chat env fixture * Secrets: refresh baseline after fixture allowlists * Secrets: reapply gateway chat env allowlist * Secrets: reapply gateway chat env allowlist * Secrets: stabilize gateway chat env allowlist * Secrets: allowlist runtime snapshot save fixture * Secrets: allowlist oauth profile fixtures * Secrets: allowlist compaction identifier fixture * Secrets: allowlist model auth fixture * Secrets: allowlist model status fixtures * Secrets: allowlist custom onboarding fixture * Secrets: allowlist mattermost token summary fixtures * Secrets: allowlist gateway auth suite fixtures * Secrets: allowlist channel summary fixture * Secrets: allowlist provider usage auth fixtures * Secrets: allowlist media proxy fixture * Secrets: allowlist secrets audit fixtures * Secrets: refresh baseline after final fixture allowlists * Feishu: prefer explicit client timeout * Feishu: test direct timeout precedence
134 lines
3.9 KiB
TypeScript
134 lines
3.9 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
import { buildProviderRegistry, runCapability } from "./runner.js";
|
|
import { withAudioFixture, withVideoFixture } from "./runner.test-utils.js";
|
|
import type { AudioTranscriptionRequest, VideoDescriptionRequest } from "./types.js";
|
|
|
|
async function runAudioCapabilityWithFetchCapture(params: {
|
|
fixturePrefix: string;
|
|
outputText: string;
|
|
}): Promise<typeof fetch | undefined> {
|
|
let seenFetchFn: typeof fetch | undefined;
|
|
await withAudioFixture(params.fixturePrefix, async ({ ctx, media, cache }) => {
|
|
const providerRegistry = buildProviderRegistry({
|
|
openai: {
|
|
id: "openai",
|
|
capabilities: ["audio"],
|
|
transcribeAudio: async (req: AudioTranscriptionRequest) => {
|
|
seenFetchFn = req.fetchFn;
|
|
return { text: params.outputText, model: req.model };
|
|
},
|
|
},
|
|
});
|
|
|
|
const cfg = {
|
|
models: {
|
|
providers: {
|
|
openai: {
|
|
apiKey: "test-key", // pragma: allowlist secret
|
|
models: [],
|
|
},
|
|
},
|
|
},
|
|
tools: {
|
|
media: {
|
|
audio: {
|
|
enabled: true,
|
|
models: [{ provider: "openai", model: "whisper-1" }],
|
|
},
|
|
},
|
|
},
|
|
} as unknown as OpenClawConfig;
|
|
|
|
const result = await runCapability({
|
|
capability: "audio",
|
|
cfg,
|
|
ctx,
|
|
attachments: cache,
|
|
media,
|
|
providerRegistry,
|
|
});
|
|
|
|
expect(result.outputs[0]?.text).toBe(params.outputText);
|
|
});
|
|
return seenFetchFn;
|
|
}
|
|
|
|
describe("runCapability proxy fetch passthrough", () => {
|
|
beforeEach(() => vi.clearAllMocks());
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
|
|
it("passes fetchFn to audio provider when HTTPS_PROXY is set", async () => {
|
|
vi.stubEnv("HTTPS_PROXY", "http://proxy.test:8080");
|
|
const seenFetchFn = await runAudioCapabilityWithFetchCapture({
|
|
fixturePrefix: "openclaw-audio-proxy",
|
|
outputText: "transcribed",
|
|
});
|
|
expect(seenFetchFn).toBeDefined();
|
|
expect(seenFetchFn).not.toBe(globalThis.fetch);
|
|
});
|
|
|
|
it("passes fetchFn to video provider when HTTPS_PROXY is set", async () => {
|
|
vi.stubEnv("HTTPS_PROXY", "http://proxy.test:8080");
|
|
|
|
await withVideoFixture("openclaw-video-proxy", async ({ ctx, media, cache }) => {
|
|
let seenFetchFn: typeof fetch | undefined;
|
|
|
|
const result = await runCapability({
|
|
capability: "video",
|
|
cfg: {
|
|
models: {
|
|
providers: {
|
|
moonshot: {
|
|
apiKey: "test-key", // pragma: allowlist secret
|
|
models: [],
|
|
},
|
|
},
|
|
},
|
|
tools: {
|
|
media: {
|
|
video: {
|
|
enabled: true,
|
|
models: [{ provider: "moonshot", model: "kimi-k2.5" }],
|
|
},
|
|
},
|
|
},
|
|
} as unknown as OpenClawConfig,
|
|
ctx,
|
|
attachments: cache,
|
|
media,
|
|
providerRegistry: new Map([
|
|
[
|
|
"moonshot",
|
|
{
|
|
id: "moonshot",
|
|
capabilities: ["video"],
|
|
describeVideo: async (req: VideoDescriptionRequest) => {
|
|
seenFetchFn = req.fetchFn;
|
|
return { text: "video ok", model: req.model };
|
|
},
|
|
},
|
|
],
|
|
]),
|
|
});
|
|
|
|
expect(result.outputs[0]?.text).toBe("video ok");
|
|
expect(seenFetchFn).toBeDefined();
|
|
expect(seenFetchFn).not.toBe(globalThis.fetch);
|
|
});
|
|
});
|
|
|
|
it("does not pass fetchFn when no proxy env vars are set", async () => {
|
|
vi.stubEnv("HTTPS_PROXY", "");
|
|
vi.stubEnv("HTTP_PROXY", "");
|
|
vi.stubEnv("https_proxy", "");
|
|
vi.stubEnv("http_proxy", "");
|
|
|
|
const seenFetchFn = await runAudioCapabilityWithFetchCapture({
|
|
fixturePrefix: "openclaw-audio-no-proxy",
|
|
outputText: "ok",
|
|
});
|
|
expect(seenFetchFn).toBeUndefined();
|
|
});
|
|
});
|