diff options
| author | mo khan <mo.khan@gmail.com> | 2020-09-15 15:34:34 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-09-15 15:34:34 -0600 |
| commit | 4b46a3cbf564fcc79c54607be33923e8015d7031 (patch) | |
| tree | f44cd70e98346323032f0210328a77b4eab7c586 /spec | |
| parent | 3ff585b2fcc616c2b2f16bf82e312f91d920b472 (diff) | |
refactor: extract class to generate self signed certificate
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gemnasium_maven_spec.rb | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/spec/gemnasium_maven_spec.rb b/spec/gemnasium_maven_spec.rb index 90fde6e..d84050a 100644 --- a/spec/gemnasium_maven_spec.rb +++ b/spec/gemnasium_maven_spec.rb @@ -13,20 +13,9 @@ RSpec.describe 'gemnasium-maven' do 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(:env) { { 'ADDITIONAL_CA_CERT_BUNDLE' => x509.to_pem, '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 + let(:x509) { X509.self_signed } around(:example) do |example| project.mount(dir: fixture_file('java/maven/custom-tls')) |
