Commit 667eebf7 authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '330918-add-conan' into 'master'

Add Conan packages to the `list project dependencies` API

See merge request gitlab-org/gitlab!67884
parents c51f6599 09e1b50f
...@@ -4,7 +4,7 @@ module Security ...@@ -4,7 +4,7 @@ module Security
class DependencyListService class DependencyListService
SORT_BY_VALUES = %w(name packager severity).freeze SORT_BY_VALUES = %w(name packager severity).freeze
SORT_VALUES = %w(asc desc).freeze SORT_VALUES = %w(asc desc).freeze
FILTER_PACKAGE_MANAGERS_VALUES = %w(bundler yarn npm maven composer pip).freeze FILTER_PACKAGE_MANAGERS_VALUES = %w(bundler yarn npm maven composer pip conan).freeze
FILTER_VALUES = %w(all vulnerable).freeze FILTER_VALUES = %w(all vulnerable).freeze
# @param pipeline [Ci::Pipeline] # @param pipeline [Ci::Pipeline]
......
...@@ -38,11 +38,35 @@ RSpec.describe Security::DependencyListService do ...@@ -38,11 +38,35 @@ RSpec.describe Security::DependencyListService do
context 'with params' do context 'with params' do
context 'filtered by package_managers' do context 'filtered by package_managers' do
let(:params) { { package_manager: 'bundler' } } using RSpec::Parameterized::TableSyntax
before do
dependencies = described_class::FILTER_PACKAGE_MANAGERS_VALUES.map do |package_manager|
build(:dependency, package_manager: package_manager)
end
allow(pipeline).to receive_message_chain(:dependency_list_report, :dependencies).and_return(dependencies)
end
context 'with matching package manager' do
where(package_manager: described_class::FILTER_PACKAGE_MANAGERS_VALUES)
with_them do
let(:params) { { package_manager: package_manager } }
it 'returns filtered items' do it 'returns filtered items' do
expect(subject.size).to eq(2) expect(subject.size).to eq(1)
expect(subject.first[:packager]).to eq('Ruby (Bundler)') expect(subject.first[:package_manager]).to eq(package_manager)
end
end
end
context 'with invalid package manager' do
let(:params) { { package_manager: 'package_manager' } }
it 'returns nothing' do
expect(subject.size).to eq(0)
end
end end
end end
......
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