Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveTenantSnapshotConfig, TenantSnapshotConfigError } from "./env.js";
|
||||
|
||||
describe("resolveTenantSnapshotConfig", () => {
|
||||
it("defaults to encryption=none and no app storage bucket", () => {
|
||||
const cfg = resolveTenantSnapshotConfig({});
|
||||
expect(cfg.encryption.method).toBe("none");
|
||||
expect(cfg.appStorageBucket).toBeNull();
|
||||
expect(cfg.s3.region).toBe("us-east-1");
|
||||
});
|
||||
|
||||
it("rejects an unknown BACKUP_ENCRYPTION value", () => {
|
||||
expect(() => resolveTenantSnapshotConfig({ BACKUP_ENCRYPTION: "rot13" })).toThrow(
|
||||
TenantSnapshotConfigError,
|
||||
);
|
||||
});
|
||||
|
||||
it("requires age key material when encryption=age", () => {
|
||||
expect(() => resolveTenantSnapshotConfig({ BACKUP_ENCRYPTION: "age" })).toThrow(
|
||||
/BACKUP_AGE_PUBLIC_KEY .* BACKUP_AGE_IDENTITY_FILE/u,
|
||||
);
|
||||
expect(() =>
|
||||
resolveTenantSnapshotConfig({
|
||||
BACKUP_ENCRYPTION: "age",
|
||||
BACKUP_AGE_PUBLIC_KEY: "age1xyz",
|
||||
}),
|
||||
).not.toThrow();
|
||||
expect(() =>
|
||||
resolveTenantSnapshotConfig({
|
||||
BACKUP_ENCRYPTION: "age",
|
||||
BACKUP_AGE_IDENTITY_FILE: "/tmp/key.txt",
|
||||
}),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("threads STORAGE_BUCKET and optional prefix through", () => {
|
||||
const cfg = resolveTenantSnapshotConfig({
|
||||
STORAGE_BUCKET: "boilerplate-files",
|
||||
TENANT_SNAPSHOT_STORAGE_PREFIX: "tenants/abc/",
|
||||
});
|
||||
expect(cfg.appStorageBucket).toBe("boilerplate-files");
|
||||
expect(cfg.storagePrefix).toBe("tenants/abc/");
|
||||
});
|
||||
|
||||
it("threads S3 credentials when both id and secret are set", () => {
|
||||
const cfg = resolveTenantSnapshotConfig({
|
||||
BACKUP_S3_ENDPOINT: "https://s3.example.com",
|
||||
BACKUP_S3_REGION: "eu-central-1",
|
||||
BACKUP_S3_FORCE_PATH_STYLE: "true",
|
||||
BACKUP_S3_ACCESS_KEY_ID: "AKIA",
|
||||
BACKUP_S3_SECRET_ACCESS_KEY: "secret",
|
||||
});
|
||||
expect(cfg.s3.endpoint).toBe("https://s3.example.com");
|
||||
expect(cfg.s3.region).toBe("eu-central-1");
|
||||
expect(cfg.s3.forcePathStyle).toBe(true);
|
||||
expect(cfg.s3.credentials).toMatchObject({ accessKeyId: "AKIA", secretAccessKey: "secret" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user