summaryrefslogtreecommitdiff
path: root/spec/integration/python
diff options
context:
space:
mode:
authorCan Eldem <celdem@gitlab.com>2020-09-02 10:20:37 +0000
committerCan Eldem <celdem@gitlab.com>2020-09-02 10:20:37 +0000
commit178dc1c91f9e43ee061825d1284bca694d6bbc65 (patch)
tree99b53a90cd7c0996a2d0993b41eb56a695bcc996 /spec/integration/python
parenteb11eeb1018c4d32e8dbaf3f734e588205f0671f (diff)
parentcbc4d1e328fd0e578f038d57fbd6b9354dafa79e (diff)
Merge branch '217897-offline-rubies' into 'master'v3.25.0
Install tools from Debian package. See merge request gitlab-org/security-products/license-management!188
Diffstat (limited to 'spec/integration/python')
-rw-r--r--spec/integration/python/pip_spec.rb59
-rw-r--r--spec/integration/python/pipenv_spec.rb4
2 files changed, 16 insertions, 47 deletions
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