diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-14 16:11:33 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-14 16:11:33 -0600 |
| commit | cea7d78e2d7f1a8f98880819b8589925b5daef1a (patch) | |
| tree | 826d3288962b0925cc291602b72153a26c45b46b | |
| parent | 018f54f7af434dfaadfdfb36687a59e2069b7a8c (diff) | |
Write a test to scan a java project
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | docker-compose.yml | 2 | ||||
| -rw-r--r-- | spec/gemnasium_maven_spec.rb | 21 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 2 | ||||
| m--------- | src/gemnasium-maven | 0 |
5 files changed, 28 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cec303e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/gemnasium-maven"] + path = src/gemnasium-maven + url = git@gitlab.com:gitlab-org/security-products/analyzers/gemnasium-maven.git diff --git a/docker-compose.yml b/docker-compose.yml index 6c132f7..a330dbe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,3 +2,5 @@ version: '3' services: gemnasium-maven: image: registry.gitlab.com/gitlab-org/security-products/analyzers/gemnasium-maven:2 + haproxy: + image: haproxy:latest diff --git a/spec/gemnasium_maven_spec.rb b/spec/gemnasium_maven_spec.rb new file mode 100644 index 0000000..63c9aae --- /dev/null +++ b/spec/gemnasium_maven_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe 'gemnasium-maven' do + context "when scanning a java project with packages from a custom source" do + subject do + Dir.chdir Pathname.pwd.join('src/gemnasium-maven') do + system("docker build --network=host -t #{docker_image} .") + + if system([ :docker, :run, '-it', '--rm', '--volume', "#{project_path}:/tmp/app", '--network=host', '--env', 'CI_PROJECT_DIR=/tmp/app', docker_image, '/analyzer run' ].map(&:to_s).join(' ')) + report_path = project_path.join('gl-license-scanning-report.json') + report_path.exist? ? JSON.parse(report_path.read) : {} + else + {} + end + end + end + + let(:project_path) { Dir.pwd } + let(:docker_image) { 'gemnasium-maven:latest' } + + specify { expect(subject.count).to eql(1) } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 251aa51..8cfc067 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,8 @@ # it. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'json' + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest diff --git a/src/gemnasium-maven b/src/gemnasium-maven new file mode 160000 +Subproject 1978f8510199a5a3a6908c2ab6b4065c9218f9c |
