@@ -6,6 +6,7 @@ import { tmpdir } from "node:os";
|
6 | 6 | import path from "node:path"; |
7 | 7 | import { beforeAll, describe, expect, it } from "vitest"; |
8 | 8 | import { createBoundedChildOutput } from "../helpers/bounded-child-output.js"; |
| 9 | +import { cleanupTempDirs, makeTempDir } from "../helpers/temp-dir.js"; |
9 | 10 | |
10 | 11 | const clientPath = path.resolve("scripts/e2e/lib/openai-chat-tools/client.mjs"); |
11 | 12 | const dockerRunnerPath = path.resolve("scripts/e2e/openai-chat-tools-docker.sh"); |
@@ -204,6 +205,44 @@ describe("scripts/e2e/lib/openai-chat-tools/client.mjs", () => {
|
204 | 205 | rmSync(root, { force: true, recursive: true }); |
205 | 206 | } |
206 | 207 | }); |
| 208 | + |
| 209 | +it.each([ |
| 210 | +["timeout", "OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS", "1e3"], |
| 211 | +["body limit", "OPENCLAW_OPENAI_CHAT_TOOLS_MAX_BODY_BYTES", "64bytes"], |
| 212 | +])( |
| 213 | +"rejects invalid Docker runner %s before auth or Docker build work starts", |
| 214 | +(_label, envName, value) => { |
| 215 | +const tempDirs: string[] = []; |
| 216 | +const root = makeTempDir(tempDirs, "openclaw-openai-chat-tools-"); |
| 217 | +try { |
| 218 | +const result = runDockerRunnerAuthPreflight(root, { [envName]: value }); |
| 219 | +const output = `${result.stdout}\n${result.stderr}`; |
| 220 | + |
| 221 | +expect(result.status).toBe(2); |
| 222 | +expect(output).toContain(`invalid ${envName}: ${value}`); |
| 223 | +expect(output).not.toContain("OPENAI_API_KEY was not available"); |
| 224 | +expect(output).not.toContain("Building Docker image:"); |
| 225 | +expect(output).not.toContain("Reusing Docker image:"); |
| 226 | +expect(output).not.toContain("Running OpenAI Chat Completions tools Docker E2E"); |
| 227 | +} finally { |
| 228 | +cleanupTempDirs(tempDirs); |
| 229 | +} |
| 230 | +}, |
| 231 | +); |
| 232 | + |
| 233 | +it("passes normalized timeout and body limits into the Docker runner", () => { |
| 234 | +const runner = readFileSync(dockerRunnerPath, "utf8"); |
| 235 | + |
| 236 | +expect(runner).toContain( |
| 237 | +"docker_e2e_read_positive_int_env OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS 180", |
| 238 | +); |
| 239 | +expect(runner).toContain( |
| 240 | +"docker_e2e_read_positive_int_env OPENCLAW_OPENAI_CHAT_TOOLS_MAX_BODY_BYTES 1048576", |
| 241 | +); |
| 242 | +expect(runner).toContain('-e "OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS=$TIMEOUT_SECONDS"'); |
| 243 | +expect(runner).toContain('-e "OPENCLAW_OPENAI_CHAT_TOOLS_MAX_BODY_BYTES=$MAX_BODY_BYTES"'); |
| 244 | +}); |
| 245 | + |
207 | 246 | it("rejects loose timeout env values instead of parsing numeric prefixes", async () => { |
208 | 247 | const result = await runClient(1, { |
209 | 248 | OPENCLAW_OPENAI_CHAT_TOOLS_TIMEOUT_SECONDS: "1e3", |
|