Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { EnvRecord } from "@hivegrid/config";
|
||||
|
||||
import { createWorkerScanService, type ScanServiceEnv } from "./scanService.js";
|
||||
|
||||
// createWorkerScanService takes `EnvRecord & ScanServiceEnv`; EnvRecord adds the
|
||||
// index signature that a bare ScanServiceEnv interface lacks, so widen the fixture.
|
||||
function fullEnv(overrides: Partial<ScanServiceEnv> = {}): EnvRecord & ScanServiceEnv {
|
||||
return {
|
||||
STORAGE_REGION: "eu-central-1",
|
||||
STORAGE_ACCESS_KEY_ID: "AKIA_TEST",
|
||||
STORAGE_SECRET_ACCESS_KEY: "secret_test",
|
||||
STORAGE_ENDPOINT: "https://s3.example.test",
|
||||
STORAGE_QUARANTINE_BUCKET: "quarantine",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("createWorkerScanService — missing-credential guards", () => {
|
||||
it("returns undefined when STORAGE_REGION is absent", () => {
|
||||
expect(createWorkerScanService(fullEnv({ STORAGE_REGION: undefined }))).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined when STORAGE_ACCESS_KEY_ID is absent", () => {
|
||||
expect(createWorkerScanService(fullEnv({ STORAGE_ACCESS_KEY_ID: undefined }))).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined when STORAGE_SECRET_ACCESS_KEY is absent", () => {
|
||||
expect(createWorkerScanService(fullEnv({ STORAGE_SECRET_ACCESS_KEY: undefined }))).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns undefined on a completely empty env", () => {
|
||||
expect(createWorkerScanService({})).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("createWorkerScanService — wiring", () => {
|
||||
it("constructs a scan service when all credentials are present", () => {
|
||||
const service = createWorkerScanService(fullEnv());
|
||||
expect(service).toBeDefined();
|
||||
expect(service?.scanObject).toBeTypeOf("function");
|
||||
});
|
||||
|
||||
it("constructs with explicit ClamAV + path-style overrides", () => {
|
||||
// Exercises the non-default branches: numeric port/timeout parsing and
|
||||
// STORAGE_FORCE_PATH_STYLE === "true".
|
||||
const service = createWorkerScanService(
|
||||
fullEnv({
|
||||
CLAMAV_HOST: "clamav.internal",
|
||||
CLAMAV_PORT: "9000",
|
||||
CLAMAV_TIMEOUT_MS: "5000",
|
||||
STORAGE_FORCE_PATH_STYLE: "true",
|
||||
STORAGE_SESSION_TOKEN: "session-token",
|
||||
})
|
||||
);
|
||||
expect(service).toBeDefined();
|
||||
expect(service?.scanObject).toBeTypeOf("function");
|
||||
});
|
||||
|
||||
it("constructs with ClamAV defaults when host/port/timeout are unset", () => {
|
||||
const service = createWorkerScanService(
|
||||
fullEnv({ CLAMAV_HOST: undefined, CLAMAV_PORT: undefined, CLAMAV_TIMEOUT_MS: undefined })
|
||||
);
|
||||
expect(service).toBeDefined();
|
||||
expect(service?.scanObject).toBeTypeOf("function");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user