Skip to content

Commit 7cb595b

Browse files
committed
raise KeyError if key KeyIssuer is not found
1 parent 4085ad4 commit 7cb595b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cryptojwt/key_jar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ def __getitem__(self, issuer_id=''):
276276
:param issuer_id: The entity ID
277277
:return: A KeyIssuer instance
278278
"""
279-
return self._get_issuer(issuer_id)
279+
_iss = self._get_issuer(issuer_id)
280+
if _iss is None:
281+
raise KeyError(issuer_id)
282+
return _iss
280283

281284
@deprecated_alias(issuer='issuer_id', owner='issuer_id')
282285
def __setitem__(self, issuer_id, key_issuer):

tests/test_04_key_jar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ def test_get_wrong_owner():
733733
assert kj.get('sig', 'rsa') == []
734734

735735
assert 'https://delphi.example.com' not in kj
736-
assert kj['https://delphi.example.com'] == None
736+
with pytest.raises(KeyError):
737+
kj['https://delphi.example.com']
737738

738739

739740
def test_match_owner():

0 commit comments

Comments
 (0)