Skip to content

feat: implement environment validation schema and test setup infrastureucture.#1059

Open
dot-enny wants to merge 1 commit into
rinafcode:mainfrom
dot-enny:feature/831-configurable-bcrypt-rounds
Open

feat: implement environment validation schema and test setup infrastureucture.#1059
dot-enny wants to merge 1 commit into
rinafcode:mainfrom
dot-enny:feature/831-configurable-bcrypt-rounds

Conversation

@dot-enny

Copy link
Copy Markdown
Contributor

Closes #831

Summary of Changes

  1. New Branch Created:

    • Created and switched to feature/831-configurable-bcrypt-rounds.
  2. Configurable Cost Factor (src/auth/auth.service.ts):

    • Injected ConfigService into AuthService.
    • Replaced hardcoded bcrypt.genSalt(10) with bcrypt.genSalt(Number(this.configService.get('BCRYPT_ROUNDS', 12))).
  3. Startup Environment Validation (src/config/env.validation.ts & scripts/validate-env.js):

    • Updated BCRYPT_ROUNDS schema rule to ensure cost factor is between 10 and 14 (min(10).max(14)), defaulting to 12.
  4. Environment Template Updated (.env.example):

    • Updated BCRYPT_ROUNDS documentation to reflect the OWASP recommended cost factor (12) and default value.
  5. Unit Tests and Performance (src/auth/auth.service.spec.ts, src/config/env.validation.spec.ts, test/setup.ts, test/setup.js):

    • Set BCRYPT_ROUNDS=10 in test setup and mock configuration for fast execution during testing.
    • Added unit test assertions verifying that values < 10 or > 14 fail validation, and that default value 12 is applied.
    • All unit tests pass cleanly.

All tests have passed successfully. The solution is complete and verified.

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

@dot-enny 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

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 configurable bcrypt cost factor instead of hardcoded rounds=10

1 participant