Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { resolveStateDir } from "../config/paths.js";
import { assertLocalMediaAllowed } from "./local-media-access.js";
describe("assertLocalMediaAllowed", () => {
it("allows managed inbound media paths before explicit root checks", async () => {
const stateDir = resolveStateDir();
const id = `managed-local-${Date.now()}-${Math.random().toString(36).slice(2)}.png`;
const filePath = path.join(stateDir, "media", "inbound", id);
await fs.mkdir(path.dirname(filePath), { recursive: true });
await fs.writeFile(filePath, Buffer.from("png"));
try {
await expect(assertLocalMediaAllowed(filePath, [])).resolves.toBeUndefined();
} finally {
await fs.rm(filePath, { force: true });
}
});
it("does not allow nested inbound paths as managed media", async () => {
const stateDir = resolveStateDir();
const filePath = path.join(stateDir, "media", "inbound", "nested", "hidden.png");
await fs.mkdir(path.dirname(filePath), { recursive: true });
await fs.writeFile(filePath, Buffer.from("png"));
try {
await expect(assertLocalMediaAllowed(filePath, [])).rejects.toMatchObject({
code: "path-not-allowed",
});
} finally {
await fs.rm(path.dirname(filePath), { recursive: true, force: true });
}
});
});
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-04-27)
¤
*© Formatika GbR, Deutschland