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
|
require 'spec_helper'
RSpec.describe "bower" do
include_examples "each report version", "js", "bower"
context "when scanning a simple bower project" do
subject { runner.scan }
before do
runner.add_file('bower.json', fixture_file_content('js/bower/bower.json'))
end
specify { expect(subject).to match_schema }
specify { expect(subject.dependency_names).to match_array(['cli', 'ev-emitter', 'example-project', 'fizzy-ui-utils', 'get-size', 'jquery', 'masonry-layout', 'matches-selector', 'outlayer', 'stimulus.umd']) }
specify { expect(subject.licenses_for('cli')).to match_array(['Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'ISC', 'MIT']) }
specify { expect(subject.licenses_for('ev-emitter')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('example-project')).to match_array(['ISC']) }
specify { expect(subject.licenses_for('fizzy-ui-utils')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('get-size')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('jquery')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('masonry-layout')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('matches-selector')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('outlayer')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('stimulus.umd')).to match_array(['unknown']) }
end
context "when scanning a bower project with a dependency from a custom npm registry", environment: 'offline' do
subject { runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => fixture_file_content('js/custom-npm.crt') }) }
before do
runner.add_file(".npmrc", "registry = https://#{private_npm_host}")
runner.add_file(".bowerrc") do
JSON.pretty_generate({ resolvers: ['bower-npm-resolver'] })
end
runner.add_file("bower.json") do
JSON.pretty_generate({
name: "js-bower",
license: "ISC",
dependencies: { lodash: "npm:lodash#4.17.10" }
})
end
end
specify { expect(subject).to match_schema }
specify { expect(subject.dependency_names).to match_array(%w[js-bower lodash]) }
specify { expect(subject.licenses_for('js-bower')).to match_array(['ISC']) }
specify { expect(subject.licenses_for('lodash')).to match_array(['MIT']) }
end
[
'https://gitlab.com/gitlab-org/ci-training-slides',
'https://gitlab.com/gitlab-org/frontend/At.js.git',
'https://gitlab.com/gitlab-org/gitter/gitter-marked.git'
].each do |git_repo|
context "when scanning #{git_repo}" do
subject { runner.scan }
before do
runner.clone(git_repo)
end
specify { expect(subject).to match_schema }
specify { expect(subject.dependency_names).not_to be_empty }
end
end
end
|