diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gemnasium_maven_spec.rb | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/spec/gemnasium_maven_spec.rb b/spec/gemnasium_maven_spec.rb index 60d7a87..6b470da 100644 --- a/spec/gemnasium_maven_spec.rb +++ b/spec/gemnasium_maven_spec.rb @@ -1,43 +1,45 @@ require 'openssl' RSpec.describe 'gemnasium-maven' do - context "when scanning a java project with packages from a custom source" do - subject do - docker.build(tag: docker_image) - return {} unless docker.run(image: docker_image, project_path: project_path, env: env) + ['8', '11', '14'].each do |java_version| + context "when scanning a java #{java_version} project with packages from a custom source" do + subject do + docker.build(tag: docker_image) + return {} unless docker.run(image: docker_image, project_path: project_path, env: env) - DependencyScanningReport.new(project_path: project_path) - end + DependencyScanningReport.new(project_path: project_path) + end - let(:docker) { Docker.new(pwd: Pathname.pwd.join('src/gemnasium-maven')) } - let(:project_path) { project.path } - let(:docker_image) { 'gemnasium-maven:latest' } - let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509 } } - let(:project) { Project.new } - let(:x509) do - rsa_key = OpenSSL::PKey::RSA.new(4096) - certificate = OpenSSL::X509::Certificate.new - certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/C=/ST=/L=/O=/OU=/CN=") - certificate.not_before = Time.now.to_i - certificate.not_after = Time.now.to_i + 600 - certificate.public_key = rsa_key.public_key - certificate.serial = 0x01 - certificate.version = 2 - certificate.sign(rsa_key, OpenSSL::Digest::SHA256.new) - certificate.to_pem - end + let(:docker) { Docker.new(pwd: Pathname.pwd.join('src/gemnasium-maven')) } + let(:project_path) { project.path } + let(:docker_image) { 'gemnasium-maven:latest' } + let(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509, 'DS_JAVA_VERSION' => java_version } } + let(:project) { Project.new } + let(:x509) do + rsa_key = OpenSSL::PKey::RSA.new(4096) + certificate = OpenSSL::X509::Certificate.new + certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/C=/ST=/L=/O=/OU=/CN=") + certificate.not_before = Time.now.to_i + certificate.not_after = Time.now.to_i + 600 + certificate.public_key = rsa_key.public_key + certificate.serial = 0x01 + certificate.version = 2 + certificate.sign(rsa_key, OpenSSL::Digest::SHA256.new) + certificate.to_pem + end - around(:example) do |example| - project.mount(dir: fixture_file('java/maven/custom-tls')) - example.run - project.cleanup - end + around(:example) do |example| + project.mount(dir: fixture_file('java/maven/custom-tls')) + example.run + project.cleanup + end - specify do - expect(subject.to_h['dependency_files'].count).to eql(1) - expect(subject.to_h['dependency_files'][0]['dependencies'].count).to eql(1) - expect(subject.to_h['dependency_files'][0]['dependencies'][0]['package']['name']).to eql('com.fasterxml.jackson.core/jackson-core') - expect(subject.to_h['dependency_files'][0]['dependencies'][0]['version']).to eql('2.10.0') + specify do + expect(subject.to_h['dependency_files'].count).to eql(1) + expect(subject.to_h['dependency_files'][0]['dependencies'].count).to eql(1) + expect(subject.to_h['dependency_files'][0]['dependencies'][0]['package']['name']).to eql('com.fasterxml.jackson.core/jackson-core') + expect(subject.to_h['dependency_files'][0]['dependencies'][0]['version']).to eql('2.10.0') + end end end end |
