Skip to content

Commit 39d38d4

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

File tree

5 files changed

+44
-56
lines changed

5 files changed

+44
-56
lines changed

tests/private/token_jwks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}]}
1+
{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}, {"kty": "oct", "use": "enc", "kid": "refresh", "k": "fHJEgxetofNA1mo6rgNxRDb6MxYBuALC"}]}

tests/pub_client.jwks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "EC", "use": "sig", "kid": "azZQQ2FEQjh3QnVZWVdrbHJkMEZSaWR6aVJ0LTBjeUFfeWRlbTRrRFZ5VQ", "crv": "P-256", "x": "2ADe18caWWGp6hpRbfa9HqQHDFNpid9xUmR56Wzm_wc", "y": "HnD_8QBanz4Y-UF8mKQFZXfqkGkXUSm34mLsdDKtSyk"}, {"kty": "RSA", "use": "sig", "kid": "SHEyYWcwNVk0LTdROTZzZ2FUWndIVXdack0xWUM5SEpwcS03dVUxWU4zRQ", "n": "rRz52ddyP9Y2ezSlRsnkt-sjXfV_Ii7vOFX-cStLE3IUlVeSJGEe_kAASLr2r3BE2unjntaxj67NP8D95h_rzG1SpCklTEn-aTe3FOwNyTzUH_oiDVeRoEcf04Y43ciRGYRB5PhI6ii-2lYuig6hyUr776Qxiu6-0zw-M_ay2MgGSy5CEj55dDSvcUyxStUObxGpPWnEvybO1vnE7iJEWGNe0L5uPe5nLidOiR-JwjxSWEx1xZYtIjxaf2Ulu-qu4hwgwBUQdx4bNZyBfljKj55skWuHqPMG3xMjnedQC6Ms5bR3rIkbBpvmgI3kJK-4CZikM6ruyLo94-Lk19aYQw", "e": "AQAB"}]}
1+
{"keys": [{"kty": "EC", "use": "sig", "kid": "azZQQ2FEQjh3QnVZWVdrbHJkMEZSaWR6aVJ0LTBjeUFfeWRlbTRrRFZ5VQ", "crv": "P-256", "x": "2ADe18caWWGp6hpRbfa9HqQHDFNpid9xUmR56Wzm_wc", "y": "HnD_8QBanz4Y-UF8mKQFZXfqkGkXUSm34mLsdDKtSyk"}, {"kty": "RSA", "use": "sig", "kid": "SHEyYWcwNVk0LTdROTZzZ2FUWndIVXdack0xWUM5SEpwcS03dVUxWU4zRQ", "e": "AQAB", "n": "rRz52ddyP9Y2ezSlRsnkt-sjXfV_Ii7vOFX-cStLE3IUlVeSJGEe_kAASLr2r3BE2unjntaxj67NP8D95h_rzG1SpCklTEn-aTe3FOwNyTzUH_oiDVeRoEcf04Y43ciRGYRB5PhI6ii-2lYuig6hyUr776Qxiu6-0zw-M_ay2MgGSy5CEj55dDSvcUyxStUObxGpPWnEvybO1vnE7iJEWGNe0L5uPe5nLidOiR-JwjxSWEx1xZYtIjxaf2Ulu-qu4hwgwBUQdx4bNZyBfljKj55skWuHqPMG3xMjnedQC6Ms5bR3rIkbBpvmgI3kJK-4CZikM6ruyLo94-Lk19aYQw"}]}

