test: dedupe repeated validation and throw assertions

This commit is contained in:
Peter Steinberger
2026-02-21 23:21:35 +00:00
parent 01ec832f78
commit 98790339ef
4 changed files with 49 additions and 26 deletions

View File

@@ -21,10 +21,10 @@ import type { SessionEntry } from "./types.js";
describe("session path safety", () => {
it("rejects unsafe session IDs", () => {
expect(() => validateSessionId("../etc/passwd")).toThrow(/Invalid session ID/);
expect(() => validateSessionId("a/b")).toThrow(/Invalid session ID/);
expect(() => validateSessionId("a\\b")).toThrow(/Invalid session ID/);
expect(() => validateSessionId("/abs")).toThrow(/Invalid session ID/);
const unsafeSessionIds = ["../etc/passwd", "a/b", "a\\b", "/abs"];
for (const sessionId of unsafeSessionIds) {
expect(() => validateSessionId(sessionId), sessionId).toThrow(/Invalid session ID/);
}
});
it("resolves transcript path inside an explicit sessions dir", () => {