blob: 5dbcc1991d4269b62e804806cb33905da847e40b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Ci::Reports::Sbom::Component, feature_category: :dependency_management do
let(:component_type) { 'library' }
let(:name) { 'component-name' }
let(:purl_type) { 'npm' }
let(:purl) { Sbom::PackageUrl.new(type: purl_type, name: name, version: version).to_s }
let(:version) { 'v0.0.1' }
subject(:component) do
described_class.new(
type: component_type,
name: name,
purl: purl,
version: version
)
end
it 'has correct attributes' do
expect(component).to have_attributes(
component_type: component_type,
name: name,
purl: an_object_having_attributes(type: purl_type),
version: version
)
end
describe '#ingestible?' do
subject { component.ingestible? }
context 'when component_type is invalid' do
let(:component_type) { 'invalid' }
it { is_expected.to be(false) }
end
context 'when purl_type is invalid' do
let(:purl_type) { 'invalid' }
it { is_expected.to be(false) }
end
context 'when component_type is valid' do
where(:component_type) { ::Enums::Sbom.component_types.keys.map(&:to_s) }
with_them do
it { is_expected.to be(true) }
end
end
context 'when purl_type is valid' do
where(:purl_type) { ::Enums::Sbom.purl_types.keys.map(&:to_s) }
with_them do
it { is_expected.to be(true) }
end
end
context 'when there is no purl' do
let(:purl) { nil }
it { is_expected.to be(true) }
end
end
end
|