feat(process): add direct replay machine runner
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
} from "../src/domain/evidenceBundle.js";
|
||||
import { analyzeJavaScriptApplication } from "../src/application/JavaScriptApplicationService.js";
|
||||
import { permissionAuthorityForRoot } from "./fixtures/permissionAuthority.js";
|
||||
import { REPLAY_MACHINE_RUN_EXAMPLE } from "../src/contracts/replayMachineExample.js";
|
||||
|
||||
const execute = promisify(execFile);
|
||||
|
||||
@@ -261,6 +262,65 @@ describe("application workflow CLI parity", () => {
|
||||
},
|
||||
});
|
||||
}, 20_000);
|
||||
|
||||
it("runs a replay machine from inline and file-backed JSON", async () => {
|
||||
const input = REPLAY_MACHINE_RUN_EXAMPLE;
|
||||
const inline = await runCli([
|
||||
"run-replay-machine",
|
||||
JSON.stringify(input),
|
||||
"--json",
|
||||
]);
|
||||
expect(inline).toMatchObject({
|
||||
schema_version: 1,
|
||||
final_state: "complete",
|
||||
decisions: [{ outcome: "matched" }],
|
||||
transition_journal: [
|
||||
{ captured_aliases: [{ name: "token", sensitive: true }] },
|
||||
],
|
||||
});
|
||||
expect(JSON.stringify(inline)).not.toContain("opaque");
|
||||
|
||||
const root = await createTestTempDirectory("rea-replay-machine-cli-");
|
||||
temporary.push(root);
|
||||
const inputPath = join(root, "run.json");
|
||||
await writeFile(inputPath, JSON.stringify(input));
|
||||
const fileBacked = await runCli([
|
||||
"run-replay-machine",
|
||||
inputPath,
|
||||
"--json",
|
||||
]);
|
||||
expect(fileBacked).toEqual(inline);
|
||||
|
||||
const invalid = await runCli([
|
||||
"run-replay-machine",
|
||||
JSON.stringify({
|
||||
machine: input.machine,
|
||||
events: [
|
||||
{
|
||||
protocol: "http",
|
||||
connection: "not_applicable",
|
||||
at_ms: 0,
|
||||
method: null,
|
||||
path: "/callback",
|
||||
headers: {},
|
||||
body: "private-cli-body",
|
||||
},
|
||||
],
|
||||
}),
|
||||
"--json",
|
||||
]);
|
||||
expect(invalid).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
path: ["events", 0, "method"],
|
||||
}),
|
||||
]),
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(invalid)).not.toContain("private-cli-body");
|
||||
}, 20_000);
|
||||
});
|
||||
|
||||
const runCli = async (
|
||||
|
||||
Reference in New Issue
Block a user