radroots_sdk_boundary_inventory.test.mjs (1734B)
1 import assert from "node:assert/strict"; 2 import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; 3 import { tmpdir } from "node:os"; 4 import { dirname, join } from "node:path"; 5 import test from "node:test"; 6 7 import { 8 GENERATED_FILES, 9 validateProductionSources, 10 validateTrackedInventory, 11 } from "./radroots_sdk_boundary_lib.mjs"; 12 13 test("generated source inventory is exact", () => { 14 assert.doesNotThrow(() => validateTrackedInventory(GENERATED_FILES)); 15 assert.throws( 16 () => validateTrackedInventory(GENERATED_FILES.slice(1)), 17 /generated source inventory is not exact/, 18 ); 19 assert.throws( 20 () => validateTrackedInventory([...GENERATED_FILES, "generated/extra.ts"]), 21 /generated source inventory is not exact/, 22 ); 23 }); 24 25 test("both native language artifacts retain their complete data notice", () => { 26 for (const language of ["swift", "kotlin"]) { 27 assert.throws( 28 () => validateTrackedInventory(GENERATED_FILES.filter((path) => path !== `generated/${language}/NOTICE`)), 29 /generated source inventory is not exact/, 30 ); 31 } 32 }); 33 34 test("tracked credential paths fail closed", () => { 35 assert.throws( 36 () => validateTrackedInventory([...GENERATED_FILES, "packages/core/.env"]), 37 /sensitive credential path is tracked/, 38 ); 39 }); 40 41 test("production credential material fails closed", () => { 42 const root = mkdtempSync(join(tmpdir(), "radroots-sdk-boundary-")); 43 const path = "packages/core/src/index.ts"; 44 mkdirSync(dirname(join(root, path)), { recursive: true }); 45 writeFileSync(join(root, path), `export const leaked = "AKIAABCDEFGHIJKLMNOP";\n`); 46 assert.throws( 47 () => validateProductionSources(root, [path]), 48 /production source contains credential material/, 49 ); 50 });