mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
test(ida): preserve physical workspace traversal controls
This commit is contained in:
+27
-23
@@ -1,4 +1,4 @@
|
||||
import { mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
@@ -16,28 +16,32 @@ afterEach(async () => {
|
||||
for (const root of roots.splice(0))
|
||||
await rm(root, { recursive: true, force: true });
|
||||
});
|
||||
it("uses the allocation normalization for readiness without creating entries", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "rea-ida-workspace-parent-"));
|
||||
roots.push(root);
|
||||
const path = join(root, "registration.json");
|
||||
const rawRoot = `${root}/missing/..`;
|
||||
await writeFile(
|
||||
path,
|
||||
JSON.stringify({
|
||||
command: "python",
|
||||
mode: "headless",
|
||||
workspaceRoot: rawRoot,
|
||||
}),
|
||||
);
|
||||
const before = await readdir(root);
|
||||
const inspection = await inspectIdaRegistration(path, resourceScope);
|
||||
const after = await readdir(root);
|
||||
expect(inspection.available).toBe(true);
|
||||
expect(
|
||||
inspection.checks.find(({ name }) => name === "private_workspace")?.detail,
|
||||
).toContain(rawRoot);
|
||||
expect(after).toEqual(before);
|
||||
});
|
||||
it.each([true, false])(
|
||||
"uses allocation filesystem resolution without creating entries (traversed directory exists=%s)",
|
||||
async (exists) => {
|
||||
const root = await mkdtemp(join(tmpdir(), "rea-ida-workspace-parent-"));
|
||||
roots.push(root);
|
||||
const path = join(root, "registration.json");
|
||||
await mkdir(join(root, "existing"));
|
||||
const rawRoot = exists ? `${root}/existing/..` : `${root}/missing/..`;
|
||||
await writeFile(
|
||||
path,
|
||||
JSON.stringify({
|
||||
command: "python",
|
||||
mode: "headless",
|
||||
workspaceRoot: rawRoot,
|
||||
}),
|
||||
);
|
||||
const before = await readdir(root);
|
||||
const inspection = await inspectIdaRegistration(path, resourceScope);
|
||||
const after = await readdir(root);
|
||||
expect(inspection.available).toBe(exists);
|
||||
expect(
|
||||
inspection.checks.find(({ name }) => name === "private_workspace")?.detail,
|
||||
).toContain(rawRoot);
|
||||
expect(after).toEqual(before);
|
||||
},
|
||||
);
|
||||
|
||||
it("marks an unusable system temporary parent unavailable when workspaceRoot is omitted", async () => {
|
||||
if (process.platform === "win32") return;
|
||||
|
||||
@@ -42,9 +42,9 @@ cliTest.skipIf(process.platform !== "darwin").for([true, false])(
|
||||
const root = await createTestTempDirectory("rea-ida-doctor-parent-");
|
||||
const parent = join(root, "parent");
|
||||
await mkdir(parent);
|
||||
// Keep the caller's unnormalized spelling; allocation normalizes it too.
|
||||
// Keep the caller's spelling while every traversed component exists.
|
||||
const workspaceRoot = usable
|
||||
? `${parent}/missing/../.`
|
||||
? `${parent}/./`
|
||||
: join(parent, "absent");
|
||||
const registration = join(root, "registration.json");
|
||||
await writeFile(
|
||||
|
||||
Reference in New Issue
Block a user