Skip to content

test: add focused behavior coverage for SessionRepositoryAdapter - #1184

Merged
thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
Adesh-tech09:test/issue-968-session-repository-adapter
Sep 29, 2026
Merged

thlpkee20-wq merged 1 commit into
RevoraOrg:masterfrom
Adesh-tech09:test/issue-968-session-repository-adapter

Conversation

@Adesh-tech09

Copy link
Copy Markdown

Closes #968

What changed

  • Adds src/auth/login/sessionRepositoryAdapter.test.ts — the dedicated fixture that src/auth/login/sessionRepositoryAdapter.ts was missing.
  • Production code is untouched: the existing public contract is preserved exactly.

Covered behavior

Case Assertion
Interface conformance SessionRepositoryAdapter stays assignable to the login module's SessionRepository interface
Field mapping camelCase input maps to { id, user_id, token_hash, expires_at }
No extra keys Unknown properties are not forwarded to the DB layer
Date identity The exact Date instance is passed through
Return contract Resolves to undefined; the persisted row is discarded
Await semantics Adapter does not resolve before the DB write settles
DB failures Errors propagate by identity (no swallowing, no re-wrapping)
Isolation A failed write does not poison the following call
Boundary/abuse input Empty-string ids and a non-Date expiry are forwarded verbatim for the DB layer to reject
Concurrency Two parallel calls produce two independent, correctly-mapped invocations

Validation

npx jest src/auth/login/sessionRepositoryAdapter.test.ts src/auth/oidc/oidcRoute.test.ts --runInBand --coverage \
  --collectCoverageFrom='src/auth/login/sessionRepositoryAdapter.ts' \
  --collectCoverageFrom='src/auth/oidc/oidcRoute.ts' --coverageReporters=text

PASS src/auth/login/sessionRepositoryAdapter.test.ts
PASS src/auth/oidc/oidcRoute.test.ts
Test Suites: 2 passed, 2 total
Tests:       68 passed, 68 total

sessionRepositoryAdapter.ts | 100% stmts | 100% branch | 100% funcs | 100% lines
  • npx jest src/auth --runInBand → 260 passed; the single failure in src/auth/register/__tests__/roundtrip.test.ts is pre-existing on master and untouched by this PR.
  • npx eslint src/auth/login/sessionRepositoryAdapter.test.ts → clean.

Security notes / assumptions

  • The adapter is a deliberate pure pass-through: it performs no local validation or normalization. All validation and constraint enforcement stays in the DB repository/database, so a hostile payload cannot be silently "cleaned" into something the persistence layer would accept — the tests lock in that pass-through semantics.
  • No credentials, sessions or network were exercised; every DB collaborator is a mock, so the suite is deterministic and offline.
  • The test asserts the adapter never returns the persisted row, keeping callers decoupled from DB row shape (including token_hash).

🤖 Generated with Codebuff

The login module's SessionRepositoryAdapter had no directly associated test
fixture, so its camelCase-to-snake_case mapping, void return contract and
error propagation were unprotected against regression. Pin those behaviors
(including boundary/abuse inputs and DB failure paths) with focused tests so
any change to the adapter's public contract fails loudly.

Refs RevoraOrg#968

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Adesh-tech09 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit 9240b78 into RevoraOrg:master Sep 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add focused behavior coverage for SessionRepositoryAdapter

2 participants