|
169 | 169 | data[alg] = JWT.encode(payload, data["#{alg}_private"], alg) |
170 | 170 | end |
171 | 171 |
|
172 | | - let(:wrong_key) { test_pkey('ec256-wrong-public.pem') } |
| 172 | + let(:wrong_key) { OpenSSL::PKey::EC.generate(data["#{alg}_private"].group.curve_name) } |
173 | 173 |
|
174 | 174 | it 'should generate a valid token' do |
175 | 175 | jwt_payload, header = JWT.decode data[alg], data["#{alg}_public"], true, algorithm: alg |
|
185 | 185 | expect(jwt_payload).to eq payload |
186 | 186 | end |
187 | 187 |
|
188 | | - it 'wrong key should raise JWT::SignatureError' do |
| 188 | + it 'wrong key should raise JWT::VerificationError' do |
189 | 189 | 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 |
192 | 192 | end |
193 | 193 |
|
194 | 194 | it 'wrong key and verify = false should not raise an error' do |
|
234 | 234 | expect(jwt_payload).to eq payload |
235 | 235 | end |
236 | 236 |
|
237 | | - it 'wrong key should raise JWT::SignatureError' do |
| 237 | + it 'wrong key should raise JWT::VerificationError' do |
238 | 238 | 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 |
241 | 241 | end |
242 | 242 |
|
243 | 243 | it 'wrong key and verify = false should not raise an error' do |
|
0 commit comments