-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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-18085] Add Manage property to UserCipherDetails #5390
base: main
Are you sure you want to change the base?
[PM-18085] Add Manage property to UserCipherDetails #5390
Conversation
…ganization properties
…bility - Split large test method into smaller, focused methods - Added helper methods for creating test data and performing assertions - Improved test coverage for cipher permissions in different scenarios - Maintained existing test logic while enhancing code structure
- Removed redundant helper methods for permission assertions - Simplified test methods for GetCipherPermissionsForOrganizationAsync, GetManyByUserIdAsync, and GetByIdAsync - Maintained existing test coverage for cipher manage permissions - Improved code readability and reduced code duplication
…missions - Added new test method GetCipherPermissionsForOrganizationAsync_ManageProperty_RespectsCollectionGroupRules - Implemented helper method CreateCipherInOrganizationCollectionWithGroup to support group-based collection permission testing - Verified manage permissions are correctly applied based on group collection access settings
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5390 +/- ##
==========================================
+ Coverage 44.47% 47.39% +2.92%
==========================================
Files 1511 1511
Lines 70253 70295 +42
Branches 6338 6338
==========================================
+ Hits 31242 33317 +2075
+ Misses 37669 35587 -2082
- Partials 1342 1391 +49 ☔ View full report in Codecov by Sentry. |
- Updated CipherDetails_Create, CipherDetails_CreateWithCollections, and CipherDetails_Update stored procedures - Added @manage parameter with comment "-- not used" - Included new stored procedure implementations in migration script - Consistent with previous work on adding Manage property to cipher details
New Issues (135)Checkmarx found the following issues in this Pull Request
Fixed Issues (24)Great job! The following issues were fixed in this Pull Request
|
Assert.True(personalDetails.Manage, "Personal ciphers should always have Manage permission"); | ||
} | ||
|
||
private async Task<(User user, Organization org, OrganizationUser orgUser)> CreateTestUserAndOrganization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work on making these helper methods to make the tests easier to read.
@shane-melton do you mind taking a look at this, just given that we discussed it and it's probably one of the more complex changes we're making. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, thanks! Just saw one tiny, non-blocking nit in the updated sproc.
util/Migrator/DbScripts/2025-02-11_00_UserCipherDetailsManage.sql
Outdated
Show resolved
Hide resolved
src/Infrastructure.EntityFramework/Repositories/Queries/UserCipherDetailsQuery.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Personal ciphers always have Manage=true
-
For organizational ciphers, Manage permission is inherited from collection/group permissions
-
The Manage property is properly propagated through all query methods
LGTM
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-18085
📔 Objective
Changes Made
Manage
property toUserCipherDetails
SQL function and EF queryManage
property behavior across:Technical Details
The EF query required restructuring because it wasn't correctly evaluating permissions for ciphers that users had access to through both groups and collections. The original logic didn't match the SQL function's behavior for permission evaluation.
The solution was to:
Testing
Added integration tests that verify the
Manage
property is correctly set:true
for user-owned cipherstrue
for organization ciphers in collections where the user has Manage permissionfalse
for organization ciphers in collections where the user does not have Manage permissiontrue
for organization ciphers in collections where the user's group has Manage permissionfalse
for organization ciphers in collections where the user's group does not have Manage permissionTests cover the
CipherRepository
query methods:GetCipherPermissionsForOrganizationAsync
GetManyByUserIdAsync
GetByIdAsync
⏰ Reminders before review
🦮 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