nsecbunkerd/tests
Padreug 14d48ca0f9
Some checks failed
Docker image / build-and-push-image (push) Has been cancelled
fix(acl): hard-reject a lapsed token binding instead of prompting (#36)
A request that finds no live token grant exited `checkIfPubkeyAllowed`
at `undefined` regardless of *why* — whether the binding never existed
or had simply lapsed (expired / token-revoked). `undefined` routes the
caller into the admin-prompt path, which for an unattended client (an
ATM spire) means the request hangs until a BunkerTimeoutError.

The Sintra smoke proved the divergence directly: a KeyUser-level revoke
exits at step 2 with `false` and the spire sees a clean BunkerRejected
("Pairing Required"), but a TTL expiry fell through to `undefined` and
the spire saw a BunkerTimeout ("Signer Unreachable") — same operator
intent ("this pairing is over"), two different, one-broken outcomes.

Classify the no-live-grant case before returning: if a token bound to
this KeyUser *would* have granted the request (its policy carries a
matching rule; for `connect`, any bound token) but is now expired or
token-revoked, return `false` so the client re-pairs immediately. Only
a genuinely never-granted (method/kind) request stays `undefined` so an
admin can still approve new permission out-of-band.

Usage-cap exhaustion is left at `undefined` deliberately: a windowed
cap is a temporary rate-limit that refills as the window rolls, not a
permanent lapse, so it must not be reclassed as the re-pair signal. A
dedicated rate-limit reply is a separate follow-up.

Tests: the #24 expired-token and token-revoke guards now assert `false`;
added connect-lapse, and two distinction cases proving a never-granted
method (live token, or a method the lapsed token never covered) stays
`undefined`.
2026-06-21 12:44:36 +02:00
..
acl.integration.test.ts fix(acl): hard-reject a lapsed token binding instead of prompting (#36) 2026-06-21 12:44:36 +02:00
lifecycle.test.ts test(acl)(#25): extract pure grantIsLive/liveWhere + unit tests 2026-06-19 15:16:37 +02:00
register-ts.cjs test(acl)(#29): DB-backed integration tests for checkIfPubkeyAllowed 2026-06-19 21:09:41 +00:00