Skip to content

[PM-39455] Organization user v2 upgrade token repository tests - #8168

Draft
mzieniukbw wants to merge 4 commits into
km/pm-39455-set-upgrade-tokens-for-organizationsfrom
km/pm-39455-organization-user-v2-upgrade-token-repository-tests
Draft

[PM-39455] Organization user v2 upgrade token repository tests#8168
mzieniukbw wants to merge 4 commits into
km/pm-39455-set-upgrade-tokens-for-organizationsfrom
km/pm-39455-organization-user-v2-upgrade-token-repository-tests

Conversation

@mzieniukbw

Copy link
Copy Markdown
Contributor

🎟️ Tracking

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

📔 Objective

Adds database integration tests for organization user v2 upgrade token added in #8158, that would otherwise be not possible, without #8165 first.

This will be used as a baseline for regression testing of key rotation, which includes both changes from both PRs.

📸 Screenshots

Replace UpdateEncryptedDataForKeyRotation with the generic DatabaseTransactionAction, which takes a DbConnection and DbTransaction rather than the SQL Server specific SqlConnection and SqlTransaction. This matches the delegate introduced in #7548.

Every EF repository that takes part in a key rotation now binds its DatabaseContext to the caller's connection and transaction through GetTransactionalDatabaseContext, instead of opening a second connection. Opening a second connection deadlocks on single-writer providers such as SQLite, and left each write outside the rotation transaction on the others, which breaks integration tests.
…e-token-repository-tests

# Conflicts:
#	src/Core/KeyManagement/UserKey/Implementations/RotateUserAccountKeysCommand.cs
Cover OrganizationUserRepository.UpdateForKeyRotation across all four providers: it
persists the reset password key and the V2 upgrade token together, clears a token left
over from an earlier upgrade, and leaves another member's membership untouched.

These need both the V2UpgradeToken column and the shared rotation transaction, so they
are kept out of the branches that add each.
@mzieniukbw mzieniukbw added the t:tech-debt Change Type - Tech debt label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.20690% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.53%. Comparing base (4a6a742) to head (0967486).

Files with missing lines Patch % Lines
...ure.EntityFramework/Repositories/UserRepository.cs 50.00% 5 Missing ⚠️
...per/Auth/Repositories/EmergencyAccessRepository.cs 0.00% 4 Missing ⚠️
...ucture.Dapper/Tools/Repositories/SendRepository.cs 0.00% 4 Missing ⚠️
...ture.Dapper/Vault/Repositories/CipherRepository.cs 0.00% 4 Missing ⚠️
...ture.Dapper/Vault/Repositories/FolderRepository.cs 0.00% 4 Missing ⚠️
...ent/Repositories/UserSignatureKeyPairRepository.cs 0.00% 2 Missing ⚠️
...ork/Auth/Repositories/EmergencyAccessRepository.cs 0.00% 2 Missing ⚠️
.../Auth/Repositories/WebAuthnCredentialRepository.cs 0.00% 2 Missing ⚠️
...e.EntityFramework/Repositories/DeviceRepository.cs 0.00% 2 Missing ⚠️
...tityFramework/Tools/Repositories/SendRepository.cs 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@                                 Coverage Diff                                  @@
##           km/pm-39455-set-upgrade-tokens-for-organizations    #8168      +/-   ##
====================================================================================
+ Coverage                                             67.50%   67.53%   +0.02%     
====================================================================================
  Files                                                  2315     2315              
  Lines                                                100518   100542      +24     
  Branches                                               9043     9043              
====================================================================================
+ Hits                                                  67855    67901      +46     
+ Misses                                                30378    30356      -22     
  Partials                                               2285     2285              

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

Comment thread test/Infrastructure.IntegrationTest/DatabaseTransactionActionTestHelper.cs Dismissed
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