mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 22:36:08 +00:00
test(desktop): cover ENOTDIR intermediate path refusal (#8692)
* test(desktop): cover ENOTDIR intermediate path refusal Lock the desktop consumer projection for selections whose intermediate component is a regular file, matching inspect-artifact's unavailable-target refusal after directory source spelling validation. Fixes #7424 * style: oxfmt ArtifactSourceResolution test
This commit is contained in:
1 file changed
+51
@@ -8,6 +8,9 @@ import { assertArtifactFileSelectedSource } from "./ArtifactFileSource.js";
|
||||
import { assertArtifactSelectedSource } from "./ArtifactSelectedSource.js";
|
||||
import { readStableArtifact } from "./readStableArtifact.js";
|
||||
import { DirectoryArtifactReader } from "./DirectoryArtifactReader.js";
|
||||
import { createDesktopApplicationService } from "../composition/desktop.js";
|
||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import { desktopApplicationSchema } from "../domain/desktopApplication.js";
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"admits a caller-selected directory symlink without changing its target identity",
|
||||
@@ -46,6 +49,54 @@ it.skipIf(process.platform === "win32")(
|
||||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"rejects desktop inspection when the selected spelling traverses a regular file",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-desktop-enotdir-intermediate-",
|
||||
);
|
||||
const app = join(root, "Demo.app");
|
||||
await mkdir(app);
|
||||
await writeFile(
|
||||
join(app, "Info.plist"),
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>CFBundleIdentifier</key><string>com.example.demo</string></dict></plist>`,
|
||||
);
|
||||
await writeFile(join(app, "marker.txt"), "marker\n");
|
||||
await writeFile(join(root, "regular"), "regular file\n");
|
||||
const service = createDesktopApplicationService();
|
||||
try {
|
||||
const invalid = await service.inspect({
|
||||
path: `${root}/regular/../Demo.app`,
|
||||
max_entries: 32,
|
||||
max_probe_bytes: 4096,
|
||||
});
|
||||
expect(invalid.ok).toBe(false);
|
||||
if (invalid.ok) throw new Error("expected ENOTDIR refusal");
|
||||
expect(projectAnalysisError(invalid.error)).toMatchObject({
|
||||
code: "target_unavailable",
|
||||
category: "unavailable",
|
||||
});
|
||||
const valid = await service.inspect({
|
||||
path: app,
|
||||
max_entries: 32,
|
||||
max_probe_bytes: 4096,
|
||||
});
|
||||
expect(valid.ok).toBe(true);
|
||||
if (!valid.ok) throw valid.error;
|
||||
expect(
|
||||
desktopApplicationSchema
|
||||
.parse(valid.value.normalized_result)
|
||||
.files.map((file) => file.path)
|
||||
.sort(),
|
||||
).toEqual(["Info.plist", "marker.txt"]);
|
||||
} finally {
|
||||
await service.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"reports a replaced ancestor symlink loop as a changed admitted source",
|
||||
async () => {
|
||||
|
||||
Reference in new issue
Block a user