mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:28:26 +00:00
refactor: unify exec wrapper resolution and parity fixtures
This commit is contained in:
@@ -53,6 +53,16 @@ type ShellParserParityFixture = {
|
||||
cases: ShellParserParityFixtureCase[];
|
||||
};
|
||||
|
||||
type WrapperResolutionParityFixtureCase = {
|
||||
id: string;
|
||||
argv: string[];
|
||||
expectedRawExecutable: string | null;
|
||||
};
|
||||
|
||||
type WrapperResolutionParityFixture = {
|
||||
cases: WrapperResolutionParityFixtureCase[];
|
||||
};
|
||||
|
||||
function loadShellParserParityFixtureCases(): ShellParserParityFixtureCase[] {
|
||||
const fixturePath = path.join(
|
||||
process.cwd(),
|
||||
@@ -64,6 +74,19 @@ function loadShellParserParityFixtureCases(): ShellParserParityFixtureCase[] {
|
||||
return fixture.cases;
|
||||
}
|
||||
|
||||
function loadWrapperResolutionParityFixtureCases(): WrapperResolutionParityFixtureCase[] {
|
||||
const fixturePath = path.join(
|
||||
process.cwd(),
|
||||
"test",
|
||||
"fixtures",
|
||||
"exec-wrapper-resolution-parity.json",
|
||||
);
|
||||
const fixture = JSON.parse(
|
||||
fs.readFileSync(fixturePath, "utf8"),
|
||||
) as WrapperResolutionParityFixture;
|
||||
return fixture.cases;
|
||||
}
|
||||
|
||||
describe("exec approvals allowlist matching", () => {
|
||||
const baseResolution = {
|
||||
rawExecutable: "rg",
|
||||
@@ -447,6 +470,17 @@ describe("exec approvals shell parser parity fixture", () => {
|
||||
}
|
||||
});
|
||||
|
||||
describe("exec approvals wrapper resolution parity fixture", () => {
|
||||
const fixtures = loadWrapperResolutionParityFixtureCases();
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
it(`matches wrapper fixture: ${fixture.id}`, () => {
|
||||
const resolution = resolveCommandResolutionFromArgv(fixture.argv);
|
||||
expect(resolution?.rawExecutable ?? null).toBe(fixture.expectedRawExecutable);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("exec approvals shell allowlist (chained commands)", () => {
|
||||
it("evaluates chained command allowlist scenarios", () => {
|
||||
const cases: Array<{
|
||||
|
||||
Reference in New Issue
Block a user