Skip to content

Conversation

@SaintPatrck
Copy link
Contributor

🎟️ Tracking

Test coverage improvements for critical unlock/authentication functionality.

📔 Objective

This PR adds comprehensive test coverage for the Unlock feature, which serves as the authentication gate for the Authenticator application. The unlock flow is security-critical and requires thorough testing to ensure correct behavior across all user scenarios.

Test Coverage:

  • UnlockViewModel: Complete test suite covering authentication state management, biometric flows, PIN validation, and error handling
  • UnlockScreen: UI test coverage for Compose screen rendering, user interactions, and state-driven UI updates

Critical Scenarios Tested:

  • Biometric authentication success/failure flows
  • PIN entry validation and verification
  • Account unlock state transitions
  • Error handling and user feedback
  • Edge cases: empty PIN, biometric unavailable, authentication timeouts

The unlock screen is the first security barrier users encounter. These tests ensure authentication mechanisms function correctly, handle failures gracefully, and maintain proper security posture across all scenarios.

📸 Screenshots

N/A - Test-only changes

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

🤖 Generated with Claude Code

@SaintPatrck SaintPatrck requested review from a team and david-livefront as code owners January 28, 2026 15:27
@github-actions github-actions bot added the app:authenticator Bitwarden Authenticator app context label Jan 28, 2026
@SaintPatrck SaintPatrck added the t:tech-debt Change Type - Tech debt label Jan 28, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

Logo
Checkmarx One – Scan Summary & Detailsf5ad1fbe-c1c7-4be1-8f9d-79175ccea3ff

Great job! No new security vulnerabilities introduced in this pull request

@SaintPatrck SaintPatrck added the ai-review Request a Claude code review label Jan 28, 2026
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.02%. Comparing base (254b2cd) to head (c3b18e3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6426      +/-   ##
==========================================
+ Coverage   85.78%   86.02%   +0.24%     
==========================================
  Files         776      776              
  Lines       56201    56201              
  Branches     8117     8117              
==========================================
+ Hits        48211    48346     +135     
+ Misses       5166     5026     -140     
- Partials     2824     2829       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude
Copy link
Contributor

claude bot commented Jan 28, 2026

Claude finished @SaintPatrck's task in 2m 36s —— View job


Code Review Complete

  • Review UnlockScreenTest.kt
  • Review UnlockViewModelTest.kt
  • Check if review comments have been addressed
  • Post final review summary

Summary

This PR adds comprehensive test coverage for the Unlock feature with 672 lines of well-structured tests across two files. The tests cover both ViewModel business logic and Compose UI interactions.

Previous Review Comments Status

Comment Status
Use assertTrue ✅ Addressed
Assert the whole state ✅ Addressed
Avoid passing SavedStateHandle directly ✅ Addressed
Remove unused biometricsManager ✅ Addressed (outdated)
Assert dialog text in dialog ❓ Open thread at line 213

Findings

One open thread remains at UnlockScreenTest.kt:213 - david-livefront asked whether the dialog tests should assert that text is being displayed within a dialog component rather than just checking text existence. This is a valid point for more robust dialog testing.

Positive aspects:

  • 👍 Comprehensive coverage of biometric success/failure/lockout scenarios
  • 👍 Good use of callback capture pattern for BiometricsManager interactions
  • 👍 Proper Turbine usage for Flow testing
  • 👍 Complete state assertions following Bitwarden conventions
  • 👍 Tests cover critical security flows (PIN validation, biometric authentication)

No new issues identified - The code follows established patterns and Bitwarden testing conventions.

Verdict

The tests are well-structured and all previously raised review comments have been addressed except for the open thread about dialog assertions. Ready for merge once that discussion is resolved.


@github-actions github-actions bot removed the t:tech-debt Change Type - Tech debt label Jan 28, 2026
@SaintPatrck SaintPatrck added the t:tech-debt Change Type - Tech debt label Jan 28, 2026
@github-actions github-actions bot removed the t:tech-debt Change Type - Tech debt label Jan 28, 2026
SaintPatrck and others added 5 commits January 29, 2026 08:41
Creates complete test coverage for:
- UnlockViewModel (17 tests)
- UnlockScreen (13 tests)

Tests cover biometric unlock flow, error handling,
state management, UI interactions, and navigation.

Critical for security-critical authentication flow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated 8 test methods to assert against complete UnlockState objects
instead of individual field assertions. This follows best practices for
state-based testing and makes assertions more explicit and maintainable.

Changed tests:
- BiometricsUnlockClick with null cipher should update state
- BiometricDecodingError should clear biometrics
- InvalidStateError should show error dialog
- BiometricsLockout should show error dialog
- DismissDialog should clear dialog state
- StateFlow changes should save to SavedStateHandle
- ReceiveVaultUnlockResult with BiometricDecodingError should update state
- ReceiveVaultUnlockResult with InvalidStateError should show error

All tests pass successfully (17/17).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add assertNotNull import and replace assertTrue with assertNotNull
for clearer null-checking semantics.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:authenticator Bitwarden Authenticator app context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants