Conversation
added 3 commits
August 28, 2026 01:48
JwtStrategy had no unit coverage, and the behaviour the database re-read exists for -- a deleted or demoted user losing access on the next request rather than at token expiry -- was untested end to end. - unit: JwtStrategy.validate lookup, returned shape, database role winning over the token claim, and rejection when the user is gone - e2e: GET /auth/me, a still-unexpired token whose user was deleted, and a role change taking effect without re-issuing the token
The role-change test relied on a comment to establish that the token still said "viewer". Decode and assert it, so a 201 can only mean the guard used the freshly-read database role.
The create conflict tests passed a payload with no versions, so the 23505 they mocked could not have occurred for that input -- service names carry no unique constraint. The payload now repeats a version name, which is the only unique constraint a create can trip, and the message is asserted so it stays pointed at versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while reviewing coverage on the auth layer after submission. No production code changes — tests only.
The gap
JwtStrategyhad 0% unit coverage, and more importantly the behaviour that its design exists for was untested anywhere:That is the main argument for accepting a per-request database read — and nothing demonstrated it.
What's added
Unit —
src/auth/strategies/jwt.strategy.spec.tsrequest.user, withoutpasswordHashE2E —
test/services.e2e-spec.tsGET /auth/mereturns the caller (endpoint previously had no coverage)That last one logs in as a viewer, gets
403on a write, promotes the user to admin in the database, then reuses the same token — which still carries"role":"viewer"— and gets201.Coverage
jwt.strategy.tsjwt-auth.guard.tsremains at 0% unit coverage. Its@Public()branch is exercised end to end by every login, so I left it rather than write a test that only restates the guard's implementation.Suites
45unit (was 41) ·59e2e (was 55). Lint clean.