Skip to content

Prepare IPushNotificationService for extraction into a push library - #8199

Draft
justindbaur wants to merge 6 commits into
mainfrom
preparing-for-push-library
Draft

Prepare IPushNotificationService for extraction into a push library#8199
justindbaur wants to merge 6 commits into
mainfrom
preparing-for-push-library

Conversation

@justindbaur

@justindbaur justindbaur commented Aug 13, 2026

Copy link
Copy Markdown
Member

🎟️ Tracking

Part of: https://bitwarden.atlassian.net/browse/PM-34546

📔 Objective

Removes all 16 default interface methods (DIMs) from IPushNotificationService, leaving only PushAsync<T>. Each DIM is extracted as a static extension method in its owning team's domain folder (Auth, Vault, Tools, AdminConsole, NotificationCenter, Billing). Push notification payload types are moved into their owning team's Models folder (namespace kept as Bit.Core.Models to avoid touching callers).

Also adds end-to-end pipeline tests for the Azure Queue push path:

  • AzureQueuePipelineTests — drives the full chain (AzureQueuePushEngine → in-memory ChannelQueueClientAzureQueueHostedServiceHubHelpers → SignalR hub mocks), covering wire-format contracts, routing by user/org/installation/client-type, and the AuthRequestResponse → anonymous hub path
  • PostSendEndpointTests — integration tests for POST /send using a real in-memory Identity server and JWT tokens, including the anonymous hub routing case
  • AzureQueueHostedService gets TimeProvider injection and resolves QueueClient via keyed DI so tests can substitute ChannelQueueClient without touching production wiring

Key changes:

  • Remove all DIMs from IPushNotificationService; retain the three legacy properties marked [Obsolete(DiagnosticId="BWP0001")]
  • Extract extension methods per team domain
  • Move payload types to team-owned Models folders (namespace unchanged)
  • Delete snapshot-style PushTestBase engine tests (migration guards, not living contracts)
  • Add AzureQueuePipelineTests + ChannelQueueClient as the replacement living contract

Once these changes land, Push should be able to be made into a library and Notifications should be able to remove a dependency on Core with only Platform review for future PRs.

📸 Screenshots

N/A

- Remove all 16 default interface methods (DIMs) from IPushNotificationService,
  leaving only PushAsync<T>; the three legacy properties (InstallationId,
  TimeProvider, Logger) are retained but marked [Obsolete(DiagnosticId="BWP0001")]
- Extract each DIM as a static extension method in its owning team's domain folder
  (Auth, Vault, Tools, AdminConsole, NotificationCenter, Billing)
- Move push notification payload types out of PushNotification.cs into their
  owning team's Models folder; namespace stays Bit.Core.Models to avoid touching
  callers (file location is the ownership signal, not the namespace—see comment
  in each file)
- Fix LogOut PushType attribution from "not-specified" to @bitwarden/team-auth-dev
- Update all service-level tests to assert on PushAsync<T> instead of the removed
  DIMs; delete the snapshot-style PushTestBase engine tests that were migration
  guards rather than living contracts
- Add AzureQueuePushEngineWireFormatTests as a wire-format guard and HubHelpers
  routing guard for the Azure Queue push path
Replaces the mock-based AzureQueuePushEngineWireFormatTests with a true
end-to-end pipeline test (AzureQueuePipelineTests) that drives the full
chain: AzureQueuePushEngine → ChannelQueueClient → AzureQueueHostedService
→ HubHelpers → SignalR hub mocks.

- ChannelQueueClient: in-memory QueueClient backed by System.Threading.Channels,
  with a separate capture channel so producer and consumer sides don't race
- AzureQueuePipelineTests: wire-format guard + routing guard + ClientType
  routing, including the AuthRequestResponse → anonymous hub case
- NotificationsApplicationFactory: expose AnonymousHubClients for asserting
  auth-request-response routing
- PostSendEndpointTests: add AuthRequestResponse routing case (anonymous hub)
- AzureQueueHostedService: inject TimeProvider for delay control in tests;
  resolve QueueClient via keyed service provider
- Startup: register TimeProvider.System and QueueClient as keyed singleton
  so tests can substitute ChannelQueueClient
@justindbaur justindbaur added the t:tech-debt Change Type - Tech debt label Aug 13, 2026
Comment thread test/Api.IntegrationTest/Auth/Controllers/AccountsControllerTest.cs Fixed
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.51351% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.18%. Comparing base (643e3aa) to head (66de559).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...re/Vault/PushNotificationServiceVaultExtensions.cs 32.00% 51 Missing ⚠️
...NotificationServiceNotificationCenterExtensions.cs 72.34% 21 Missing and 5 partials ⚠️
...e/PushNotificationServiceAdminConsoleExtensions.cs 68.42% 12 Missing ⚠️
...re/Tools/PushNotificationServiceToolsExtensions.cs 92.59% 2 Missing and 2 partials ⚠️
...els/ProviderBankAccountVerifiedPushNotification.cs 0.00% 2 Missing ⚠️
src/Notifications/AzureQueueHostedService.cs 81.81% 1 Missing and 1 partial ⚠️
...OrganizationBankAccountVerifiedPushNotification.cs 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (643e3aa) and HEAD (66de559). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (643e3aa) HEAD (66de559)
2 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8199      +/-   ##
==========================================
- Coverage   68.41%   63.18%   -5.23%     
==========================================
  Files        2380     2397      +17     
  Lines      103679   103755      +76     
  Branches     9386     9385       -1     
==========================================
- Hits        70931    65557    -5374     
- Misses      30420    35956    +5536     
+ Partials     2328     2242      -86     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant