Problem
src/modules/auth/auth.service.ts has zero unit tests. All authentication paths (nonce generation, signature verification, token rotation) are untested. Any regression here logs every user out and is undetectable until production.
Context
Auth is the most security-sensitive module. A silent bug in token rotation could leak session lifetimes or allow refresh-token replay attacks. Unit tests are the cheapest line of defense.
Before Starting
Read these context files first:
- context/architecture-context.md
- context/code-standards.md
- context/progress-tracker.md
- src/modules/auth/auth.service.ts
What To Build
- Create
test/unit/auth.service.spec.ts with a Test.createTestingModule setup mocking SupabaseService, JwtService, and ConfigService.
- Test
getNonce(wallet): returns a 32-char nonce, inserts a row in nonces with wallet, nonce, expires_at.
- Test
verify(wallet, signature): valid signature path returns { accessToken, refreshToken }; invalid signature throws UnauthorizedException.
- Test
refresh(refreshToken): valid token returns new pair; refresh token is rotated (old one marked revoked).
- Test nonce dedup: two
getNonce(wallet) calls within expiry window return the same nonce.
- Achieve ≥ 90% branch coverage on
auth.service.ts.
Files To Touch
test/unit/auth.service.spec.ts
Acceptance Criteria
Mandatory Checks Before PR
Problem
src/modules/auth/auth.service.tshas zero unit tests. All authentication paths (nonce generation, signature verification, token rotation) are untested. Any regression here logs every user out and is undetectable until production.Context
Auth is the most security-sensitive module. A silent bug in token rotation could leak session lifetimes or allow refresh-token replay attacks. Unit tests are the cheapest line of defense.
Before Starting
Read these context files first:
What To Build
test/unit/auth.service.spec.tswith aTest.createTestingModulesetup mockingSupabaseService,JwtService, andConfigService.getNonce(wallet): returns a 32-char nonce, inserts a row innonceswithwallet,nonce,expires_at.verify(wallet, signature): valid signature path returns{ accessToken, refreshToken }; invalid signature throwsUnauthorizedException.refresh(refreshToken): valid token returns new pair; refresh token is rotated (old one marked revoked).getNonce(wallet)calls within expiry window return the same nonce.auth.service.ts.Files To Touch
test/unit/auth.service.spec.tsAcceptance Criteria
describeblocks covering each methodnpm test -- auth.servicepassesanytypes in the test fileMandatory Checks Before PR
anytypes introduced anywhere