Skip to content

Commit 1d156c9

Browse files
pbolingCopilot
andcommitted
Avoid JRuby EC PEM round trip in specs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2fdc6c6 commit 1d156c9

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

.rubocop_gradual.lock

Lines changed: 2 additions & 2 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:3056129689": [
9+
"spec/lib/omniauth/strategies/jwt_spec.rb:268640036": [
1010
[3, 1, 40, "RSpec/SpecFilePathFormat: Spec path should end with `omni_auth/strategies/jwt*_spec.rb`.", 1545891400],
1111
[20, 13, 25, "RSpec/DescribedClass: Use `described_class` instead of `OmniAuth::Strategies::JWT`.", 2234488924],
1212
[32, 11, 15, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 391893083],
1313
[42, 11, 16, "RSpec/ContextWording: Context description should match /^when\\b/, /^with\\b/, or /^without\\b/.", 1409468707],
1414
[129, 9, 20, "RSpec/StubbedMock: Prefer `allow` over `expect` when configuring a response.", 2951559342],
1515
[133, 5, 125, "RSpec/LeakyLocalVariable: Do not use local variables defined outside of examples inside of them.", 689775740],
1616
[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]
17+
[179, 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],

spec/lib/omniauth/strategies/jwt_spec.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,27 @@ def generate_ec_private_key(curve_name)
145145
algorithms.each do |algorithm|
146146
context "when the #{algorithm} algorithm is used" do
147147
let(:algorithm) { algorithm }
148+
let(:ecdsa_private_key) { generate_ec_private_key(ecdsa_named_curves[algorithm]) }
148149
let(:secret) do
149150
# rubocop:disable Style/CaseLikeIf
150151
if private_key_class == OpenSSL::PKey::RSA
151152
private_key_class.generate(2048)
152153
.to_pem
153154
elsif private_key_class == OpenSSL::PKey::EC
154-
generate_ec_private_key(ecdsa_named_curves[algorithm])
155-
.to_pem
155+
ecdsa_private_key.to_pem
156156
else
157157
private_key_class.new(rand_secret)
158158
end
159159
# rubocop:enable Style/CaseLikeIf
160160
end
161161

162-
let(:private_key) { private_key_class ? private_key_class.new(secret) : secret }
162+
let(:private_key) do
163+
if private_key_class == OpenSSL::PKey::EC
164+
ecdsa_private_key
165+
else
166+
private_key_class.new(secret)
167+
end
168+
end
163169

164170
it "decodes the user information" do
165171
result = subject.decoded

0 commit comments

Comments
 (0)