diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/fixtures/c/conan/example-package/conanfile.py | 35 | ||||
| -rw-r--r-- | spec/fixtures/c/conan/example-project/.conan/.keep | 0 | ||||
| -rw-r--r-- | spec/fixtures/c/conan/example-project/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | spec/fixtures/c/conan/example-project/conanfile.txt.erb | 5 | ||||
| -rw-r--r-- | spec/fixtures/c/conan/example-project/main.c | 6 | ||||
| -rw-r--r-- | spec/integration/c/conan_spec.rb | 29 | ||||
| -rw-r--r-- | spec/integration/java/gradle_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/java/maven_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/js/bower_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/js/npm_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/js/yarn_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/python/pip_spec.rb | 2 | ||||
| -rw-r--r-- | spec/integration/python/pipenv_spec.rb | 2 |
13 files changed, 92 insertions, 7 deletions
diff --git a/spec/fixtures/c/conan/example-package/conanfile.py b/spec/fixtures/c/conan/example-package/conanfile.py new file mode 100644 index 0000000..3e6b7bc --- /dev/null +++ b/spec/fixtures/c/conan/example-package/conanfile.py @@ -0,0 +1,35 @@ +from conans import ConanFile, CMake, tools +import os + + +class ExampleConan(ConanFile): + name = "example" + version = "0.1" + license = "MIT" + author = "<Put your name here> <And your email here>" + url = "<Package recipe repository url here, for issues about the package>" + description = "<Description of Example here>" + topics = ("<Put some tag here>", "<here>", "<and here>") + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False]} + default_options = {"shared": False} + generators = "cmake" + + def source(self): + self.run("git clone --depth=1 --single-branch --branch master https://github.com/conan-io/hello.git") + + def build(self): + cmake = CMake(self) + cmake.configure(source_folder="hello") + cmake.build() + + def package(self): + self.copy("*.h", dst="include", src="hello") + self.copy("*hello.lib", dst="lib", keep_path=False) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.dylib", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["example"] diff --git a/spec/fixtures/c/conan/example-project/.conan/.keep b/spec/fixtures/c/conan/example-project/.conan/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/spec/fixtures/c/conan/example-project/.conan/.keep diff --git a/spec/fixtures/c/conan/example-project/CMakeLists.txt b/spec/fixtures/c/conan/example-project/CMakeLists.txt new file mode 100644 index 0000000..ed046e6 --- /dev/null +++ b/spec/fixtures/c/conan/example-project/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8) +project(example C) + +set(CMAKE_VERBOSE_MAKEFILE FALSE) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} main.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/spec/fixtures/c/conan/example-project/conanfile.txt.erb b/spec/fixtures/c/conan/example-project/conanfile.txt.erb new file mode 100644 index 0000000..e3d275f --- /dev/null +++ b/spec/fixtures/c/conan/example-project/conanfile.txt.erb @@ -0,0 +1,5 @@ +[requires] +example/0.1@<%= package_name %> + +[generators] +cmake diff --git a/spec/fixtures/c/conan/example-project/main.c b/spec/fixtures/c/conan/example-project/main.c new file mode 100644 index 0000000..5e8b15a --- /dev/null +++ b/spec/fixtures/c/conan/example-project/main.c @@ -0,0 +1,6 @@ +#include <hello.h> + +int main() { + hello(); + return 0; +} diff --git a/spec/integration/c/conan_spec.rb b/spec/integration/c/conan_spec.rb index 3c2ac45..cdbf029 100644 --- a/spec/integration/c/conan_spec.rb +++ b/spec/integration/c/conan_spec.rb @@ -61,4 +61,33 @@ RSpec.describe "conan" do specify { expect(subject.licenses_for('protobuf')).to match_array(['BSD-3-Clause']) } specify { expect(subject.licenses_for('protoc_installer')).to match_array(['BSD-3-Clause']) } end + + context "when pulling packages from a custom conan remote" do + subject { runner.scan } + + let(:package_name) { "#{project_namespace.tr('/', '+')}+#{project_name}/stable" } + let(:project_namespace) { ENV.fetch('CI_PROJECT_NAMESPACE', 'gitlab-org/security-products') } + let(:project_name) { ENV.fetch('CI_PROJECT_NAME', 'license-management') } + let(:api_url) { ENV.fetch('CI_API_V4_URL', 'https://gitlab.com/api/v4') } + + before do + runner.mount(dir: fixture_file('c/conan/example-project')) + runner.add_file('conanfile.txt', fixture_file_content('c/conan/example-project/conanfile.txt.erb', package_name: package_name)) + runner.add_file('.conan/remotes.json') do + JSON.pretty_generate({ + remotes: [ + { + name: 'gitlab', + url: "#{api_url}/packages/conan", + verify_ssl: true + } + ] + }) + end + end + + specify { expect(subject).to match_schema } + specify { expect(subject.dependency_names).to match_array(['example']) } + specify { expect(subject.licenses_for('example')).to match_array(['MIT']) } + end end diff --git a/spec/integration/java/gradle_spec.rb b/spec/integration/java/gradle_spec.rb index 25336c1..0e71038 100644 --- a/spec/integration/java/gradle_spec.rb +++ b/spec/integration/java/gradle_spec.rb @@ -49,7 +49,7 @@ plugins { end end - context 'when scanning a project that needs to connect to multiple TLS endpoints with different custom certificate chains' do + context 'when scanning a project that needs to connect to multiple TLS endpoints with different custom certificate chains', environment: 'offline' do subject do runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => fixture_file_content('java/gradle/offline-environment/bundle.crt'), diff --git a/spec/integration/java/maven_spec.rb b/spec/integration/java/maven_spec.rb index fa57752..85637b2 100644 --- a/spec/integration/java/maven_spec.rb +++ b/spec/integration/java/maven_spec.rb @@ -80,7 +80,7 @@ RSpec.describe "maven" do end end - context "when connecting to a custom package registry with a self signed certificate" do + context "when connecting to a custom package registry with a self signed certificate", environment: 'offline' do let(:bundle) { fixture_file_content('java/maven.crt') } let(:report) { runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => bundle, 'LOG_LEVEL' => 'debug' }) } diff --git a/spec/integration/js/bower_spec.rb b/spec/integration/js/bower_spec.rb index 5a4f72d..cc7cf9d 100644 --- a/spec/integration/js/bower_spec.rb +++ b/spec/integration/js/bower_spec.rb @@ -24,7 +24,7 @@ RSpec.describe "bower" do 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" do + 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 diff --git a/spec/integration/js/npm_spec.rb b/spec/integration/js/npm_spec.rb index 13cbd15..abc6fc0 100644 --- a/spec/integration/js/npm_spec.rb +++ b/spec/integration/js/npm_spec.rb @@ -465,7 +465,7 @@ RSpec.describe "npm" do end end - context "when scanning a project with dependencies sourced from a custom registry" do + context "when scanning a project with dependencies sourced from a custom registry", environment: 'offline' do subject { runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => fixture_file_content('js/custom-npm.crt') }) } before do diff --git a/spec/integration/js/yarn_spec.rb b/spec/integration/js/yarn_spec.rb index a5a9695..bacac47 100644 --- a/spec/integration/js/yarn_spec.rb +++ b/spec/integration/js/yarn_spec.rb @@ -150,7 +150,7 @@ RSpec.describe "yarn" do end end - context "when scanning a project with dependencies sourced from a custom registry" do + context "when scanning a project with dependencies sourced from a custom registry", environment: 'offline' do subject { runner.scan(env: { 'ADDITIONAL_CA_CERT_BUNDLE' => fixture_file_content('js/custom-npm.crt') }) } before do diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index f47bbe6..0ba3d0e 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -127,7 +127,7 @@ RSpec.describe "pip" do end end - context "when connecting to a private package repository with self signed certificate" do + context "when connecting to a private package repository with self signed certificate", environment: 'offline' do let(:index_url) { "https://#{private_pypi_host}/simple" } let(:bundle) { fixture_file_content('python/pypi.crt') } diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index ccc2585..b95f1fa 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -202,7 +202,7 @@ RSpec.describe "pipenv" do end end - context "when connecting to a private package repository with self signed certificate" do + context "when connecting to a private package repository with self signed certificate", environment: 'offline' do let(:index_url) { "https://#{private_pypi_host}/simple" } let(:bundle) { fixture_file_content('python/pypi.crt') } |
