import assert from "node:assert/strict"; import test from "node:test"; import { HeadBucketCommand } from "@aws-sdk/client-s3"; import { checkFileStorage } from "../src/modules/system-status.service"; test("file storage health uses an authenticated S3 bucket request for every provider", async () => { const client = { send: async (command: any, options: any) => { assert.ok(command instanceof HeadBucketCommand); assert.deepEqual(command.input, { Bucket: "fedeo" }); assert.ok(options.abortSignal instanceof AbortSignal); } }; assert.equal((await checkFileStorage(client, "fedeo")).ok, true); }); test("unconfigured or denied S3 access is unhealthy and does not disclose SDK details", async () => { assert.equal((await checkFileStorage(null, "fedeo")).ok, false); const result = await checkFileStorage({ send: async () => { throw new Error("secret@private-host"); } }, "fedeo"); assert.equal(result.ok, false); assert.ok(!JSON.stringify(result).includes("private-host")); }); test("S3 health aborts a hung request at its deadline", async () => { const client = { send: (_command: any, options: any) => new Promise((_resolve, reject) => { options.abortSignal.addEventListener("abort", () => reject(new Error("aborted")), { once: true }); }) }; const result = await checkFileStorage(client, "fedeo", 10); assert.equal(result.ok, false); assert.match(result.error, /Zeitlimit/); });