diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/fixtures/python/simple-setup.py | 5 | ||||
| -rw-r--r-- | spec/integration/python/pip_spec.rb | 32 | ||||
| -rw-r--r-- | spec/integration/python/pipenv_spec.rb | 9 | ||||
| -rw-r--r-- | spec/support/integration_test_helper.rb | 6 |
4 files changed, 39 insertions, 13 deletions
diff --git a/spec/fixtures/python/simple-setup.py b/spec/fixtures/python/simple-setup.py index 02ee1c4..51b96a2 100644 --- a/spec/fixtures/python/simple-setup.py +++ b/spec/fixtures/python/simple-setup.py @@ -1,12 +1,7 @@ #!/usr/bin/env python3 -import os -import shutil - from setuptools import find_packages from setuptools import setup -shutil.rmtree("build", ignore_errors=True) - setup( name="package name", version='1.1', diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 2183dd1..8e3ec3d 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -24,7 +24,6 @@ RSpec.describe "pip" do 'jsonschema>=3.0.0', 'python-json-logger>=0.1.10', 'sentry-sdk>=0.7.7', - 'https://s3-eu-west-1.amazonaws.com/new10-pypi/new10-logging-1.1.4.tar.gz', 'ptvsd', 'pylint', 'flake8', @@ -127,4 +126,35 @@ RSpec.describe "pip" do expect(report[:dependencies]).to be_empty end end + + context "when connecting to a private package repository with self signed certificate" do + let(:index_url) { "https://#{private_pypi_host}/simple" } + let(:bundle) { fixture_file_content('python/pypi.crt') } + + before do + runner.add_file('setup.py') do + <<~RAW +from setuptools import setup, find_packages + +setup( + name='gitlab-sp-test-python-pip', + version='1.2.0', + packages=find_packages(), + install_requires=['requests'], +) + RAW + end + end + + it 'downloads the packages and trusts the certificate' do + report = runner.scan(env: { + 'ADDITIONAL_CA_CERT_BUNDLE' => bundle, + 'PIP_INDEX_URL' => index_url + }) + + expect(report).to match_schema(version: '2.0') + expect(report.dependency_names).to include('requests') + expect(report.licenses_for('requests')).to match_array(['Apache-2.0']) + end + end end diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 9ec7d96..b54ee99 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -203,20 +203,15 @@ RSpec.describe "pipenv" do end context "when connecting to a private package repository with self signed certificate" do - let(:index_url) { "https://gitlab-airgap-pypi.us-west1-b.c.group-secure-a89fe7.internal/simple" } + let(:index_url) { "https://#{private_pypi_host}/simple" } let(:bundle) { fixture_file_content('python/pypi.crt') } - def install_airgap_hosts - add_host('gitlab-airgap-test.us-west1-b.c.group-secure-a89fe7.internal', '34.82.7.216') - add_host('gitlab-airgap-pypi.us-west1-b.c.group-secure-a89fe7.internal', '35.227.149.218') - end - before do runner.add_file('Pipfile', fixture_file_content('python/airgap-Pipfile.erb', index_url: index_url)) runner.add_file('Pipfile.lock', fixture_file_content('python/airgap-Pipfile.lock.erb', index_url: index_url)) end - pending 'downloads the packages and trusts the certificate' do + it 'downloads the packages and trusts the certificate' do report = runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => bundle, 'PIP_INDEX_URL' => index_url diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb index 6c30a99..52693f2 100644 --- a/spec/support/integration_test_helper.rb +++ b/spec/support/integration_test_helper.rb @@ -86,6 +86,12 @@ module IntegrationTestHelper end end + def private_pypi_host + @private_pypi_host ||= ENV.fetch('PRIVATE_PYPI_HOST').tap do |host| + add_host(host, ENV.fetch('PRIVATE_PYPI_IP')) + end + end + def runner(*args) @runner ||= IntegrationTestRunner.new(*args) end |
