Skip to content

Commit 8fcf1fb

Browse files
committed
Fixed tests. Blacked and isorted.
1 parent 39d38d4 commit 8fcf1fb

File tree

8 files changed

+83
-73
lines changed

8 files changed

+83
-73
lines changed

src/idpyoidc/configure.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ class Base(dict):
9494
parameter = {}
9595

9696
def __init__(
97-
self,
98-
conf: Dict,
99-
base_path: str = "",
100-
file_attributes: Optional[List[str]] = None,
101-
dir_attributes: Optional[List[str]] = None,
102-
domain: Optional[str] = "",
103-
port: Optional[int] = 0,
97+
self,
98+
conf: Dict,
99+
base_path: str = "",
100+
file_attributes: Optional[List[str]] = None,
101+
dir_attributes: Optional[List[str]] = None,
102+
domain: Optional[str] = "",
103+
port: Optional[int] = 0,
104104
):
105105
dict.__init__(self)
106106
if file_attributes is None:
@@ -147,14 +147,14 @@ def items(self):
147147
yield key, getattr(self, key)
148148

149149
def extend(
150-
self,
151-
conf: Dict,
152-
base_path: str,
153-
domain: str,
154-
port: int,
155-
entity_conf: Optional[List[dict]] = None,
156-
file_attributes: Optional[List[str]] = None,
157-
dir_attributes: Optional[List[str]] = None,
150+
self,
151+
conf: Dict,
152+
base_path: str,
153+
domain: str,
154+
port: int,
155+
entity_conf: Optional[List[dict]] = None,
156+
file_attributes: Optional[List[str]] = None,
157+
dir_attributes: Optional[List[str]] = None,
158158
):
159159
for econf in entity_conf:
160160
_path = econf.get("path")
@@ -195,13 +195,13 @@ def complete_paths(self, conf: Dict, keys: List[str], default_config: Dict, base
195195
setattr(self, key, _val)
196196

197197
def format(
198-
self,
199-
conf,
200-
base_path: str,
201-
domain: str,
202-
port: int,
203-
file_attributes: Optional[List[str]] = None,
204-
dir_attributes: Optional[List[str]] = None,
198+
self,
199+
conf,
200+
base_path: str,
201+
domain: str,
202+
port: int,
203+
file_attributes: Optional[List[str]] = None,
204+
dir_attributes: Optional[List[str]] = None,
205205
) -> Union[Dict, str]:
206206
"""
207207
Formats parts of the configuration. That includes replacing the strings {domain} and {port}
@@ -236,14 +236,14 @@ class Configuration(Base):
236236
uris = ["redirect_uris", "issuer", "base_url", "server_name"]
237237

238238
def __init__(
239-
self,
240-
conf: Dict,
241-
base_path: str = "",
242-
entity_conf: Optional[List[dict]] = None,
243-
file_attributes: Optional[List[str]] = None,
244-
domain: Optional[str] = "",
245-
port: Optional[int] = 0,
246-
dir_attributes: Optional[List[str]] = None,
239+
self,
240+
conf: Dict,
241+
base_path: str = "",
242+
entity_conf: Optional[List[dict]] = None,
243+
file_attributes: Optional[List[str]] = None,
244+
domain: Optional[str] = "",
245+
port: Optional[int] = 0,
246+
dir_attributes: Optional[List[str]] = None,
247247
):
248248
Base.__init__(
249249
self,
@@ -290,14 +290,14 @@ def __init__(
290290

291291

292292
def create_from_config_file(
293-
cls,
294-
filename: str,
295-
base_path: Optional[str] = "",
296-
entity_conf: Optional[List[dict]] = None,
297-
file_attributes: Optional[List[str]] = None,
298-
domain: Optional[str] = "",
299-
port: Optional[int] = 0,
300-
dir_attributes: Optional[List[str]] = None,
293+
cls,
294+
filename: str,
295+
base_path: Optional[str] = "",
296+
entity_conf: Optional[List[dict]] = None,
297+
file_attributes: Optional[List[str]] = None,
298+
domain: Optional[str] = "",
299+
port: Optional[int] = 0,
300+
dir_attributes: Optional[List[str]] = None,
301301
):
302302
return cls(
303303
load_config_file(filename),

src/idpyoidc/server/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Union
66

77
from cryptojwt import KeyJar
8+
89
from idpyoidc.impexp import ImpExp
910
from idpyoidc.message.oidc import RegistrationRequest
1011
from idpyoidc.server import authz
@@ -36,12 +37,12 @@ class Server(ImpExp):
3637
parameter = {"endpoint": [Endpoint], "endpoint_context": EndpointContext}
3738

3839
def __init__(
39-
self,
40-
conf: Union[dict, OPConfiguration, ASConfiguration],
41-
keyjar: Optional[KeyJar] = None,
42-
cwd: Optional[str] = "",
43-
cookie_handler: Optional[Any] = None,
44-
httpc: Optional[Any] = None,
40+
self,
41+
conf: Union[dict, OPConfiguration, ASConfiguration],
42+
keyjar: Optional[KeyJar] = None,
43+
cwd: Optional[str] = "",
44+
cookie_handler: Optional[Any] = None,
45+
httpc: Optional[Any] = None,
4546
):
4647
ImpExp.__init__(self)
4748
self.conf = conf

src/idpyoidc/server/client_configure.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@
33
from typing import Optional
44

55
from idpyoidc.message import OPTIONAL_LIST_OF_STRINGS
6-
from idpyoidc.message.oidc import RegistrationResponse
76
from idpyoidc.message.oidc import SINGLE_OPTIONAL_BOOLEAN
87
from idpyoidc.message.oidc import SINGLE_OPTIONAL_DICT
8+
from idpyoidc.message.oidc import RegistrationResponse
99
from idpyoidc.server.session.token import TOKEN_MAP
1010

1111
logger = logging.getLogger(__name__)
1212

1313

1414
class ClientConfiguration(RegistrationResponse):
1515
c_param = RegistrationResponse.c_param.copy()
16-
c_param.update({
17-
"token_usage_rules": SINGLE_OPTIONAL_DICT,
18-
"token_exchange": SINGLE_OPTIONAL_DICT,
19-
"add_claims": SINGLE_OPTIONAL_DICT,
20-
"pkce_essential": SINGLE_OPTIONAL_BOOLEAN,
21-
"revoke_refresh_on_issue": SINGLE_OPTIONAL_BOOLEAN,
22-
"allowed_scopes": OPTIONAL_LIST_OF_STRINGS,
23-
"scopes_to_claims": SINGLE_OPTIONAL_DICT,
24-
#
25-
# These may be added dynamically at run time
26-
# "dpop_jkt": SINGLE_OPTIONAL_STRING,
27-
# "si_redirects": OPTIONAL_LIST_OF_STRINGS,
28-
# "sector_id": SINGLE_OPTIONAL_STRING,
29-
# "client_secret_expires_at": SINGLE_OPTIONAL_INT,
30-
# "registration_access_token": SINGLE_OPTIONAL_STRING
31-
# "auth_method": SINGLE_OPTIONAL_DICT,
32-
})
16+
c_param.update(
17+
{
18+
"token_usage_rules": SINGLE_OPTIONAL_DICT,
19+
"token_exchange": SINGLE_OPTIONAL_DICT,
20+
"add_claims": SINGLE_OPTIONAL_DICT,
21+
"pkce_essential": SINGLE_OPTIONAL_BOOLEAN,
22+
"revoke_refresh_on_issue": SINGLE_OPTIONAL_BOOLEAN,
23+
"allowed_scopes": OPTIONAL_LIST_OF_STRINGS,
24+
"scopes_to_claims": SINGLE_OPTIONAL_DICT,
25+
#
26+
# These may be added dynamically at run time
27+
# "dpop_jkt": SINGLE_OPTIONAL_STRING,
28+
# "si_redirects": OPTIONAL_LIST_OF_STRINGS,
29+
# "sector_id": SINGLE_OPTIONAL_STRING,
30+
# "client_secret_expires_at": SINGLE_OPTIONAL_INT,
31+
# "registration_access_token": SINGLE_OPTIONAL_STRING
32+
# "auth_method": SINGLE_OPTIONAL_DICT,
33+
}
34+
)
3335

3436
def verify(self, **kwargs):
3537
RegistrationResponse.verify(self, **kwargs)
@@ -50,9 +52,10 @@ def verify(self, **kwargs):
5052
if _typ not in TOKEN_MAP.keys():
5153
logger.warning(f"Undefined token type '{_typ}' used")
5254

53-
if not set(_rule.keys()).issubset({'expires_in', 'supports_minting', 'max_usage'}):
55+
if not set(_rule.keys()).issubset({"expires_in", "supports_minting", "max_usage"}):
5456
_diff = set(_rule.keys()).difference(
55-
{'expires_in', 'supports_minting', 'max_usage'})
57+
{"expires_in", "supports_minting", "max_usage"}
58+
)
5659
logger.warning(f"Undefined token_usage_rules parameter '{_diff}' used")
5760

5861
_supports = _rule.get("supports_minting")
@@ -65,9 +68,9 @@ def verify(self, **kwargs):
6568
pass
6669

6770

68-
def verify_oidc_client_information(conf: dict,
69-
server_get: Optional[Callable] = None,
70-
**kwargs) -> dict:
71+
def verify_oidc_client_information(
72+
conf: dict, server_get: Optional[Callable] = None, **kwargs
73+
) -> dict:
7174
res = {}
7275
for key, item in conf.items():
7376
_rr = ClientConfiguration(**item)

src/idpyoidc/server/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from typing import Optional
88

99
from idpyoidc.configure import Base
10-
from idpyoidc.server.scopes import SCOPE2CLAIMS
1110
from idpyoidc.server.client_configure import verify_oidc_client_information
11+
from idpyoidc.server.scopes import SCOPE2CLAIMS
1212

1313
logger = logging.getLogger(__name__)
1414

src/idpyoidc/server/endpoint_context.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ def get_token_handler_args(conf: dict) -> dict:
7272
"""
7373
th_args = conf.get("token_handler_args", None)
7474
if not th_args:
75-
th_args = {typ: {"lifetime": tid} for typ, tid in [("code", 600), ("token", 3600),
76-
("refresh", 86400)]}
75+
th_args = {
76+
typ: {"lifetime": tid}
77+
for typ, tid in [("code", 600), ("token", 3600), ("refresh", 86400)]
78+
}
7779

7880
return th_args
7981

tests/test_20_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def test_init_crypto_None():
101101

102102

103103
def test_init_crypto_old():
104-
_res = init_encrypter({"password": "long sentence WITH number 64", "salt": "potassium_chloride"})
104+
_res = init_encrypter(
105+
{"password": "long sentence WITH number 64", "salt": "potassium_chloride"}
106+
)
105107
assert _res["conf"]["class"] == DEFAULT_CRYPTO
106108
assert set(_res["conf"]["kwargs"].keys()) == {"password", "salt"}
107109
assert _res["conf"]["kwargs"]["password"] == "long sentence WITH number 64"

tests/test_client_21_oidc_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ def test_construct(self):
769769

770770
def test_config_with_post_logout(self):
771771
self.service.client_get("service_context").register_args[
772-
"post_logout_redirect_uri"] = "https://example.com/post_logout"
772+
"post_logout_redirect_uri"
773+
] = "https://example.com/post_logout"
773774

774775
_req = self.service.construct()
775776
assert isinstance(_req, RegistrationRequest)

tests/test_server_00_configure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import json
22
import os
33

4+
import pytest
5+
46
from idpyoidc.configure import Configuration
57
from idpyoidc.configure import create_from_config_file
68
from idpyoidc.logging import configure_logging
79
from idpyoidc.server.configure import OPConfiguration
8-
import pytest
910

1011
BASEDIR = os.path.abspath(os.path.dirname(__file__))
1112

0 commit comments

Comments
 (0)