[PM-39455] Organization user v2 upgrade token repository tests - #8168
Draft
mzieniukbw wants to merge 4 commits into
Conversation
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.
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎟️ 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