Files
ghbot/test/config-validation.test.ts
T
wdawdwaandClaude Opus 4.8 039acabd96 fix: production hardening for merge races, timeouts, and webhook ops
Pin merge SHA, lock conflict repair, bound subprocess/proxy output,
fail-fast incomplete R2/webhook config, redact validation/stderr
secrets, and document that webhook 202 is best-effort after ACK.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-23 15:44:08 +08:00

47 lines
1.4 KiB
TypeScript

import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import path from "node:path";
import test from "node:test";
function loadConfigWith(overrides: Record<string, string | undefined>) {
const env = { ...process.env };
for (const [key, value] of Object.entries(overrides)) {
if (value === undefined) {
delete env[key];
} else {
env[key] = value;
}
}
return spawnSync(process.execPath, ["--import", "tsx", "--eval", "import('./src/config.ts')"], {
cwd: path.resolve(process.cwd()),
env,
encoding: "utf8"
});
}
test("config rejects enabled webhook without a secret", () => {
const result = loadConfigWith({ WEBHOOK_ENABLED: "true", WEBHOOK_SECRET: "" });
assert.notEqual(result.status, 0);
assert.match(`${result.stdout}${result.stderr}`, /WEBHOOK_SECRET/);
});
test("config rejects partially configured R2 settings", () => {
const result = loadConfigWith({
WEBHOOK_ENABLED: "false",
R2_ENDPOINT: "https://example.r2.cloudflarestorage.com",
R2_BUCKET_NAME: "bucket",
R2_ACCESS_KEY_ID: "",
R2_SECRET_ACCESS_KEY: ""
});
assert.notEqual(result.status, 0);
assert.match(`${result.stdout}${result.stderr}`, /R2_ENDPOINT/);
});
test("config defaults the provider base URL explicitly", () => {
const result = loadConfigWith({
WEBHOOK_ENABLED: "false",
GOOSE_BASE_URL: ""
});
assert.equal(result.status, 0, result.stderr);
});