debian-mirror-gitlab/spec/lib/gitlab/security/scan_configuration_spec.rb

70 lines
1.4 KiB
Ruby
Raw Normal View History

2022-01-26 12:08:38 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Gitlab::Security::ScanConfiguration do
2022-04-04 11:22:00 +05:30
using RSpec::Parameterized::TableSyntax
2022-01-26 12:08:38 +05:30
let_it_be(:project) { create(:project, :repository) }
let(:scan) { described_class.new(project: project, type: type, configured: configured) }
describe '#available?' do
subject { scan.available? }
let(:configured) { true }
context 'with a core scanner' do
2022-04-04 11:22:00 +05:30
where(type: %i(sast sast_iac secret_detection))
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
with_them do
it { is_expected.to be_truthy }
end
2022-01-26 12:08:38 +05:30
end
context 'with custom scanner' do
let(:type) { :my_scanner }
it { is_expected.to be_falsey }
end
end
describe '#configured?' do
subject { scan.configured? }
let(:type) { :sast }
let(:configured) { false }
it { is_expected.to be_falsey }
end
describe '#configuration_path' do
subject { scan.configuration_path }
let(:configured) { true }
2022-04-04 11:22:00 +05:30
let(:type) { :sast }
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
it { is_expected.to be_nil }
end
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
describe '#can_enable_by_merge_request?' do
subject { scan.can_enable_by_merge_request? }
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
let(:configured) { true }
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
context 'with a core scanner' do
where(type: %i(sast sast_iac secret_detection))
2022-01-26 12:08:38 +05:30
2022-04-04 11:22:00 +05:30
with_them do
it { is_expected.to be_truthy }
end
2022-01-26 12:08:38 +05:30
end
2022-04-04 11:22:00 +05:30
context 'with a custom scanner' do
2022-01-26 12:08:38 +05:30
let(:type) { :my_scanner }
2022-04-04 11:22:00 +05:30
it { is_expected.to be_falsey }
2022-01-26 12:08:38 +05:30
end
end
end