Add a DB-backed test harness + integration tests for checkIfPubkeyAllowed #29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
#27 ships
node:testunit coverage of the pure lifecycle predicate (lib/acl/lifecycle.ts:grantIsLive/liveWhere), but the gatekeeper wiring (checkIfPubkeyAllowed) has no automated test — verifying it needs a real DB. This issue tracks adding a proper test harness and the integration cases.Why #27 stopped at unit tests
There is no test runner in the repo, and
pnpm add -D vitestfails against the nix-builtnode_modules:A full
pnpm installto recreatenode_moduleswas too disruptive to do mid-PR. The.js-extension ESM-style imports under a CommonJS tsconfig also block a quickts-node-only integration path ('../../../db.js'won't resolve todb.ts). So #27 extracted the pure predicate to make something testable without a DB, and deferred the rest here.Proposed work
vitest(configureresolve.extensionAlias: { '.js': ['.ts', '.js'] }to handle the extension-ful imports), or settle on another runner that copes with the CommonJS +.js-specifier setup. Wire it into CI (.github/workflows) and the nix build so the prisma engine env is present.globalSetupcreates a throwaway sqlite file +prisma db push; tests seedKeyUser/Token/Policy/PolicyRule/SigningConditiondirectly.checkIfPubkeyAllowed(the wiring #27 couldn't assert):sign_eventallowedsign_event→undefined(the #24 regression guard)sign_event→undefinedconnect→ allowed; expired token →connect→undefinedKeyUser.revokedAtset → any method →falseSigningConditiongrant →true; expired/revoked override → ignored (falls through)SigningConditiondeny (method-specific) →false(denials beat grants)KeyUser→undefinedKeyUser ← Tokenbinding and noSigningConditionrows (guards against the photocopy regressing).Notes
PRISMA_QUERY_ENGINE_LIBRARYetc.) — see the related devshell issue; the harness must inherit it.prisma migrate/validatein the dev shell #30