Skip to content

Commit 59ebfb7

Browse files
author
Michael Davis
committed
Test all the things
1 parent bf919db commit 59ebfb7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

jose/algorithms/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ def get_algorithm_object(algorithm):
1010
"""
1111
Returns an algorithm object for the given algorithm.
1212
"""
13-
if algorithm not in ALGORITHMS.SUPPORTED:
14-
raise JWSError('Algorithm not supported: %s' % algorithm)
1513

1614
if algorithm == ALGORITHMS.HS256:
1715
return HMACAlgorithm(HMACAlgorithm.SHA256)
@@ -31,4 +29,4 @@ def get_algorithm_object(algorithm):
3129
if algorithm == ALGORITHMS.RS512:
3230
return RSAAlgorithm(RSAAlgorithm.SHA512)
3331

34-
raise JWSError('No algorithm found for %s.' % algorithm)
32+
raise JWSError('Algorithm not supported: %s' % algorithm)

tests/test_jws.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def test_claims_not_json(self):
4646
with pytest.raises(JWSError):
4747
jws.verify(token, 'secret', ['HS256'])
4848

49+
def test_invalid_key(self, claims):
50+
with pytest.raises(JWSError):
51+
jws.sign(claims, 'secret', algorithm='RS256')
52+
4953

5054
class TestHMAC:
5155

0 commit comments

Comments
 (0)