Skip to content

Commit 3b11042

Browse files
committed
Better reasons to skip tests
1 parent e7fceee commit 3b11042

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/jwt/version.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def self.openssl_3?
2727
end
2828

2929
def self.openssl_3_hmac_empty_key_regression?
30-
openssl_3? && ::Gem::Version.new(OpenSSL::VERSION) <= ::Gem::Version.new('3.0.0')
30+
openssl_3? && openssl_version <= ::Gem::Version.new('3.0.0')
31+
end
32+
33+
def self.openssl_version
34+
@openssl_version ||= ::Gem::Version.new(OpenSSL::VERSION)
3135
end
3236
end

spec/jwk/rsa_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@
171171
context 'when e, n, d is given' do
172172
let(:jwk_parameters) { all_jwk_parameters.slice(:e, :n, :d) }
173173

174+
before do
175+
skip 'OpenSSL prior to 2.2 does not seem to support partial parameters' if ::JWT.openssl_version < ::Gem::Version.new('2.2')
176+
end
177+
174178
it 'creates a valid RSA object representing a private key' do
175179
expect(subject).to be_a(::OpenSSL::PKey::RSA)
176180
expect(subject.private?).to eq(true)
@@ -196,8 +200,8 @@
196200

197201
describe '.create_rsa_key_using_sets' do
198202
before do
199-
skip unless OpenSSL::PKey::RSA.new.respond_to?(:set_key)
200-
skip if ::JWT.openssl_3?
203+
skip 'OpenSSL without the RSA#set_key method not supported' unless OpenSSL::PKey::RSA.new.respond_to?(:set_key)
204+
skip 'OpenSSL 3.0 does not allow mutating objects anymore' if ::JWT.openssl_3?
201205
end
202206

203207
subject(:rsa) { described_class.create_rsa_key_using_sets(rsa_parameters) }
@@ -208,7 +212,7 @@
208212

209213
describe '.create_rsa_key_using_accessors' do
210214
before do
211-
skip if OpenSSL::PKey::RSA.new.respond_to?(:set_key)
215+
skip 'OpenSSL if RSA#set_key is available there is no accessors anymore' if OpenSSL::PKey::RSA.new.respond_to?(:set_key)
212216
end
213217

214218
subject(:rsa) { described_class.create_rsa_key_using_accessors(rsa_parameters) }

0 commit comments

Comments
 (0)