test(acl): DB-backed integration tests for checkIfPubkeyAllowed (#29) #33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-29-acl-integration-tests"
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?
Closes #29. Fills the testing gap the #27 review flagged: the wiring that actually closes #24 — step-4
Tokenjoin filtered byliveWhere(now)— had no automated coverage; only the pure predicate (grantIsLive) was tested. Now covered end-to-end against a real (throwaway) SQLite DB + the real prisma client.Harness (no new dependency)
pnpm add -D vitestis blocked by the nix-builtnode_moduleshoist pattern (#29 background), so this stays on Node's built-innode:test+ the already-presentts-node:tests/register-ts.cjs— registers ts-node (transpile-only) and adds a CommonJS resolver that maps the app's.jsESM-style import specifiers to their.tssources (the app isimport x from './y.js', compiled by tsup; there's noy.json disk). This is what lets a testrequirethe realacl/dbmodules without a build or bundler.prisma db pushinbefore(), with a hard guard that refuses to run unlessDATABASE_URLpoints attests/.tmp/— these tests truncate tables, so they can never touch a real DB.npm run test:integration,npm run test:all(unit + integration).Coverage — 13 cases, all green
incl. the #24 regression guard (
expired token → denied), plus revoked token,connectoff a live token (and denied when expired),KeyUser.revokedAtbeats a live token, live override grant, expired/revoked override ignored (falls through), deny beats grant, kind mismatch, and no-KeyUser.Also
acl/index.tsNDK import →import type(NostrEvent/NIP46Methodare type-only) so the ACL module no longer pulls ESM-only NDK at runtime. Required for the CommonJS test import, and a correct cleanup on its own (the gatekeeper shouldn't need the NDK runtime).Notes
PRISMA_QUERY_ENGINE_LIBRARYetc.). Present in CI/nix; in the devShell it's pending #30 (which currently exports 7.x). Until #30 lands, run with the engine env pinned toprisma-engines_6.tsc --noEmitunchanged (3 pre-existing, unrelated errors);npm run buildclean.Wiring CI to run
test:allcan ride in #30 (engine env) or a small follow-up.🤖 Generated with Claude Code
Correction to the "Notes" section above: the devShell-pending-#30 caveat is wrong — I'd misdiagnosed #30 (now closed as invalid).
The flake pins nixos-25.05, whose
prisma-enginesis 6.7.0 (shipslibquery_engine.node), so the integration suite runs in the devShell out of the box, no manual engine env:The 7.x I hit during #27 was the system/unstable channel via
<nixpkgs>, never the flake's devShell. So this PR has no #30 dependency —nix develop -c npm run test:alljust works, which also makes it straightforward to wire into CI later (the one real blocker there is the stale lockfile, #2).