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 & Details80a2258f-d1e4-41ca-999c-db0dfb3b70a4

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.01%. Comparing base (254b2cd) to head (246c394).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6426      +/-   ##
==========================================
+ Coverage   85.78%   86.01%   +0.23%     
==========================================
  Files         776      775       -1     
  Lines       56201    56203       +2     
  Branches     8117     8123       +6     
==========================================
+ Hits        48211    48342     +131     
+ Misses       5166     5032     -134     
- 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 19s —— View job


Code Review Summary

Status: Approved

PR Overview

This PR adds comprehensive test coverage for the Unlock feature, a security-critical authentication flow in the Authenticator application.

File Lines Tests
UnlockViewModelTest.kt 488 17
UnlockScreenTest.kt 286 13

Review Assessment

All previous review comments have been addressed:

  • Complete state assertions implemented (not individual field assertions)
  • Dialog content verified within dialog context using hasAnyAncestor(isDialog())
  • createViewModel uses nullable state pattern instead of passing SavedStateHandle directly
  • Unused variable initialization removed
  • Loading states explicitly asserted rather than skipped

Code Quality:

  • Follows established Bitwarden testing patterns (AuthenticatorComposeTest, BaseViewModelTest)
  • Proper use of Turbine for Flow testing with explicit state verification
  • Good callback capture pattern for BiometricsManager interactions
  • Comprehensive coverage of security-critical scenarios:
    • Biometric authentication success/failure/lockout
    • Biometric decoding errors with clearBiometrics() verification
    • Dialog state management
    • Navigation events

No issues identified - The test code is well-structured and follows project conventions.

Verdict

Ready for merge.

@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>
Removed unnecessary initialization of onUnlockedCalled in setUp.
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