Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-10600] Unit Test coverage and refactor for Push Notifications #5011

Open
wants to merge 10 commits into
base: km/pm-10600
Choose a base branch
from

Conversation

mzieniukbw
Copy link
Contributor

🎟️ Tracking

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

📔 Objective

Part 2 of Push Notification changes. This one focuses on refactoring for ease of testing.
More coverage and changes coming in Part 3.

📸 Screenshots

⏰ 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

Also added HttpClientCustomize fixture, that provides IHttpClientFactory, HttpClient and MockedHttpMessageHandler. The latter can be used to mock requests and provide expected responses.
Expanded HttpRequestMatcher to be able to respond with content.
…ements.

The GlobalSettingsFactory no longer provides the same instance of GlobalSettings. If modified, other tests would fail too.
The factory now have a method to create new GlobalSettings objects, which can be modified as it's needed for the test.
This is then used in GlobalSettingsBuilder, which can be used to customize GlobalSettings.
The GlobalSettings fixture customization had the same name as the GlobalSettings itself, causing a bunch of compilation issues.
…nce.

The IHttpClientFactory.CreateClient(string name) needs to return different HttpClient instances in case there are multiple clients to be created. This have been issue for BaseIdentityClientService where the HttpClient is modified with BaseAddress, causing issues.
The SutProviderCustomization now includes create boolean flag, set to false, does not implicitly create the SutProvider instance. This gives flexibility to set dependencies and modify them, before the constructor of the Sut is called.
…dentityClientService

SendAsync in BaseIdentityClientService never throws exception. Ideally this behaviour should be changed, and the method should throw error on any failure, but it's not in scope of change.
Will be fixed by PM-14675
@mzieniukbw mzieniukbw requested a review from a team November 9, 2024 15:48
@mzieniukbw mzieniukbw marked this pull request as ready for review November 9, 2024 15:54
Copy link

codecov bot commented Nov 9, 2024

Codecov Report

Attention: Patch coverage is 38.29787% with 29 lines in your changes missing coverage. Please review.

Project coverage is 43.03%. Comparing base (31316ee) to head (7bea641).

Files with missing lines Patch % Lines
src/Notifications/AzureQueueHostedService.cs 0.00% 12 Missing ⚠️
src/Notifications/HubHelpers.cs 63.15% 7 Missing ⚠️
src/Notifications/Controllers/SendController.cs 0.00% 6 Missing ⚠️
...vices/Implementations/BaseIdentityClientService.cs 0.00% 2 Missing and 1 partial ⚠️
src/Notifications/Startup.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           km/pm-10600    #5011      +/-   ##
===============================================
+ Coverage        42.78%   43.03%   +0.25%     
===============================================
  Files             1391     1389       -2     
  Lines            64902    64869      -33     
  Branches          5960     5960              
===============================================
+ Hits             27769    27918     +149     
+ Misses           35903    35714     -189     
- Partials          1230     1237       +7     

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

Copy link
Contributor

github-actions bot commented Nov 9, 2024

Logo
Checkmarx One – Scan Summary & Details4c543e60-0a12-4128-9601-96dd7738c472

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 59 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 105 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/MembersController.cs: 95 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 237 Attack Vector
MEDIUM CSRF /src/Api/Controllers/DevicesController.cs: 60 Attack Vector
MEDIUM CSRF /src/Api/Controllers/DevicesController.cs: 73 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 263 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 344 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 361 Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 75 Attack Vector
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 217 Attack Vector
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 208 Attack Vector
MEDIUM Privacy_Violation /src/Core/Auth/Services/Implementations/AuthRequestService.cs: 217 Attack Vector

Fixed Issues

Severity Issue Source File / Package
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29
LOW Log_Forging /src/Api/Billing/Controllers/ProviderClientsController.cs: 29

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.

1 participant