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

Commit d0eb303

Browse files
committed
chore: fixed userinfo configuration in unit tests
1 parent 600c03a commit d0eb303

7 files changed

Lines changed: 36 additions & 3 deletions

File tree

src/oidcop/session/claims.py

Lines changed: 1 addition & 1 deletion
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
132131
meth = self.server_get("endpoint_context").userinfo
133132
if not meth:
134133
raise ImproperlyConfigured(
135134
"userinfo MUST be defined in the configuration"
136135
)
137136
if claims_restriction:
137+
# Get all possible claims
138138
user_info = meth(user_id, client_id=None)
139139
# Filter out the claims that can be returned
140140
return {

tests/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
BASEDIR = os.path.abspath(os.path.dirname(__file__))
4+
5+
6+
def full_path(local_file):
7+
return os.path.join(BASEDIR, local_file)

tests/test_01_grant.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from cryptojwt.key_jar import build_keyjar
33
from oidcmsg.oidc import AuthorizationRequest
44

5+
from . import full_path
56
from oidcop.authn_event import create_authn_event
67
from oidcop.server import Server
78
from oidcop.session.grant import TOKEN_MAP
@@ -20,6 +21,7 @@
2021

2122
KEYJAR = build_keyjar(KEYDEFS)
2223

24+
2325
conf = {
2426
"issuer": "https://example.com/",
2527
"template_dir": "template",
@@ -40,6 +42,10 @@
4042
}
4143
},
4244
"claims_interface": {"class": "oidcop.session.claims.ClaimsInterface", "kwargs": {}},
45+
"userinfo": {
46+
"class": "oidcop.user_info.UserInfo",
47+
"kwargs": {"db_file": full_path("users.json")},
48+
},
4349
}
4450

4551
USER_ID = "diana"

tests/test_06_session_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from oidcmsg.time_util import time_sans_frac
33
import pytest
44

5+
from . import full_path
56
from oidcop.authn_event import AuthnEvent
67
from oidcop.authn_event import create_authn_event
78
from oidcop.authz import AuthzHandling
@@ -74,6 +75,10 @@ def create_session_manager(self):
7475
},
7576
"template_dir": "template",
7677
"claims_interface": {"class": "oidcop.session.claims.ClaimsInterface", "kwargs": {}},
78+
"userinfo": {
79+
"class": "oidcop.user_info.UserInfo",
80+
"kwargs": {"db_file": full_path("users.json")},
81+
},
7782
}
7883
server = Server(conf)
7984
self.server = server

tests/test_08_session_life.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from oidcmsg.oidc import RefreshAccessTokenRequest
99
from oidcmsg.time_util import time_sans_frac
1010

11+
from . import full_path
1112
from oidcop import user_info
1213
from oidcop.authn_event import create_authn_event
1314
from oidcop.client_authn import verify_client
@@ -50,6 +51,10 @@ def setup_token_handler(self):
5051
"token_endpoint": {"path": "{}/token", "class": Token, "kwargs": {}},
5152
},
5253
"template_dir": "template",
54+
"userinfo": {
55+
"class": "oidcop.user_info.UserInfo",
56+
"kwargs": {"db_file": full_path("users.json")},
57+
},
5358
}
5459
server = Server(OPConfiguration(conf=conf, base_path=BASEDIR), cwd=BASEDIR)
5560

tests/test_33_oauth2_pkce.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import secrets
55
import string
66

7+
from . import full_path
78
from oidcop.configure import ASConfiguration
89
import pytest
910
import yaml
@@ -161,6 +162,10 @@ def conf():
161162
},
162163
},
163164
},
165+
"userinfo": {
166+
"class": "oidcop.user_info.UserInfo",
167+
"kwargs": {"db_file": full_path("users.json")},
168+
},
164169
}
165170

166171

tests/test_34_oidc_sso.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44

5+
from . import full_path
56
from oidcop.configure import OPConfiguration
67
import pytest
78
import yaml
@@ -89,11 +90,11 @@ def full_path(local_file):
8990
client_1:
9091
client_secret: hemligtkodord,
9192
client_id: client_1,
92-
"redirect_uris":
93+
"redirect_uris":
9394
- ['https://example.com/cb', '']
9495
"client_salt": "salted"
9596
'token_endpoint_auth_method': 'client_secret_post'
96-
'response_types':
97+
'response_types':
9798
- 'code'
9899
- 'token'
99100
- 'code id_token'
@@ -158,6 +159,10 @@ def create_endpoint_context(self):
158159
},
159160
},
160161
"template_dir": "template",
162+
"userinfo": {
163+
"class": "oidcop.user_info.UserInfo",
164+
"kwargs": {"db_file": full_path("users.json")},
165+
},
161166
}
162167
server = Server(OPConfiguration(conf=conf, base_path=BASEDIR), cwd=BASEDIR)
163168

0 commit comments

Comments
 (0)