@stratum-hq/test-utils
@stratum-hq/test-utils provides test helpers that verify tenant isolation is working correctly. Use these in your CI pipeline to catch isolation regressions before they reach production.
Installation
Section titled “Installation”npm install -D @stratum-hq/test-utilsQuick start
Section titled “Quick start”import { assertIsolation, assertConfigInheritance } from "@stratum-hq/test-utils";
describe("tenant isolation", () => { it("tenantA cannot read tenantB data", async () => { // Connect `pool` as your application's role; a superuser ignores RLS. await assertIsolation(pool, tenantAId, tenantBId, "orders"); });
it("config inherits and locks down the tree", async () => { // `stratum` is a Stratum instance from @stratum-hq/lib. await assertConfigInheritance(stratum, parentId, childId, "test.inheritance_key"); });});Features
Section titled “Features”assertIsolation(pool, tenantA, tenantB, table, options?): inserts a row as tenantB, checks tenantB can read it back, and asserts tenantA cannot, then rolls backassertMongoIsolation(getCollection, tenantA, tenantB): the same check for MongoDB, through the collection your Stratum adapter or Mongoose plugin returns for a tenantassertConfigInheritance(stratum, parentId, childId, key): verifies inheritance, child override and parent locks through Stratum’s config API- Descriptive error messages: clear failure output showing exactly which isolation boundary was breached
- PostgreSQL and MongoDB: there is no MySQL helper yet