- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.5k
[PM-26690] Wire VNextSavePolicyCommand behind PolicyValidatorsRefactor feature flag #6483
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
base: ac/pm-26429/add-validation-to-policy-data-and-metadata
Are you sure you want to change the base?
Conversation
…on feature flag - Added IFeatureService and IVNextSavePolicyCommand dependencies to PoliciesController. - Updated PutVNext method to conditionally use VNextSavePolicyCommand or SavePolicyCommand based on the PolicyValidatorsRefactor feature flag. - Enhanced unit tests to verify behavior for both enabled and disabled states of the feature flag.
…d based on feature flag - Introduced IFeatureService and IVNextSavePolicyCommand to manage policy saving based on the PolicyValidatorsRefactor feature flag. - Updated the Put method to conditionally use the new VNextSavePolicyCommand or the legacy SavePolicyCommand. - Added unit tests to validate the behavior of the Put method for both enabled and disabled states of the feature flag.
…ommand based on feature flag - Added IFeatureService and IVNextSavePolicyCommand dependencies to VerifyOrganizationDomainCommand. - Updated EnableSingleOrganizationPolicyAsync method to conditionally use VNextSavePolicyCommand or SavePolicyCommand based on the PolicyValidatorsRefactor feature flag. - Enhanced unit tests to validate the behavior when the feature flag is enabled.
…feature flag - Added IFeatureService and IVNextSavePolicyCommand dependencies to SsoConfigService. - Updated SaveAsync method to conditionally use VNextSavePolicyCommand or SavePolicyCommand based on the PolicyValidatorsRefactor feature flag. - Added unit tests to validate the behavior when the feature flag is enabled.
| Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@                                    Coverage Diff                                     @@
##           ac/pm-26429/add-validation-to-policy-data-and-metadata    #6483      +/-   ##
==========================================================================================
+ Coverage                                                   52.02%   52.06%   +0.03%     
==========================================================================================
  Files                                                        1877     1877              
  Lines                                                       82651    82717      +66     
  Branches                                                     7316     7320       +4     
==========================================================================================
+ Hits                                                        42997    43063      +66     
  Misses                                                      37995    37995              
  Partials                                                     1659     1659              ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| 
 Great job! No new security vulnerabilities introduced in this pull request | 
… into ac/pm-26690/use-vnextsavepolicycommand
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.
Pull Request Overview
This PR introduces wiring for VNextSavePolicyCommand behind the PolicyValidatorsRefactor feature flag across policy save endpoints. The implementation allows gradual migration from the legacy ISavePolicyCommand to the new IVNextSavePolicyCommand interface.
Key Changes
- Added IVNextSavePolicyCommanddependency injection alongside existingISavePolicyCommandacross services and controllers
- Implemented feature flag checks that route policy saves to either the new VNext command or legacy command based on the PolicyValidatorsRefactorflag
- Added comprehensive test coverage for both enabled and disabled feature flag scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description | 
|---|---|
| src/Core/Constants.cs | Added PolicyValidatorsRefactorfeature flag constant | 
| src/Core/Auth/Services/Implementations/SsoConfigService.cs | Integrated VNext command with conditional routing based on feature flag for TDE policy saves | 
| src/Core/AdminConsole/OrganizationFeatures/OrganizationDomains/VerifyOrganizationDomainCommand.cs | Added feature flag check to route SingleOrg policy saves through VNext command | 
| src/Api/AdminConsole/Public/Models/Request/PolicyUpdateRequestModel.cs | Added ToSavePolicyModelmethod to support VNext command interface | 
| src/Api/AdminConsole/Public/Controllers/PoliciesController.cs | Implemented feature flag routing for public API policy updates | 
| src/Api/AdminConsole/Controllers/PoliciesController.cs | Implemented feature flag routing for private API PutVNext endpoint | 
| test/Core.Test/Auth/Services/SsoConfigServiceTests.cs | Added test verifying VNext command usage when feature flag enabled | 
| test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationDomains/VerifyOrganizationDomainCommandTests.cs | Added test verifying VNext command usage when feature flag enabled | 
| test/Api.Test/Controllers/PoliciesControllerTests.cs | Added tests for both enabled and disabled feature flag scenarios in PutVNext | 
| test/Api.Test/AdminConsole/Public/Controllers/PoliciesControllerTests.cs | Added tests for both enabled and disabled feature flag scenarios in public API Put | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Just one small suggestion.
| { | ||
| var performedBy = new SystemUser(EventSystemUser.Unknown); | ||
| await _vNextSavePolicyCommand.SaveAsync(new SavePolicyModel(singleOrgPolicy, performedBy, new EmptyMetadataModel())); | ||
| await _vNextSavePolicyCommand.SaveAsync(new SavePolicyModel(resetPasswordPolicy, performedBy, new EmptyMetadataModel())); | 
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.
Consider adding a different constructor for SavePolicyModel, so the client can simply pass in what it has, and the SavePolicyModel object will fill in the default values.
Currently, the client needs to be aware that EmptyMetadataModel is the default value. We're also calling this logic in multiple places, so centralizing it would be nice, even if the value is low.
So something like this.
public record SavePolicyModel(PolicyUpdate PolicyUpdate, IActingUser? PerformedBy, IPolicyMetadataModel Metadata)
{
    public SavePolicyModel(PolicyUpdate PolicyUpdate)
        : this(PolicyUpdate, null, new EmptyMetadataModel())
    {
    }
    public SavePolicyModel(PolicyUpdate PolicyUpdate, IActingUser performedBy)
        : this(PolicyUpdate, performedBy, new EmptyMetadataModel())
    {
    }
    public SavePolicyModel(PolicyUpdate PolicyUpdate, EmptyMetadataModel metadata)
        : this(PolicyUpdate, null, metadata)
    {
    }
}
…ptyMetadataModel parameter. Update related usages across the codebase to reflect the new constructor overloads.
| 
 | 




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-26690
📔 Objective
Wire up
VNextSavePolicyCommandbehind thePolicyValidatorsRefactorfeature flag across all policy save endpoints: private APIPutVNext, public API Put, domain verification, and SSO configuration⏰ 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