mirror of
https://github.com/morluto/rea.git
synced 2026-11-03 13:26:10 +00:00
* test: strengthen integration oracles and verification * test: bound lifecycle gates and strengthen workflow checks * test: verify complete paged and extracted results * test: preserve bytecode and cancellation evidence * test: strengthen retained evidence and fixture cleanup * test: require cross-projection bridge identities * test: retain fixture owners through cleanup failures * test: verify graph examples and project selectors * test: tighten provider and lifecycle regressions * test: consolidate hex coverage and bound cutter cleanup * test: bound subprocess output waits and strengthen graph checks * test: check mcp recovery and preserve cleanup owners * test: verify structured mcp argument failures * test: preserve artifact cleanup and gdb limit evidence * test: preserve evidence identities and bound provider gates * test: retain browser and comparison cleanup owners * test: bound startup and strengthen fixture oracles * test: bound lifecycle gates and verify recovered evidence * test: verify public outcomes and lifecycle ownership * test: assert precise evidence and release lifecycle gates * test: verify selected facts and bound cleanup waits * test: check retained evidence and decoded records * test: verify final reports and retain cleanup ownership * test: bound reviewed startup gates and retain cleanup * test: verify PE errors and preserve MCP cleanup * test: preserve MCP fixture cleanup ownership * test: release provider gates before late startup
95 lines
2.6 KiB
TypeScript
95 lines
2.6 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { ZodError } from "zod";
|
|
import { parsePacketOutput } from "../../../src/captures/parsePacketOutput.js";
|
|
import { AnalysisOutputError } from "../../../src/domain/analysisErrorCore.js";
|
|
|
|
it("preserves repeated field values and missing fields while discarding export index metadata", () => {
|
|
const output = JSON.stringify([
|
|
{
|
|
_index: "packets-2026",
|
|
_score: null,
|
|
_source: {
|
|
layers: {
|
|
"frame.number": ["2"],
|
|
"ip.addr": ["192.0.2.1", "192.0.2.2"],
|
|
},
|
|
},
|
|
},
|
|
{ _source: { layers: { "frame.number": ["7"] } } },
|
|
]);
|
|
expect(parsePacketOutput(output)).toEqual([
|
|
{ "frame.number": ["2"], "ip.addr": ["192.0.2.1", "192.0.2.2"] },
|
|
{ "frame.number": ["7"] },
|
|
]);
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
layers: { "ip.addr": ["192.0.2.1"] },
|
|
issue: {
|
|
code: "invalid_type",
|
|
path: [0, "_source", "layers", "frame.number"],
|
|
},
|
|
},
|
|
{
|
|
layers: { "frame.number": ["1"], "ip.addr": "192.0.2.1" },
|
|
issue: { code: "invalid_type", path: [0, "_source", "layers", "ip.addr"] },
|
|
},
|
|
{
|
|
layers: { "frame.number": ["0"] },
|
|
issue: {
|
|
code: "invalid_format",
|
|
path: [0, "_source", "layers", "frame.number", 0],
|
|
},
|
|
},
|
|
{
|
|
layers: { "frame.number": ["1", "2"] },
|
|
issue: { code: "too_big", path: [0, "_source", "layers", "frame.number"] },
|
|
},
|
|
])("rejects malformed producer fields: $layers", ({ layers, issue }) => {
|
|
let failure: unknown;
|
|
try {
|
|
parsePacketOutput(JSON.stringify([{ _source: { layers } }]));
|
|
} catch (error) {
|
|
failure = error;
|
|
}
|
|
expect(failure).toBeInstanceOf(ZodError);
|
|
if (!(failure instanceof ZodError)) throw failure;
|
|
expect(failure.issues).toEqual(
|
|
expect.arrayContaining([expect.objectContaining(issue)]),
|
|
);
|
|
});
|
|
|
|
it.each([
|
|
[["2"], ["2"]],
|
|
[["2"], ["1"]],
|
|
])("rejects repeated or reordered producer frames: %j then %j", (...frames) => {
|
|
let failure: unknown;
|
|
try {
|
|
parsePacketOutput(
|
|
JSON.stringify(
|
|
frames.map((frame) => ({
|
|
_source: { layers: { "frame.number": frame } },
|
|
})),
|
|
),
|
|
);
|
|
} catch (error) {
|
|
failure = error;
|
|
}
|
|
expect(failure).toBeInstanceOf(AnalysisOutputError);
|
|
expect(failure).toMatchObject({ operation: "inspect_packet_capture" });
|
|
});
|
|
|
|
it("preserves canonical field names emitted for a selected alias", () => {
|
|
const output = JSON.stringify([
|
|
{
|
|
_source: {
|
|
layers: { "frame.number": ["1"], "dhcp.type": ["1"] },
|
|
},
|
|
},
|
|
]);
|
|
expect(parsePacketOutput(output)).toEqual([
|
|
{ "frame.number": ["1"], "dhcp.type": ["1"] },
|
|
]);
|
|
});
|