Skip to content
This repository was archived by the owner on Jun 12, 2021. It is now read-only.

Commit 68c0375

Browse files
committed
Changed Exception type
1 parent babef53 commit 68c0375

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/oidcendpoint/common/authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def verify_uri(endpoint_context, request, uri_type, client_id=None):
8989
if not redirect_uris:
9090
if _cid not in endpoint_context.cdb:
9191
logger.debug("CIDs: {}".format(list(endpoint_context.cdb.keys())))
92-
raise ValueError("No such client")
92+
raise KeyError("No such client")
9393
raise ValueError("No registered {}".format(uri_type))
9494
else:
9595
for regbase, rquery in redirect_uris:

tests/test_24_oauth2_authorization_endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def test_verify_uri_noregistered(self):
262262
_ec = self.endpoint.endpoint_context
263263
request = {"redirect_uri": "https://rp.example.com/cb"}
264264

265-
with pytest.raises(ValueError):
265+
with pytest.raises(KeyError):
266266
verify_uri(_ec, request, "redirect_uri", "client_id")
267267

268268
def test_verify_uri_unregistered(self):

tests/test_24_oidc_authorization_endpoint.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_verify_uri_noregistered(self):
445445
_ec = self.endpoint.endpoint_context
446446
request = {"redirect_uri": "https://rp.example.com/cb"}
447447

448-
with pytest.raises(ValueError):
448+
with pytest.raises(KeyError):
449449
verify_uri(_ec, request, "redirect_uri", "client_id")
450450

451451
def test_verify_uri_unregistered(self):
@@ -993,11 +993,30 @@ def create_endpoint(self):
993993
'flag': 'c',
994994
"writeback": True
995995
}
996+
},
997+
"jti_db": {
998+
"class": 'oidcendpoint.shelve_db.ShelveDataBase',
999+
"kwargs": {
1000+
"filename": 'jti',
1001+
'flag': 'c',
1002+
"writeback": True
1003+
}
1004+
},
1005+
"client_db": {
1006+
"class": 'oidcendpoint.shelve_db.ShelveDataBase',
1007+
"kwargs": {
1008+
"filename": 'client',
1009+
'flag': 'c',
1010+
"writeback": True
1011+
}
9961012
}
1013+
9971014
}
9981015
endpoint_context = EndpointContext(conf)
9991016
_clients = yaml.safe_load(io.StringIO(client_yaml))
1000-
endpoint_context.cdb = _clients["oidc_clients"]
1017+
for c,v in _clients["oidc_clients"].items():
1018+
endpoint_context.cdb[c] = v
1019+
10011020
endpoint_context.keyjar.import_jwks(
10021021
endpoint_context.keyjar.export_jwks(True, ""), conf["issuer"]
10031022
)
@@ -1194,7 +1213,7 @@ def test_verify_uri_noregistered(self):
11941213
_ec = self.endpoint.endpoint_context
11951214
request = {"redirect_uri": "https://rp.example.com/cb"}
11961215

1197-
with pytest.raises(ValueError):
1216+
with pytest.raises(KeyError):
11981217
verify_uri(_ec, request, "redirect_uri", "client_id")
11991218
self._reset()
12001219

0 commit comments

Comments
 (0)