Commit b9b90d4c authored by Aishwarya Subramanian's avatar Aishwarya Subramanian

Fix group level compliance pipeline feature availability

Update policy feature flag check for group level
compliance pipeline configuration in graphql apis.
The attribute is gated behind
ff_evaluate_group_level_compliance_pipeline FF.
This is to keep it independent of the rollout of
compliance frameworks.
parent a2cab0ab
...@@ -177,7 +177,6 @@ class License < ApplicationRecord ...@@ -177,7 +177,6 @@ class License < ApplicationRecord
subepics subepics
threat_monitoring threat_monitoring
vulnerability_auto_fix vulnerability_auto_fix
evaluate_group_level_compliance_pipeline
] ]
EEU_FEATURES.freeze EEU_FEATURES.freeze
......
...@@ -11,7 +11,7 @@ module ComplianceManagement ...@@ -11,7 +11,7 @@ module ComplianceManagement
condition(:group_level_compliance_pipeline_enabled) do condition(:group_level_compliance_pipeline_enabled) do
@subject.namespace.feature_available?(:evaluate_group_level_compliance_pipeline) && @subject.namespace.feature_available?(:evaluate_group_level_compliance_pipeline) &&
Feature.enabled?(:ff_custom_compliance_frameworks, @subject.namespace) Feature.enabled?(:ff_evaluate_group_level_compliance_pipeline, @subject.namespace)
end end
rule { can?(:owner_access) & custom_compliance_frameworks_enabled }.policy do rule { can?(:owner_access) & custom_compliance_frameworks_enabled }.policy do
......
...@@ -135,7 +135,7 @@ module EE ...@@ -135,7 +135,7 @@ module EE
condition(:group_level_compliance_pipeline_available) do condition(:group_level_compliance_pipeline_available) do
@subject.feature_available?(:evaluate_group_level_compliance_pipeline) && @subject.feature_available?(:evaluate_group_level_compliance_pipeline) &&
::Feature.enabled?(:ff_custom_compliance_frameworks, @subject, default_enabled: :yaml) ::Feature.enabled?(:ff_evaluate_group_level_compliance_pipeline, @subject, default_enabled: :yaml)
end end
rule { public_group | logged_in_viewable }.policy do rule { public_group | logged_in_viewable }.policy do
......
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
module ComplianceManagement module ComplianceManagement
module Frameworks module Frameworks
def compliance_pipeline_configuration_available? def compliance_pipeline_configuration_available?
return true unless params[:pipeline_configuration_full_path].present? return true unless params.key?(:pipeline_configuration_full_path)
can? current_user, :manage_group_level_compliance_pipeline_config, framework available = can? current_user, :manage_group_level_compliance_pipeline_config, framework
params.delete(:pipeline_configuration_full_path) unless available
available
end end
end end
end end
...@@ -57,7 +57,9 @@ RSpec.describe ComplianceManagement::FrameworkPolicy do ...@@ -57,7 +57,9 @@ RSpec.describe ComplianceManagement::FrameworkPolicy do
context 'feature is disabled' do context 'feature is disabled' do
before do before do
stub_feature_flags(ff_custom_compliance_framework: false) stub_licensed_features(custom_compliance_frameworks: true, evaluate_group_level_compliance_pipeline: true)
stub_feature_flags(ff_custom_compliance_frameworks: false)
stub_feature_flags(ff_evaluate_group_level_compliance_pipeline: false)
end end
it { is_expected.to be_disallowed(:manage_compliance_framework) } it { is_expected.to be_disallowed(:manage_compliance_framework) }
......
...@@ -1569,7 +1569,7 @@ RSpec.describe GroupPolicy do ...@@ -1569,7 +1569,7 @@ RSpec.describe GroupPolicy do
end end
describe 'compliance framework permissions' do describe 'compliance framework permissions' do
shared_context 'compliance framework permissions' do shared_examples 'compliance framework permissions' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
where(:role, :licensed, :feature_flag, :admin_mode, :allowed) do where(:role, :licensed, :feature_flag, :admin_mode, :allowed) do
...@@ -1590,7 +1590,7 @@ RSpec.describe GroupPolicy do ...@@ -1590,7 +1590,7 @@ RSpec.describe GroupPolicy do
before do before do
stub_licensed_features(licensed_feature => licensed) stub_licensed_features(licensed_feature => licensed)
stub_feature_flags(ff_custom_compliance_frameworks: feature_flag) stub_feature_flags(feature_flag_name => feature_flag)
enable_admin_mode!(current_user) if admin_mode enable_admin_mode!(current_user) if admin_mode
end end
...@@ -1601,15 +1601,17 @@ RSpec.describe GroupPolicy do ...@@ -1601,15 +1601,17 @@ RSpec.describe GroupPolicy do
context ':admin_compliance_framework' do context ':admin_compliance_framework' do
let(:policy) { :admin_compliance_framework } let(:policy) { :admin_compliance_framework }
let(:licensed_feature) { :custom_compliance_frameworks } let(:licensed_feature) { :custom_compliance_frameworks }
let(:feature_flag_name) { :ff_custom_compliance_frameworks }
include_context 'compliance framework permissions' include_examples 'compliance framework permissions'
end end
context ':admin_compliance_pipeline_configuration' do context ':admin_compliance_pipeline_configuration' do
let(:policy) { :admin_compliance_pipeline_configuration } let(:policy) { :admin_compliance_pipeline_configuration }
let(:licensed_feature) { :evaluate_group_level_compliance_pipeline } let(:licensed_feature) { :evaluate_group_level_compliance_pipeline }
let(:feature_flag_name) { :ff_evaluate_group_level_compliance_pipeline }
include_context 'compliance framework permissions' include_examples 'compliance framework permissions'
end end
end end
......
...@@ -42,7 +42,7 @@ RSpec.describe 'Create a Compliance Framework' do ...@@ -42,7 +42,7 @@ RSpec.describe 'Create a Compliance Framework' do
end end
end end
context 'feature is unlicensed' do context 'framework feature is unlicensed' do
before do before do
stub_licensed_features(custom_compliance_frameworks: false) stub_licensed_features(custom_compliance_frameworks: false)
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
...@@ -51,12 +51,21 @@ RSpec.describe 'Create a Compliance Framework' do ...@@ -51,12 +51,21 @@ RSpec.describe 'Create a Compliance Framework' do
it_behaves_like 'a mutation that returns errors in the response', errors: ['Not permitted to create framework'] it_behaves_like 'a mutation that returns errors in the response', errors: ['Not permitted to create framework']
end end
context 'pipeline configuration feature is unlicensed' do
before do
stub_licensed_features(custom_compliance_frameworks: true, evaluate_group_level_compliance_pipeline: false)
post_graphql_mutation(mutation, current_user: current_user)
end
it_behaves_like 'a mutation that returns errors in the response', errors: ['Pipeline configuration full path feature is not available']
end
context 'feature is licensed' do context 'feature is licensed' do
before do before do
stub_licensed_features(custom_compliance_frameworks: true, evaluate_group_level_compliance_pipeline: true) stub_licensed_features(custom_compliance_frameworks: true, evaluate_group_level_compliance_pipeline: true)
end end
context 'feature is disabled' do context 'framework feature is disabled' do
before do before do
stub_feature_flags(ff_custom_compliance_frameworks: false) stub_feature_flags(ff_custom_compliance_frameworks: false)
end end
...@@ -64,6 +73,14 @@ RSpec.describe 'Create a Compliance Framework' do ...@@ -64,6 +73,14 @@ RSpec.describe 'Create a Compliance Framework' do
it_behaves_like 'a mutation that returns errors in the response', errors: ['Not permitted to create framework'] it_behaves_like 'a mutation that returns errors in the response', errors: ['Not permitted to create framework']
end end
context 'pipeline configuration feature is disabled' do
before do
stub_feature_flags(ff_evaluate_group_level_compliance_pipeline: false)
end
it_behaves_like 'a mutation that returns errors in the response', errors: ['Pipeline configuration full path feature is not available']
end
context 'current_user is namespace owner' do context 'current_user is namespace owner' do
it_behaves_like 'a mutation that creates a compliance framework' it_behaves_like 'a mutation that creates a compliance framework'
end end
......
...@@ -91,6 +91,19 @@ RSpec.describe 'Update a compliance framework' do ...@@ -91,6 +91,19 @@ RSpec.describe 'Update a compliance framework' do
expect(mutation_response['errors']).to contain_exactly "Pipeline configuration full path feature is not available" expect(mutation_response['errors']).to contain_exactly "Pipeline configuration full path feature is not available"
end end
end end
context 'when compliance pipeline configuration feature flag is not enabled' do
before do
stub_licensed_features(custom_compliance_frameworks: true, evaluate_group_level_compliance_pipeline: true)
stub_feature_flags(ff_evaluate_group_level_compliance_pipeline: false)
end
it 'returns an error' do
subject
expect(mutation_response['errors']).to contain_exactly "Pipeline configuration full path feature is not available"
end
end
end end
context 'current_user is not permitted to update framework' do context 'current_user is not permitted to update framework' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment