Skip to content

Conversation

@r-tome
Copy link
Contributor

@r-tome r-tome commented Oct 22, 2025

🎟️ Tracking

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

📔 Objective

Wire up VNextSavePolicyCommand behind the PolicyValidatorsRefactor feature flag across all policy save endpoints: private API PutVNext, public API Put, domain verification, and SSO configuration

⏰ 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

…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.
@r-tome r-tome requested a review from JimmyVo16 October 22, 2025 16:20
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.06%. Comparing base (f957c91) to head (cf6d0d1).

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

Logo
Checkmarx One – Scan Summary & Details2d1e6882-3082-4aa9-9ca8-073d4973c353

Great job! No new security vulnerabilities introduced in this pull request

… into ac/pm-26690/use-vnextsavepolicycommand
@r-tome r-tome requested a review from Copilot October 24, 2025 10:21
Copy link
Contributor

Copilot AI left a 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 IVNextSavePolicyCommand dependency injection alongside existing ISavePolicyCommand across services and controllers
  • Implemented feature flag checks that route policy saves to either the new VNext command or legacy command based on the PolicyValidatorsRefactor flag
  • 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 PolicyValidatorsRefactor feature 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 ToSavePolicyModel method 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.

@r-tome r-tome changed the title Ac/pm 26690/use vnextsavepolicycommand [PM-26690] Wire VNextSavePolicyCommand behind PolicyValidatorsRefactor feature flag Oct 24, 2025
@r-tome r-tome marked this pull request as ready for review October 24, 2025 10:34
@r-tome r-tome requested review from a team as code owners October 24, 2025 10:34
Copy link
Contributor

@JimmyVo16 JimmyVo16 left a 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()));
Copy link
Contributor

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.
@sonarqubecloud
Copy link

@r-tome r-tome requested a review from JimmyVo16 October 27, 2025 15:15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

4 participants