blob: 30cf7763f505b5e4b5c42acf375185eb24552ed0 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
require 'spec_helper'
RSpec.describe "bundler" do
subject { runner.scan(env: env) }
let(:env) { {} }
include_examples "each report version", "ruby", "bundler"
context "when the project depends on an older version of ruby specified in a `.ruby-version` file" do
before do
runner.mount(dir: fixture_file('ruby/bundler-ruby-2.4.9-no-lockfile'))
end
it 'installs the required ruby and produces a valid report' do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject[:dependencies].map { |x| x[:name] }).to include("saml-kit")
end
end
context "when a project depends on an older version of bundler" do
before do
runner.mount(dir: fixture_file('ruby/bundler-v1.17'))
end
it 'produces a valid report' do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject.dependency_names).to include("saml-kit")
end
end
context "when a project depends on bundler `~> 2.1`" do
before do
runner.mount(dir: fixture_file('ruby/bundler-v2.1'))
end
it 'produces a valid report' do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject.dependency_names).to include('net-hippie')
expect(subject.licenses_for('net-hippie')).to match_array(['MIT'])
end
end
context "when passing custom options to license finder" do
let(:env) do
{
'LICENSE_FINDER_CLI_OPTS' => "--debug --aggregate-paths=. ruby"
}
end
before do
runner.clone('https://gitlab.com/gitlab-org/gitaly.git', branch: 'v12.10.13')
end
it 'forwards the options to license finder' do
expect(subject).to match_schema
expect(subject.dependency_names).to include('rbtrace')
end
end
context "when parsing a project with versions of gems that conflict with license_finder" do
before do
runner.mount(dir: fixture_file('ruby/bundler-gem-conflict'))
end
specify do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject[:dependencies]).not_to be_empty
expect(subject.dependency_names).to include('rails')
end
end
context "when scanning the `gitlab` project" do
before do
runner.clone('https://gitlab.com/gitlab-org/gitlab.git')
system("rm #{runner.project_path}/config/dependency_decisions.yml")
end
specify do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject[:dependencies]).not_to be_empty
expect(subject.dependency_names).to include('rails')
expect(subject.dependency_names).to include('vue')
end
end
context "when fetching dependencies from a custom registry" do
before do
add_host('rubygems.test', '127.0.0.1')
start_proxy_server
runner.mount(dir: fixture_file('ruby/bundler-custom-tls'))
end
context "when the CA certificate is provided" do
let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509_certificate('wildcard.test').read } }
specify do
expect(subject).to match_schema
expect(subject.dependency_names).to include("spandx")
expect(subject.licenses_for('spandx')).to match_array('MIT')
end
end
context "when the CA certificate is NOT provided" do
let(:env) { {} }
specify do
expect(subject).to match_schema
expect(subject.dependency_names).to be_empty
end
end
end
context "when fetching dependencies from a git repo" do
before do
runner.mount(dir: fixture_file('ruby/bundler-git-source'))
end
specify do
expect(subject).to match_schema
expect(subject.dependency_names).to include("net-hippie")
expect(subject.licenses_for('net-hippie')).to match_array(['MIT'])
end
end
context "when scanning a projects with a gems.lock" do
before do
runner.mount(dir: fixture_file('ruby/bundler-v2.1-gems.lock'))
end
specify do
expect(subject).to match_schema
expect(subject[:licenses]).not_to be_empty
expect(subject.dependency_names).to include('spandx')
expect(subject.licenses_for('spandx')).to match_array(['MIT'])
end
end
end
|