Skip to content

Add regression tests for the password utility - #5

Open
ubf-hunter wants to merge 1 commit into
MrAshki:mainfrom
ubf-hunter:test/password-util-regression-coverage
Open

Add regression tests for the password utility#5
ubf-hunter wants to merge 1 commit into
MrAshki:mainfrom
ubf-hunter:test/password-util-regression-coverage

Conversation

@ubf-hunter

Copy link
Copy Markdown

Summary

apps/api had no automated test setup at all. Added jest + ts-jest (matching the NestJS/TypeScript stack already in use) scoped to the API package, and covered auth/password.util.ts:

  • hashPassword: produces a scrypt-tagged hash that never contains the raw password, and salts independently (the same password hashes differently each time).
  • verifyPassword: accepts the correct password, rejects an incorrect one, and rejects malformed/unrecognised hash formats without throwing (an unrelated algorithm tag, a hash missing its parts).

No PostgreSQL or other external service involved — password.util.ts is pure crypto (node:crypto scrypt), so nothing here touches Prisma.

Closes #3

Test plan

  • pnpm test (in apps/api) — 6/6 pass
  • pnpm typecheck — clean
  • pnpm lint — clean

apps/api had no test setup at all. Added jest + ts-jest (matching the
NestJS/TypeScript stack already in use) scoped to the API package, and
covered the two functions in auth/password.util.ts:

- hashPassword: produces a scrypt-tagged hash that never contains the
  raw password, and salts independently (same password hashes
  differently each time).
- verifyPassword: accepts the correct password, rejects an incorrect
  one, and rejects malformed/unrecognised hash formats without
  throwing (an unrelated algorithm tag, a hash missing its parts).

Runs via `pnpm test` in apps/api, no PostgreSQL or other external
service involved -- password.util.ts is pure crypto (node:crypto
scrypt), so nothing here touches Prisma.

Closes MrAshki#3
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 regression tests for the password utility

1 participant