test: cover admin gating for upload and scan
This commit is contained in:
@@ -6,3 +6,25 @@ test("imports POST rejects when missing admin token", async () => {
|
|||||||
expect(res.status).toBe(401);
|
expect(res.status).toBe(401);
|
||||||
expect(res.body).toEqual({ error: "admin_required" });
|
expect(res.body).toEqual({ error: "admin_required" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("imports upload rejects when missing admin token", async () => {
|
||||||
|
const { handleUploadImport } = await import("../../app/api/imports/handlers");
|
||||||
|
const res = await handleUploadImport({
|
||||||
|
adminOk: false,
|
||||||
|
params: { id: "00000000-0000-0000-0000-000000000000" },
|
||||||
|
request: new Request("http://localhost/upload"),
|
||||||
|
});
|
||||||
|
expect(res.status).toBe(401);
|
||||||
|
expect(res.body).toEqual({ error: "admin_required" });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("imports scan rejects when missing admin token", async () => {
|
||||||
|
const { handleScanMinioImport } = await import("../../app/api/imports/handlers");
|
||||||
|
const res = await handleScanMinioImport({
|
||||||
|
adminOk: false,
|
||||||
|
params: { id: "00000000-0000-0000-0000-000000000000" },
|
||||||
|
body: {},
|
||||||
|
});
|
||||||
|
expect(res.status).toBe(401);
|
||||||
|
expect(res.body).toEqual({ error: "admin_required" });
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user