Skip to content

Fix issue where settings showed up without feature flags

What does this MR do and why?

Fix issue where settings showed up with feature fs

  • the policy yaml approval_settings needs to be updated when the rules are updated depending on the rule type because certain rules add additional settings
  • this should only happen when the proper feature flags are enabled that result in different settings being added
  • update tests

Changelog: fixed

EE: true

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Scenario 1

  1. Upload a GitLab Ultimate license
  2. Put the feature flags in the appropriate state with the following command
echo "Feature.disable(:scan_result_policy_settings) && Feature.disable(:scan_result_any_merge_request)" | rails c
  1. Navigate to a project => Secure => Policies => New policy => Scan Result Policy
  2. Verify the yaml does not have any approval_settings
  3. Select a policy type
  4. Verify the yaml does not have any approval_settings

Scenario 2

  1. Upload a GitLab Ultimate license
  2. Put the feature flags in the appropriate state with the following command
echo "Feature.enable(:scan_result_policy_settings) && Feature.disable(:scan_result_any_merge_request)" | rails c
  1. Navigate to a project => Secure => Policies => New policy => Scan Result Policy
  2. Verify the yaml has one setting in approval_settings
  3. Select a policy type
  4. Verify the yaml has one setting in approval_settings and it is unchanged

Scenario 3

  1. Upload a GitLab Ultimate license
  2. Put the feature flags in the appropriate state with the following command
echo "Feature.disable(:scan_result_policy_settings) && Feature.enable(:scan_result_any_merge_request)" | rails c
  1. Navigate to a project => Secure => Policies => New policy => Scan Result Policy
  2. Verify the yaml does not have any approval_settings
  3. Select the scan_result policy type
  4. Verify the yaml does not have any approval_settings
  5. Select the merge request policy type
  6. Verify the yaml does not have any approval_settings

Scenario 4

  1. Upload a GitLab Ultimate license
  2. Put the feature flags in the appropriate state with the following command
echo "Feature.enable(:scan_result_policy_settings) && Feature.enable(:scan_result_any_merge_request)" | rails c
  1. Navigate to a project => Secure => Policies => New policy => Scan Result Policy
  2. Verify the yaml has one setting in approval_settings
  3. Select the scan_result policy type
  4. Verify the yaml has one setting in approval_settings
  5. Select the merge request policy type
  6. Verify the yaml has many settings in approval_settings

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Scenario Before After
1 s1_-_b s1_-_a
2 s2_-_b s2_-_a
3 s3_-_b s3_-_a
4 s4_-_b s4_-_a

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #428538 (closed)

Edited by Alexander Turinske

Merge request reports