Skip to content

Commit

Permalink
fix tests on jruby
Browse files Browse the repository at this point in the history
  • Loading branch information
duritong committed Nov 28, 2024
1 parent 791ca9e commit 18da665
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions spec/trocla/formats/x509_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def verify(ca,cert)
expect((Date.parse(cert.not_after.localtime.to_s) - Date.today).to_i).to eq(365)
# it's a self signed cert and NOT a CA
# Change of behavior on openssl side: https://github.com/openssl/openssl/issues/15146
validates_self_even_if_no_ca = Gem::Version.new(%x{openssl version}.split(' ')[1]) > Gem::Version.new('1.1.1g')
validates_self_even_if_no_ca = RUBY_ENGINE == 'jruby' ? true : Gem::Version.new(%x{openssl version}.split(' ')[1]) > Gem::Version.new('1.1.1g')
expect(verify(cert,cert)).to be validates_self_even_if_no_ca

v = cert.extensions.find{|e| e.oid == 'basicConstraints' }.value
Expand Down Expand Up @@ -311,8 +311,7 @@ def verify(ca,cert)
expect(cert.subject.to_s).to match(/#{field}=#{co[field]}/)
end
expect(cert.subject.to_s).to match(/(Email|emailAddress)=#{co['emailAddress']}/)
hash_match = (defined?(RUBY_ENGINE) &&RUBY_ENGINE == 'jruby') ? 'RSA-SHA512' : 'sha512WithRSAEncryption'
expect(cert.signature_algorithm).to eq(hash_match)
expect(cert.signature_algorithm).to eq('sha512WithRSAEncryption')
expect(cert.not_before).to be < Time.now
expect((Date.parse(cert.not_after.localtime.to_s) - Date.today).to_i).to eq(3650)
# https://stackoverflow.com/questions/13747212/determine-key-size-from-public-key-pem-format
Expand Down

0 comments on commit 18da665

Please sign in to comment.