Commit bf7b8903 authored by Fernando's avatar Fernando

Add presenter unit tests for feature flag cases

* Update tests
parent 3fc05282
......@@ -98,6 +98,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
context "when coverage fuzzing has run in a pipeline with feature flag off" do
before do
stub_feature_flags(corpus_management: false)
pipeline = create(
:ci_pipeline,
:auto_devops_source,
......@@ -105,7 +106,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
ref: project.default_branch,
sha: project.commit.sha
)
create(:ee_ci_build, :coverage_fuzzing, pipeline: pipeline, status: 'success')
create(:ci_build, :coverage_fuzzing, pipeline: pipeline, status: 'success')
end
it 'reports that coverage fuzzing, corpus management, and DAST are configured' do
......@@ -117,7 +118,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
security_scan(:dependency_scanning, configured: false),
security_scan(:license_scanning, configured: false),
security_scan(:secret_detection, configured: false),
security_scan(:coverage_fuzzing, configured: false),
security_scan(:coverage_fuzzing, configured: true),
security_scan(:api_fuzzing, configured: false),
security_scan(:dast_profiles, configured: true),
security_scan(:corpus_management, configured: true)
......@@ -135,7 +136,7 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
ref: project.default_branch,
sha: project.commit.sha
)
create(:ee_ci_build, :coverage_fuzzing, pipeline: pipeline, status: 'success')
create(:ci_build, :coverage_fuzzing, pipeline: pipeline, status: 'success')
end
it 'reports that coverage fuzzing, corpus management, and DAST are configured' do
......@@ -147,10 +148,10 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
security_scan(:dependency_scanning, configured: false),
security_scan(:license_scanning, configured: false),
security_scan(:secret_detection, configured: false),
security_scan(:coverage_fuzzing, configured: false),
security_scan(:coverage_fuzzing, configured: true),
security_scan(:api_fuzzing, configured: false),
security_scan(:dast_profiles, configured: true),
security_scan(:corpus_management, configured: true)
security_scan(:corpus_management, configured: true, configuration_path: project_security_configuration_corpus_management_path(project))
)
end
end
......@@ -305,13 +306,13 @@ RSpec.describe Projects::Security::ConfigurationPresenter do
end
end
def security_scan(type, configured:)
configuration_path = configuration_path(type)
def security_scan(type, configured:, configuration_path: nil)
path = configuration_path || configuration_path(type)
{
"type" => type.to_s,
"configured" => configured,
"configuration_path" => configuration_path,
"configuration_path" => path,
"available" => licensed_scan_types.include?(type)
}
end
......
......@@ -534,6 +534,14 @@ FactoryBot.define do
end
end
trait :coverage_fuzzing do
options do
{
artifacts: { reports: { coverage_fuzzing: 'gl-coverage-fuzzing-report.json' } }
}
end
end
trait :license_scanning do
options 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