Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/config/src/gdpr-export-storage.test.ts
T

24 lines
889 B
TypeScript

import { describe, expect, it } from "vitest";
import { normalizeGdprExportSseCKey, requireGdprExportSseCKey } from "./gdpr-export-storage.js";
const KEY = "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc=";
describe("GDPR export SSE-C key", () => {
it("accepts only canonical base64 encoding of exactly 32 bytes", () => {
expect(normalizeGdprExportSseCKey(` ${KEY} `)).toBe(KEY);
expect(normalizeGdprExportSseCKey(Buffer.alloc(31, 7).toString("base64"))).toBeUndefined();
expect(normalizeGdprExportSseCKey("not-base64")).toBeUndefined();
});
it("never echoes an invalid key", () => {
const invalid = "secret-that-must-not-appear";
expect(() => requireGdprExportSseCKey(invalid)).toThrow(/GDPR_EXPORT_SSE_C_KEY_BASE64/u);
try {
requireGdprExportSseCKey(invalid);
} catch (error) {
expect(String(error)).not.toContain(invalid);
}
});
});