mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 10:06:07 +00:00
fix(cli): bound exec approvals stdin
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// Exec approvals CLI tests cover approval command registration and output handling.
|
||||
import { Readable } from "node:stream";
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import * as execApprovals from "../infra/exec-approvals.js";
|
||||
import type { ExecApprovalsFile } from "../infra/exec-approvals.js";
|
||||
import { registerExecApprovalsCli } from "./exec-approvals-cli.js";
|
||||
import { registerExecApprovalsCli, testing } from "./exec-approvals-cli.js";
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
const runtimeErrors: string[] = [];
|
||||
@@ -560,4 +561,11 @@ describe("exec approvals CLI", () => {
|
||||
});
|
||||
expect(runtimeErrors).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("bounds approvals JSON read from stdin", async () => {
|
||||
await expect(testing.readStdin(Readable.from(["12345"]), 5)).resolves.toBe("12345");
|
||||
await expect(testing.readStdin(Readable.from(["12345", "6"]), 5)).rejects.toThrow(
|
||||
"Exec approvals stdin exceeds 5 bytes.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user