Skip to content

test: Add 2FA recovery code tests#188

Merged
bobbyiliev merged 1 commit intothedevdojo:mainfrom
bobbyonmagic:test/2fa-recovery-codes
Jan 26, 2026
Merged

test: Add 2FA recovery code tests#188
bobbyiliev merged 1 commit intothedevdojo:mainfrom
bobbyonmagic:test/2fa-recovery-codes

Conversation

@bobbyonmagic
Copy link
Contributor

Adds 20 tests covering the 2FA recovery code functionality.

Tests Added

GenerateNewRecoveryCodes Action

  • Generates codes as Collection
  • Generates exactly 8 codes
  • Correct format (10chars-10chars)
  • Unique codes each generation
  • No duplicates within set

Recovery Code Storage

  • Codes stored encrypted in database
  • Codes cleared when disabling 2FA

Recovery Code Regeneration

  • New codes replace old ones
  • Old codes invalidated after regeneration

Login with Recovery Codes

  • Valid recovery code allows login
  • Invalid code rejected
  • Empty code rejected

DisableTwoFactorAuthentication Action

  • Dispatches event when disabling
  • No event when 2FA not enabled

Security

  • Codes encrypted (not plaintext)
  • Multiple users have unique codes

- Test GenerateNewRecoveryCodes action (format, uniqueness, count)
- Test recovery code storage and encryption
- Test recovery code regeneration
- Test login with valid/invalid recovery codes
- Test DisableTwoFactorAuthentication action and events
- Test security (encryption, multi-user isolation)
@bobbyiliev bobbyiliev merged commit c6db9e7 into thedevdojo:main Jan 26, 2026
4 checks 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.

2 participants