Skip to content

test : added vitest unit tests for rlsContext middleware#1872

Open
tmdeveloper007 wants to merge 1 commit into
gopaljilab:mainfrom
tmdeveloper007:#1867
Open

test : added vitest unit tests for rlsContext middleware#1872
tmdeveloper007 wants to merge 1 commit into
gopaljilab:mainfrom
tmdeveloper007:#1867

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #1867.

Summary of What Has Been Done:
Added vitest tests for server/middleware/rlsContext.ts covering the RLS context resolution chain. Tests verify context is correctly resolved from Express session, jwtUser on request, Bearer token in Authorization header, and that unauthenticated requests pass through without creating an RLS context. Cleanup handlers attached to res.on(finish) and res.on(close) are also verified. All 6 tests pass.

Changes Made:

  • server/middleware/rlsContext.test.ts (new file): 154 lines

Impact it Made:

  • Guards Row-Level Security context setup for cross-user data protection
  • Increases server test coverage for critical RLS security middleware
  • Verified: ./node_modules/.bin/vitest run server/middleware/rlsContext.test.ts (6 passed)

Note: Please assign this PR to the tmdeveloper007 account.

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@tmdeveloper007 is attempting to deploy a commit to the gopaljilab's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the type:security Vulnerability fixes or security-related enhancements. label Jun 24, 2026
Cover context resolution from session, jwtUser, Bearer token, and
unauthenticated passthrough. All 6 tests pass.
@github-actions github-actions Bot added the type:testing Adding, updating, or fixing unit/integration tests. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:security Vulnerability fixes or security-related enhancements. type:testing Adding, updating, or fixing unit/integration tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add vitest unit tests for rlsContext middleware

1 participant