Skip to content

Commit bec9291

Browse files
committed
Make specs test what they claim they are testing
1 parent 74c11d0 commit bec9291

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

spec/jwt/jwt_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
data[alg] = JWT.encode(payload, data["#{alg}_private"], alg)
170170
end
171171

172-
let(:wrong_key) { test_pkey('ec256-wrong-public.pem') }
172+
let(:wrong_key) { OpenSSL::PKey::EC.generate(data["#{alg}_private"].group.curve_name) }
173173

174174
it 'should generate a valid token' do
175175
jwt_payload, header = JWT.decode data[alg], data["#{alg}_public"], true, algorithm: alg
@@ -185,10 +185,10 @@
185185
expect(jwt_payload).to eq payload
186186
end
187187

188-
it 'wrong key should raise JWT::SignatureError' do
188+
it 'wrong key should raise JWT::VerificationError' do
189189
expect do
190-
JWT.decode data[alg], wrong_key
191-
end.to raise_error JWT::SignatureError
190+
JWT.decode data[alg], wrong_key, true, algorithm: alg
191+
end.to raise_error JWT::VerificationError
192192
end
193193

194194
it 'wrong key and verify = false should not raise an error' do
@@ -234,10 +234,10 @@
234234
expect(jwt_payload).to eq payload
235235
end
236236

237-
it 'wrong key should raise JWT::SignatureError' do
237+
it 'wrong key should raise JWT::VerificationError' do
238238
expect do
239-
JWT.decode data[alg], wrong_key
240-
end.to raise_error JWT::SignatureError
239+
JWT.decode data[alg], wrong_key, true, algorithm: alg
240+
end.to raise_error JWT::VerificationError
241241
end
242242

243243
it 'wrong key and verify = false should not raise an error' do

0 commit comments

Comments
 (0)