tests/pub_iss.jwks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"keys": [{"kty": "EC", "use": "sig", "kid": "SmdKMlVGcG1zMnprdDdXZGpGWEczdHhlZVpGbkx1THpPdUY4d0w4bnZkSQ", "crv": "P-256", "x": "tRHJYm0fsOi0icpGEb33qiDVgt68ltMoYSWdLGhDGz4", "y": "fRpX0i6p5Jigf5I0qwW34PyStosMShwWAWS8x_w5o7E"}, {"kty": "RSA", "use": "sig", "kid": "R0FsaFdqREFaUFp1c0MwbUpsbHVSZ200blBJZWJVMTUtNGsyVlBmdHk5UQ", "n": "2ilgsKVqF92KfhwmosSVeZOaDgb3RF1mbg-pqkmLO6YpOO06LF4V4angF-GhP-ysAm2E75aSIU4tnHVThFlcxTgKFqjYKJQXyVzTVK2r-L2IbvFPaDtvoU6WteybpMlIUVk2po3cFDGObCWYKCm7CUOLlwH0uOpui66P9VSCqdKVKbJRAQBvTSbP10KWPxulfqjWGJtHO5fY7-JVWwOBkG-eHSJIT_uaoPjyvKCZjknq04bLUV9qP78KRQpRyYijBN60w2v8F79baN9CN10TIEjjWKGz0uX0M_YYQzTUoSY5l5ka9RkL3wT4o2iQ1t5nHphX6aA-gqwgCQmi-nvjaw", "e": "AQAB"}]}
1+
{"keys": [{"kty": "EC", "use": "sig", "kid": "SmdKMlVGcG1zMnprdDdXZGpGWEczdHhlZVpGbkx1THpPdUY4d0w4bnZkSQ", "crv": "P-256", "x": "tRHJYm0fsOi0icpGEb33qiDVgt68ltMoYSWdLGhDGz4", "y": "fRpX0i6p5Jigf5I0qwW34PyStosMShwWAWS8x_w5o7E"}, {"kty": "RSA", "use": "sig", "kid": "R0FsaFdqREFaUFp1c0MwbUpsbHVSZ200blBJZWJVMTUtNGsyVlBmdHk5UQ", "e": "AQAB", "n": "2ilgsKVqF92KfhwmosSVeZOaDgb3RF1mbg-pqkmLO6YpOO06LF4V4angF-GhP-ysAm2E75aSIU4tnHVThFlcxTgKFqjYKJQXyVzTVK2r-L2IbvFPaDtvoU6WteybpMlIUVk2po3cFDGObCWYKCm7CUOLlwH0uOpui66P9VSCqdKVKbJRAQBvTSbP10KWPxulfqjWGJtHO5fY7-JVWwOBkG-eHSJIT_uaoPjyvKCZjknq04bLUV9qP78KRQpRyYijBN60w2v8F79baN9CN10TIEjjWKGz0uX0M_YYQzTUoSY5l5ka9RkL3wT4o2iQ1t5nHphX6aA-gqwgCQmi-nvjaw"}]}

tests/test_server_00a_client_configure.py

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import json
2+
import os
23

34
from idpyoidc.server import OPConfiguration
45
from idpyoidc.server import Server
56
from idpyoidc.server.client_configure import verify_oidc_client_information
67
from idpyoidc.util import load_config_file
7-
88
from tests import full_path
99

10+
BASEDIR = os.path.abspath(os.path.dirname(__file__))
11+
1012
extra = {
1113
"token_usage_rules": {
1214
"authorization_code": {
@@ -23,42 +25,28 @@
2325
"subject_token_types_supported": [
2426
"urn:ietf:params:oauth:token-type:access_token",
2527
"urn:ietf:params:oauth:token-type:refresh_token",
26-
"urn:ietf:params:oauth:token-type:id_token"
28+
"urn:ietf:params:oauth:token-type:id_token",
2729
],
2830
"requested_token_types_supported": [
2931
"urn:ietf:params:oauth:token-type:access_token",
3032
"urn:ietf:params:oauth:token-type:refresh_token",
31-
"urn:ietf:params:oauth:token-type:id_token"
33+
"urn:ietf:params:oauth:token-type:id_token",
3234
],
3335
"policy": {
3436
"urn:ietf:params:oauth:token-type:access_token": {
3537
"callable": "/path/to/callable",
36-
"kwargs": {
37-
"audience": ["https://example.com"],
38-
"scopes": ["openid"]
39-
}
38+
"kwargs": {"audience": ["https://example.com"], "scopes": ["openid"]},
4039
},
4140
"urn:ietf:params:oauth:token-type:refresh_token": {
4241
"callable": "/path/to/callable",
43-
"kwargs": {
44-
"resource": ["https://example.com"],
45-
"scopes": ["openid"]
46-
}
42+
"kwargs": {"resource": ["https://example.com"], "scopes": ["openid"]},
4743
},
48-
"": {
49-
"callable": "/path/to/callable",
50-
"kwargs": {
51-
"scopes": ["openid"]
52-
}
53-
}
54-
}
55-
}
44+
"": {"callable": "/path/to/callable", "kwargs": {"scopes": ["openid"]}},
45+
},
46+
},
5647
},
5748
"allowed_scopes": ["scope"],
58-
"scopes_to_claims": {
59-
"scope_a": ["claim1", "claim2"],
60-
"scope_b": []
61-
},
49+
"scopes_to_claims": {"scope_a": ["claim1", "claim2"], "scope_b": []},
6250
"add_claims": {
6351
"always": {
6452
"userinfo": ["email", "phone"],
@@ -71,50 +59,50 @@
7159
"by_scope": {
7260
"id_token": False,
7361
},
74-
}
75-
}
62+
},
63+
},
7664
}
7765

7866

7967
def test_op_configure_oidc_clients_simple():
80-
_str = open(full_path("op_config.json")).read()
68+
_str = open(full_path(full_path("op_config.json"))).read()
8169
_conf = json.loads(_str)
8270
_conf["oidc_clients"] = {
8371
"client1": {
8472
"client_id": "client1",
8573
"client_secret": "Namnam",
86-
"redirect_uris": ['https://openidconnect.net/callback', ''],
87-
"response_types": ["code"]
74+
"redirect_uris": ["https://openidconnect.net/callback", ""],
75+
"response_types": ["code"],
8876
},
8977
"client2": {
9078
"client_id": "client2",
9179
"client_secret": "spraket",
92-
"redirect_uris": ['https://app1.example.net/foo', 'https://app2.example.net/bar'],
93-
"response_types": ["code"]
80+
"redirect_uris": ["https://app1.example.net/foo", "https://app2.example.net/bar"],
81+
"response_types": ["code"],
9482
},
9583
"client3": {
9684
"client_id": "client3",
97-
"client_secret": '2222222222222222222222222222222222222222',
98-
"redirect_uris": ['https://127.0.0.1:8090/authz_cb/bobcat'],
99-
"post_logout_redirect_uri": 'https://openidconnect.net/',
100-
"response_types": ["code"]
101-
}
85+
"client_secret": "2222222222222222222222222222222222222222",
86+
"redirect_uris": ["https://127.0.0.1:8090/authz_cb/bobcat"],
87+
"post_logout_redirect_uri": "https://openidconnect.net/",
88+
"response_types": ["code"],
89+
},
10290
}
10391

104-
op_conf = OPConfiguration(conf=_conf)
92+
op_conf = OPConfiguration(conf=_conf, base_path=BASEDIR)
10593
assert op_conf
10694

10795

10896
def test_verify_oidc_client_information_complext():
109-
_conf = load_config_file("op_config.json")
110-
server = Server(OPConfiguration(conf=_conf))
97+
_conf = load_config_file(full_path("op_config.json"))
98+
server = Server(OPConfiguration(conf=_conf, base_path=BASEDIR))
11199

112100
client_conf = {
113101
"client1": {
114102
"client_id": "client1",
115103
"client_secret": "Namnam",
116-
"redirect_uris": ['https://openidconnect.net/callback', ''],
117-
"response_types": ["code"]
104+
"redirect_uris": ["https://openidconnect.net/callback", ""],
105+
"response_types": ["code"],
118106
}
119107
}
120108

@@ -127,22 +115,22 @@ def test_verify_oidc_client_information_complext():
127115

128116

129117
def test_verify_oidc_client_information_2():
130-
_conf = load_config_file("op_config.json")
131-
server = Server(OPConfiguration(conf=_conf))
118+
_conf = load_config_file(full_path("op_config.json"))
119+
server = Server(OPConfiguration(conf=_conf, base_path=BASEDIR), cwd=full_path(""))
132120

133121
client_conf = {
134122
"client1": {
135123
"client_id": "client1",
136124
"client_secret": "Namnam",
137-
"redirect_uris": ['https://openidconnect.net/callback', ''],
125+
"redirect_uris": ["https://openidconnect.net/callback", ""],
138126
"response_types": ["code"],
139127
"token_usage_rules": {
140128
"authorization_code": {
141129
"expires_in": 600,
142130
"supports_minting": ["access_token", "refresh_token"],
143131
},
144132
"refresh_token": {"supports_minting": ["access_token"]},
145-
"dummy_token": {"supports_minting": ["foobar_token"]}
133+
"dummy_token": {"supports_minting": ["foobar_token"]},
146134
},
147135
}
148136
}

tests/test_server_40_oauth2_pushed_authorization.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import io
22
import os
33

4+
import pytest
5+
import yaml
46
from cryptojwt import JWT
57
from cryptojwt.jwt import remove_jwt_parameters
68
from cryptojwt.key_jar import init_key_jar
9+
710
from idpyoidc.message import Message
811
from idpyoidc.message.oauth2 import AuthorizationRequest
912
from idpyoidc.server import Server
13+
from idpyoidc.server.client_configure import verify_oidc_client_information
1014
from idpyoidc.server.configure import ASConfiguration
1115
from idpyoidc.server.cookie_handler import CookieHandler
1216
from idpyoidc.server.oauth2.authorization import Authorization
1317
from idpyoidc.server.oauth2.pushed_authorization import PushedAuthorization
1418
from idpyoidc.server.oidc.provider_config import ProviderConfiguration
1519
from idpyoidc.server.oidc.registration import Registration
16-
from idpyoidc.util import verify_oidc_client_information
17-
import pytest
18-
import yaml
19-
2020
from tests import CRYPT_CONFIG
2121
from tests import SESSION_PARAMS
2222

@@ -51,12 +51,12 @@
5151
client_yaml = """
5252
oidc_clients:
5353
s6BhdRkqt3:
54-
"client_secret": 7Fjfp0ZBr1KtDRbnfVdmIw
55-
"redirect_uris":
54+
client_id: s6BhdRkqt3
55+
client_secret: 7Fjfp0ZBr1KtDRbnfVdmIw
56+
redirect_uris:
5657
- 'https://client.example.org/cb'
57-
"client_salt": "salted"
58-
'token_endpoint_auth_method': 'client_secret_post'
59-
'response_types':
58+
token_endpoint_auth_method: 'client_secret_post'
59+
response_types:
6060
- 'code'
6161
- 'token'
6262
- 'code id_token'

0 commit comments

Comments
 (0)