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

Commit 600c03a

Browse files
committed
test: missing userinfo in configuration
1 parent ac9d69f commit 600c03a

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/oidcop/session/claims.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def get_user_claims(self, user_id: str, claims_restriction: dict) -> dict:
128128
:param claims_restriction: Specifies the upper limit of which claims can be returned
129129
:return:
130130
"""
131+
# Get all possible claims
132+
meth = self.server_get("endpoint_context").userinfo
133+
if not meth:
134+
raise ImproperlyConfigured(
135+
"userinfo MUST be defined in the configuration"
136+
)
131137
if claims_restriction:
132-
# Get all possible claims
133-
meth = self.server_get("endpoint_context").userinfo
134-
if not meth:
135-
raise ImproperlyConfigured(
136-
"userinfo MUST be defined in the configuration"
137-
)
138138
user_info = meth(user_id, client_id=None)
139139
# Filter out the claims that can be returned
140140
return {

tests/test_26_oidc_userinfo_endpoint.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from oidcop.authn_event import create_authn_event
1212
from oidcop.configure import OPConfiguration
1313
from oidcop.cookie_handler import CookieHandler
14+
from oidcop.exception import ImproperlyConfigured
1415
from oidcop.oidc import userinfo
1516
from oidcop.oidc.authorization import Authorization
1617
from oidcop.oidc.provider_config import ProviderConfiguration
@@ -439,3 +440,14 @@ def test_userinfo_claims_acr_none(self):
439440
res = self.endpoint.do_response(request=_req, **args)
440441
_response = json.loads(res["response"])
441442
assert _response["acr"] == _acr
443+
444+
def test_process_request_absent_userinfo_conf(self):
445+
# consider to have a configuration without userinfo defined in
446+
ec = self.endpoint.server_get('endpoint_context')
447+
ec.userinfo = None
448+
449+
session_id = self._create_session(AUTH_REQ)
450+
grant = self.session_manager[session_id]
451+
452+
with pytest.raises(ImproperlyConfigured):
453+
code = self._mint_code(grant, session_id)

0 commit comments

Comments
 (0)