Files
pom-omp/tests/events.test.ts

16 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { shouldBlockProjectCommand } from "../src/policy";
test("destructive-command policy blocks recursive deletion from or against project root", () => {
const root = "/work/clockwork-sea";
assert.equal(shouldBlockProjectCommand("rm -rf .", root, "clockwork-sea", root), true);
assert.equal(shouldBlockProjectCommand("rm --recursive --force \"$PWD\"", root, "clockwork-sea", root), true);
assert.equal(shouldBlockProjectCommand("find . -delete", root, "clockwork-sea", root), true);
assert.equal(shouldBlockProjectCommand("git reset --hard HEAD~1", root, "clockwork-sea", root), true);
assert.equal(shouldBlockProjectCommand("Remove-Item -Recurse -Force .", root, "clockwork-sea", root), true);
assert.equal(shouldBlockProjectCommand("rm -rf /tmp/scratch", root, "clockwork-sea", "/tmp"), false);
assert.equal(shouldBlockProjectCommand("rm -rf /work/clockwork-sea", root, "clockwork-sea", "/tmp"), true);
assert.equal(shouldBlockProjectCommand("rm notes.txt", root, "clockwork-sea", root), false);
});