release: WRNexusJS 0.8.0
Quality / quality (ubuntu-latest) (push) Failing after 21s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-02 23:18:51 +05:30
parent 87507edf59
commit 586a6db8ff
625 changed files with 243608 additions and 11210 deletions
+27
View File
@@ -61,3 +61,30 @@ test("signed file tokens reject tampering and expired payloads", async () => {
expect(await verifySignedFileToken(`${token}x`, secret, 1_000)).toBeNull();
expect(await verifySignedFileToken(token, secret, 2_000)).toBeNull();
});
test("upload scanning rejects unsafe bytes before storage", async () => {
const form = new FormData();
form.set("file", new File(["virus"], "bad.txt", { type: "text/plain" }));
await expect(
upload("public", new Request("http://test/upload", { method: "POST", body: form }), {
scan: async () => ({ safe: false, scanner: "test-av", reason: "signature" }),
}),
).rejects.toMatchObject({ status: 422 });
expect(await getStore("public").driver.get("bad.txt")).toBeNull();
});
test("post-storage processor failure rolls back the object", async () => {
const form = new FormData();
form.set("file", new File(["image"], "photo.png", { type: "image/png" }));
let key = "";
await expect(
upload("public", new Request("http://test/upload", { method: "POST", body: form }), {
afterStore(file) {
key = file.key;
throw new Error("transform failed");
},
}),
).rejects.toMatchObject({ status: 422 });
expect(key).not.toBe("");
expect(await getStore("public").driver.get(key)).toBeNull();
});