mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
- mitm-handler-base: hookBufferStart returns InterceptedRequest with sanitized headers, extractSourceModel parses body.model, writeError emits JSON with sanitized message (Hard Rule #12). - mitm-handler-<id>: nine per-agent happy-path tests (antigravity, kiro, copilot, codex, cursor, zed, claude-code, open-code) exercise full intercept() with mocked fetch via _mitmHandlerHarness.ts; asserts mapped model is forwarded and AgentBridge correlation headers are present. Trae test confirms intercept() rejects with a structured error. - mitm-targets-resolve: ALL_TARGETS contains 9 entries; resolveTarget is case-insensitive and returns null for unknown hosts. - mitm-targets-route: bypass > target > passthrough precedence validated against representative hostnames. - mitm-detection: DETECTORS covers every AgentId; detectAgent never throws and returns DetectionResult-shaped objects for all probes.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { AntigravityHandler } from "../../src/mitm/handlers/antigravity.ts";
|
|
import { runHandler } from "./_mitmHandlerHarness.ts";
|
|
|
|
test("antigravity handler — forwards to OmniRoute and pipes SSE", async () => {
|
|
const r = await runHandler(
|
|
new AntigravityHandler(),
|
|
{ model: "gpt-4o", messages: [{ role: "user", content: "hi" }] },
|
|
"claude-3.5-sonnet",
|
|
{ upstreamBody: "data: hello\n\ndata: world\n\n" }
|
|
);
|
|
assert.ok(r.fetchCalled);
|
|
assert.equal(r.status, 200);
|
|
assert.ok(r.responseChunks.join("").includes("hello"));
|
|
});
|
|
|
|
test("antigravity handler — propagates upstream failure as 500", async () => {
|
|
const r = await runHandler(
|
|
new AntigravityHandler(),
|
|
{ model: "gpt-4o" },
|
|
"claude-3.5-sonnet",
|
|
{ upstreamStatus: 500, upstreamBody: "boom" }
|
|
);
|
|
assert.equal(r.status, 500);
|
|
const body = r.responseChunks.join("");
|
|
// Error must NOT include raw stack trace (Hard Rule #12 sanitization).
|
|
assert.ok(!body.includes("at /"));
|
|
});
|