Skip to content

Conversation

@KatherineInCode
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-27047

📔 Objective

Following the Interface Segregation Principle, this segregates out the Biometrics-relevant parts of StateService into a BiometricsStateService, which is then pulled into BitwardenKit.

The PM BiometricsRepository has been updated to use this; BWA has not, as in a future PR the PM one will also be pulled into BitwardenKit, and used in BWA, which will result in some changed functionality. That is, the BiometricsRepository classes in PM and BWA have diverged due to changes being made in PM but not BWA, and will eventually re-merge following the newer implementation. As updating BWA now would require building out functions in BiometricsStateService that will just be taken out at that time, it didn't seem the prudent thing to do.

⏰ 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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Logo
Checkmarx One – Scan Summary & Details66b831b4-1768-406c-9d11-a69ca9a6eb33

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

@KatherineInCode KatherineInCode marked this pull request as ready for review December 11, 2025 17:37
@claude
Copy link

claude bot commented Dec 11, 2025

Claude finished @KatherineInCode's task in 3m 3s —— View job


Code Review Complete ✓

Review completed and posted inline.

if let setBiometricAuthenticationEnabledError {
throw setBiometricAuthenticationEnabledError
}
biometricAuthenticationEnabledResult = .success(isEnabled ?? false)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Observation: The mock implementation stores the result of setBiometricAuthenticationEnabled in biometricAuthenticationEnabledResult, which creates bidirectional coupling between the setter and getter.

While this works for simple test scenarios, it means that setting isEnabled = nil will be stored as false, which may not accurately reflect the behavior of the real implementation. Consider whether tests need to verify the actual value passed vs. the stored state separately.

This is fine for current test needs, but worth noting for future test scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do this elsewhere in our mocks, I believe, so I'm comfortable with this for now. In the PR where I bring the BiometricsRepository into BitwardenKit, I might do a re-look through all the tests and decide to change this then.

@codecov
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 98.68421% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.22%. Comparing base (a39361e) to head (7cd289b).

Files with missing lines Patch % Lines
TestHelpers/Support/BitwardenTestError.swift 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2192      +/-   ##
==========================================
- Coverage   85.53%   84.22%   -1.32%     
==========================================
  Files        1737     1979     +242     
  Lines      147232   162342   +15110     
==========================================
+ Hits       125942   136734   +10792     
- Misses      21290    25608    +4318     

☔ 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.

// MARK: Biometrics

extension DefaultStateService {
extension DefaultStateService: BiometricsStateService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Do we want to remove the getBiometricAuthenticationEnabled()/setBiometricAuthenticationEnabled() definitions from the StateService protocol now that these are covered by BiometricsStateService? Maybe we haven't done that elsewhere, but it seems like it would be better to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm comfortable with that, especially as we have the pattern here of a separate extension for the segregated protocol. I'll make the change.

fedemkr
fedemkr previously approved these changes Dec 15, 2025
@claude
Copy link

claude bot commented Dec 15, 2025

Overall Assessment: APPROVE

Reviewed interface segregation refactoring moving BiometricsStateService into BitwardenKit across 6 files.

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.

4 participants