Skip to content

Commit 6eea8ee

Browse files
pbolingCopilot
andcommitted
Fix JRuby EC key generation specs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0021fc8 commit 6eea8ee

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

.rubocop_gradual.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
[166, 3, 39, "Gemspec/DependencyVersion: Dependency version specification is required.", 190611830],
77
[167, 3, 45, "Gemspec/DependencyVersion: Dependency version specification is required.", 1496807756]
88
],
9-
"spec/lib/omniauth/strategies/jwt_spec.rb:1409726614": [
9+
"spec/lib/omniauth/strategies/jwt_spec.rb:3056129689": [
1010
[3, 1, 40, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1545891400],
11-
[12, 13, 25, "RSpec/DescribedClass: Use `described_class` instead of `OmniAuth::Strategies::JWT`.", 2234488924],
12-
[24, 11, 15, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 391893083],
13-
[34, 11, 16, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1409468707],
14-
[121, 9, 20, "RSpec/StubbedMock: Prefer `allow` over `expect` when configuring a response.", 2951559342],
15-
[125, 5, 125, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 689775740],
16-
[135, 5, 56, "Performance/RedundantMerge: Use `algos[OpenSSL::PKey::EC] = %w[ES256 ES384 ES512]` instead of `algos.merge!(OpenSSL::PKey::EC => %w[ES256 ES384 ES512])`.", 2983772293],
17-
[165, 13, 28, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1877551307]
11+
[20, 13, 25, "RSpec/DescribedClass: Use `described_class` instead of `OmniAuth::Strategies::JWT`.", 2234488924],
12+
[32, 11, 15, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 391893083],
13+
[42, 11, 16, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1409468707],
14+
[129, 9, 20, "RSpec/StubbedMock: Prefer `allow` over `expect` when configuring a response.", 2951559342],
15+
[133, 5, 125, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 689775740],
16+
[143, 5, 56, "Performance/RedundantMerge: Use `algos[OpenSSL::PKey::EC] = %w[ES256 ES384 ES512]` instead of `algos.merge!(OpenSSL::PKey::EC => %w[ES256 ES384 ES512])`.", 2983772293],
17+
[173, 13, 28, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1877551307]
1818
],
1919
"spec/spec_helper.rb:2608937500": [
2020
[50, 3, 34, "RSpec/Output: Do not write to stdout in specs.", 1097326571],

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Please file a bug if you notice a violation of semantic versioning.
2828

2929
### Fixed
3030

31+
- Restored JRuby 9.2 and 9.3 CI coverage for ECDSA JWT decode specs by using
32+
the older OpenSSL EC key generation API when `OpenSSL::PKey::EC.generate` is
33+
unavailable.
34+
3135
### Security
3236

3337
## [0.1.1] - 2026-06-16

spec/lib/omniauth/strategies/jwt_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
require "spec_helper"
22

33
RSpec.describe OmniAuth::Strategies::JWT do
4+
def generate_ec_private_key(curve_name)
5+
return OpenSSL::PKey::EC.generate(curve_name) if OpenSSL::PKey::EC.respond_to?(:generate)
6+
7+
key = OpenSSL::PKey::EC.new(curve_name)
8+
key.generate_key
9+
key
10+
end
11+
412
let(:response_json) { JSON.parse(last_response.body) }
513
let(:rand_secret) { SecureRandom.hex(10) }
614
let(:args) { [rand_secret, {auth_url: "http://example.com/login"}] }
@@ -143,7 +151,7 @@
143151
private_key_class.generate(2048)
144152
.to_pem
145153
elsif private_key_class == OpenSSL::PKey::EC
146-
private_key_class.generate(ecdsa_named_curves[algorithm])
154+
generate_ec_private_key(ecdsa_named_curves[algorithm])
147155
.to_pem
148156
else
149157
private_key_class.new(rand_secret)

0 commit comments

Comments
 (0)