repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by admin
extensions/strata/__tests__/protected-path.property.test.ts
Rawimport { describe, it } from "vitest";
import { assertProperty, fc } from "../../../test/property.ts";
import { isProtectedPath } from "../git.ts";
const segment = fc
.array(fc.constantFrom(..."abcdefghij0123456789._-".split("")), {
minLength: 1,
maxLength: 10,
})
.map((chars) => chars.join(""));
// `.git` and `.ssh` are protected anywhere in the path, in any case.
const anywhereMarker = fc.constantFrom(".git", ".GIT", ".Git", ".ssh", ".SSH");
describe("isProtectedPath (property)", () => {
it("keeps a sensitive directory protected under any surrounding path and case", () => {
assertProperty(
import.meta.url,
"protected directories stay protected",
fc.property(
fc.array(segment, { maxLength: 3 }),
fc.array(segment, { maxLength: 3 }),
anywhereMarker,
(before, after, marker) => {
const path = [...before, marker, ...after].join("/");
return isProtectedPath(path) === true;
},
),
);
});
});