Skip to content

[PM-37072] chore: Consolidate MockAuthClient with support for MockRegistrationClientProtocol#2638

Merged
matt-livefront merged 1 commit into
mainfrom
matt/PM-37072-mock-registration-client
May 13, 2026
Merged

[PM-37072] chore: Consolidate MockAuthClient with support for MockRegistrationClientProtocol#2638
matt-livefront merged 1 commit into
mainfrom
matt/PM-37072-mock-registration-client

Conversation

@matt-livefront
Copy link
Copy Markdown
Collaborator

@matt-livefront matt-livefront commented May 12, 2026

🎟️ Tracking

PM-37072

📔 Objective

This consolidates MockAuthClient to BitwardenKit and adds a MockRegistrationClientProtocol.

The current MockAuthClient conforms to AuthClientProtocol. When the SDK builds protocols for services, the protocol methods return the concrete type instead of a protocol type (e.g. AuthClientProtocol returns RegistrationClient instead of RegistrationClientProtocol). This makes it difficult to use SDK's protocols directly when they return other types which need to be mocked. As a workaround, this adds an AuthClientService protocol which returns a RegistrationClientProtocol, and then AuthClient can conform to that. This allows for mocking RegistrationClient without too much overhead. The AuthClientService protocol just needs to be used in place of AuthClientProtocol.

@matt-livefront matt-livefront added the ai-review Request a Claude code review label May 12, 2026
@matt-livefront matt-livefront requested a review from a team as a code owner May 12, 2026 17:24
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:tech-debt Change Type - Tech debt labels May 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR consolidates two duplicate MockAuthClient definitions (one in BitwardenShared, one in AuthenticatorShared) into a single public mock in BitwardenKitMocks, and introduces a new AuthClientService protocol in BitwardenKit that mirrors BitwardenSdk.AuthClientProtocol but returns RegistrationClientProtocol so the registration client can finally be mocked. The change wires BitwardenSdkMocks into BitwardenKitMocks so MockRegistrationClientProtocol is available, follows the same extension Client: BitwardenSdkClient shadowing pattern already used for auth()/crypto()/etc., and adjusts the ErrorReportBuilderTests snapshots to include the new BitwardenSdkMocks binary image. No production behavior changes — this is purely a test-infrastructure refactor.

Code Review Details

No findings.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 88.40580% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.33%. Comparing base (010f65e) to head (f736eed).

Files with missing lines Patch % Lines
.../Core/Auth/Services/SDK/Mocks/MockAuthClient.swift 93.49% 8 Missing ⚠️
...rShared/Core/Platform/Services/ClientService.swift 0.00% 3 Missing ⚠️
...Kit/Core/Auth/Services/SDK/AuthClientService.swift 0.00% 3 Missing ⚠️
...tform/Services/TestHelpers/MockClientService.swift 0.00% 1 Missing ⚠️
...nShared/Core/Platform/Services/ClientService.swift 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2638      +/-   ##
==========================================
- Coverage   87.35%   86.33%   -1.02%     
==========================================
  Files        1919     2144     +225     
  Lines      170962   185355   +14393     
==========================================
+ Hits       149336   160018   +10682     
- Misses      21626    25337    +3711     

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

import BitwardenSdkMocks
import Foundation

public class MockAuthClient: AuthClientService {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤔 Could we use Sourcery for this? And nonetheless, shouldn't this be named MockAuthClientService?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We could, yes, this PR was already getting large so I was trying to limit the amount of changes. I have these changes on another branch, so ok if I do this as a follow-up PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure no problem

@matt-livefront matt-livefront merged commit 511cf32 into main May 13, 2026
36 of 40 checks passed
@matt-livefront matt-livefront deleted the matt/PM-37072-mock-registration-client branch May 13, 2026 20:40
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 app:password-manager Bitwarden Password Manager app context t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants