diff options
| author | mo khan <mo.khan@gmail.com> | 2020-07-13 09:57:29 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-08-21 16:31:57 -0600 |
| commit | cbc4d1e328fd0e578f038d57fbd6b9354dafa79e (patch) | |
| tree | 99b53a90cd7c0996a2d0993b41eb56a695bcc996 /spec/integration | |
| parent | eb11eeb1018c4d32e8dbaf3f734e588205f0671f (diff) | |
Install tools from .deb package
Diffstat (limited to 'spec/integration')
| -rw-r--r-- | spec/integration/dotnet/nuget_spec.rb | 1 | ||||
| -rw-r--r-- | spec/integration/java/gradle_spec.rb | 6 | ||||
| -rw-r--r-- | spec/integration/java/maven_spec.rb | 42 | ||||
| -rw-r--r-- | spec/integration/python/pip_spec.rb | 59 | ||||
| -rw-r--r-- | spec/integration/python/pipenv_spec.rb | 4 | ||||
| -rw-r--r-- | spec/integration/ruby/bundler_spec.rb | 17 |
6 files changed, 37 insertions, 92 deletions
diff --git a/spec/integration/dotnet/nuget_spec.rb b/spec/integration/dotnet/nuget_spec.rb index c72296e..f640c32 100644 --- a/spec/integration/dotnet/nuget_spec.rb +++ b/spec/integration/dotnet/nuget_spec.rb @@ -8,6 +8,7 @@ RSpec.describe "nuget" do let(:env) { {} } before do + system("rm -fr /opt/asdf/installs/mono") system("rm -fr /opt/gitlab/.nuget/packages") end diff --git a/spec/integration/java/gradle_spec.rb b/spec/integration/java/gradle_spec.rb index 25d7e26..e6bda3c 100644 --- a/spec/integration/java/gradle_spec.rb +++ b/spec/integration/java/gradle_spec.rb @@ -122,10 +122,10 @@ plugins { runner.add_file('.tool-versions', "gradle 1.9") end - it 'returns an empty report because the plugin we use does not work in this version of the gradle API' do + specify do expect(subject).to match_schema - expect(subject[:dependencies]).to be_empty - expect(subject[:licenses]).to be_empty + expect(subject.dependency_names).to match_array(['postgresql']) + expect(subject.licenses_for('postgresql')).to match_array(['BSD-2-Clause']) end end diff --git a/spec/integration/java/maven_spec.rb b/spec/integration/java/maven_spec.rb index 65d8bf5..217035d 100644 --- a/spec/integration/java/maven_spec.rb +++ b/spec/integration/java/maven_spec.rb @@ -114,48 +114,6 @@ RSpec.describe "maven" do specify { expect(report.licenses_for('jackson-core')).to match_array(['Apache-2.0']) } end - context "when specifying the version of java using environment variables" do - let(:output_file) { Pathname.new(runner.project_path.join('output.txt')) } - - before do - runner.add_file('custom.sh') do - <<~SCRIPT - #!/bin/bash -l - - java -version &> '#{output_file}' - SCRIPT - end - end - - it 'prioritizes `LM_JAVA_VERSION` over the `ASDF_JAVA_VERSION`' do - runner.scan(env: { - 'ASDF_JAVA_VERSION' => 'adopt-openjdk-11.0.7+10', - 'LM_JAVA_VERSION' => '8', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('openjdk version "1.8.0_252"') - end - - it 'reads the ASDF_JAVA_VERSION' do - runner.scan(env: { - 'ASDF_JAVA_VERSION' => 'adopt-openjdk-11.0.7+10.1', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('openjdk version "11.0.7"') - end - - it 'defaults to java 8' do - runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) - - expect(output_file).to exist - expect(output_file.read).to include('openjdk version "1.8.0_252"') - end - end - [ { java: '8', maven: ['3.6.3', '3.5.4', '3.3.9', '3.2.5'] }, { java: '11', maven: ['3.6.3', '3.5.4', '3.3.9', '3.2.5'] } diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 9911dc5..8b7d43b 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' RSpec.describe "pip" do + before do + system('rm -fr /opt/asdf/installs/python') + end + context "when a project depends on the latest version of pip" do let(:requirements) { "sentry-sdk>=0.7.7" } @@ -65,18 +69,21 @@ RSpec.describe "pip" do [{ version: '2', commit: '04dce91b' }, { version: '3', commit: '48e250a1' }].each do |python| ['1.0', '1.1', '2.0', '2.1'].each do |report_version| context "when generating a `#{report_version}` report using Python `#{python[:version]}`" do + subject { runner.scan(env: environment) } + let(:url) { "https://gitlab.com/gitlab-org/security-products/tests/#{language}-#{package_manager}.git" } let(:language) { 'python' } let(:package_manager) { 'pip' } let(:environment) { { 'LM_REPORT_VERSION' => report_version, 'LM_PYTHON_VERSION' => python[:version] } } let(:expected_content) { fixture_file_content("expected/#{language}/#{python[:version]}/#{package_manager}/v#{report_version}.json").chomp } - it 'matches the expected report' do + before do runner.clone(url, branch: python[:commit]) - report = runner.scan(env: environment) + end - expect(JSON.pretty_generate(report.to_h)).to eq(expected_content) - expect(report).to match_schema(version: report_version) + it 'matches the expected report' do + expect(JSON.pretty_generate(subject.to_h)).to eq(expected_content) + expect(subject).to match_schema(version: report_version) end end end @@ -134,8 +141,8 @@ RSpec.describe "pip" do report = runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) expect(report).to match_schema(version: '2.0') - expect(report.licenses_for('six')).to match_array(["MIT"]) expect(report.dependency_names).to contain_exactly('six') + expect(report.licenses_for('six')).to match_array(["MIT"]) end end @@ -187,46 +194,4 @@ RSpec.describe "pip" do expect(report.licenses_for('requests')).to match_array(['Apache-2.0']) end end - - context "when specifying the version of Python using environment variables" do - let(:output_file) { Pathname.new(runner.project_path.join('output.txt')) } - - before do - runner.add_file('custom.sh') do - <<~SCRIPT - #!/bin/bash -l - - python --version &> '#{output_file}' - SCRIPT - end - end - - it 'prioritizes `LM_PYTHON_VERSION` over the `ASDF_PYTHON_VERSION`' do - runner.scan(env: { - 'ASDF_PYTHON_VERSION' => '3.8.2', - 'LM_PYTHON_VERSION' => '2.7.18', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('2.7.18') - end - - it 'reads the ASDF_PYTHON_VERSION' do - runner.scan(env: { - 'ASDF_PYTHON_VERSION' => '3.8.2', - 'SETUP_CMD' => 'bash custom.sh' - }) - - expect(output_file).to exist - expect(output_file.read).to include('3.8.2') - end - - it 'defaults to Python 3' do - runner.scan(env: { 'SETUP_CMD' => 'bash custom.sh' }) - - expect(output_file).to exist - expect(output_file.read).to include('3.8.2') - end - end end diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index cd20522..fad3edf 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -7,6 +7,10 @@ RSpec.describe "pipenv" do let(:env) { {} } + before do + system('rm -fr /opt/asdf/installs/python') + end + include_examples "each report version", "python", "pipenv", "pip-file-lock" context "when a project depends on a version 6 Pipfile.lock" do diff --git a/spec/integration/ruby/bundler_spec.rb b/spec/integration/ruby/bundler_spec.rb index 6cb5543..1c0e472 100644 --- a/spec/integration/ruby/bundler_spec.rb +++ b/spec/integration/ruby/bundler_spec.rb @@ -7,6 +7,10 @@ RSpec.describe "bundler" do let(:env) { {} } + before do + system('rm -fr /opt/asdf/installs/ruby') + end + 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 @@ -89,6 +93,19 @@ RSpec.describe "bundler" do end end + context "when scanning the `gitlab-runner` project" do + before do + runner.clone('https://gitlab.com/gitlab-org/gitlab-runner.git') + 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('gitlab.com/gitlab-org/gitlab-terminal') + end + end + context "when fetching dependencies from a custom registry" do before do add_host('rubygems.test', '127.0.0.1') |
