Session lifecycle: deeper invariant tests (expiry cleanup, refresh, updatedAt)

Open
#960 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript

Research direction

Start from the existing 87-session-lifecycle.spec.ts added in #956 and read how its logout, concurrent-session and unauthenticated cases set up sessions. Then find the login, refresh and session-store code it exercises, to see where expired rows are cleaned up and where updatedAt is written. Done means four new tests pass against a real session store: expired-session cleanup on login, refresh extending expiry, rejection of a token whose session row was deleted, and updatedAt staying unchanged.

Written by the indexing model from the issue text.

Description

area: auth enhancement priority: P2 testing

Follow-up to #956 (auth hardening review). Missing tests on existing behavior.

Context

#956 added 87-session-lifecycle.spec.ts (logout destroys session; logging out one session leaves a concurrent one alive; unauth rejected). More session invariants remain unasserted.

Proposed coverage

  • Expired sessions are cleaned up on next login.
  • Session refresh extends expiry and returns an up-to-date user.
  • A JWT/cookie whose underlying session row was terminated server-side is rejected.
  • updatedAt is NOT bumped on session create / logout / refresh (matches Better Auth semantics).

Acceptance

  • Extend 87-session-lifecycle.spec.ts (or add integration tests) covering the above against a real session store.
Dominant language
TypeScript
Stars
1.8k
Forks
219
Avg merge
2d 21h
Merged PRs (30d)
67

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SonicJs-Org/sonicjs

All issues in SonicJs-Org/sonicjs

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.