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

Commit 1581130

Browse files
committed
Updated some tests
1 parent d7d1ac3 commit 1581130

2 files changed

Lines changed: 80 additions & 8 deletions

File tree

tests/test_00_endpoint_context.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import io
12
from copy import copy
23

34
import pytest
5+
import yaml
46
from cryptojwt.key_jar import build_keyjar
7+
from oidcendpoint.oidc.session import Session
58

69
from oidcendpoint.endpoint_context import EndpointContext
710
from oidcendpoint.exception import ConfigurationError
@@ -58,6 +61,11 @@
5861
'path': 'userinfo',
5962
'class': UserInfo,
6063
'kwargs': {'db_file': 'users.json'}
64+
},
65+
'session': {
66+
'path': 'end_session',
67+
'class': Session,
68+
'kwargs': {}
6169
}
6270
},
6371
'authentication': {
@@ -70,6 +78,32 @@
7078
'template_dir': 'template'
7179
}
7280

81+
client_yaml = """
82+
oidc_clients:
83+
client1:
84+
# client secret is "password"
85+
client_secret: "Namnam"
86+
redirect_uris:
87+
- ['https://openidconnect.net/callback', '']
88+
response_types:
89+
- code
90+
client2:
91+
client_secret: "spraket"
92+
redirect_uris:
93+
- ['https://app1.example.net/foo', '']
94+
- ['https://app2.example.net/bar', '']
95+
response_types:
96+
- code
97+
client3:
98+
client_secret: '2222222222222222222222222222222222222222'
99+
redirect_uris:
100+
- ['https://127.0.0.1:8090/authz_cb/bobcat', '']
101+
post_logout_redirect_uris:
102+
- ['https://openidconnect.net/', '']
103+
response_types:
104+
- code
105+
"""
106+
73107

74108
def test_capabilities_default():
75109
endpoint_context = EndpointContext(conf)
@@ -109,3 +143,11 @@ def test_capabilities_no_support():
109143
_cnf['capabilities'] = {'id_token_signing_alg_values_supported': 'RC4'}
110144
with pytest.raises(ConfigurationError):
111145
EndpointContext(_cnf)
146+
147+
148+
def test_cdb():
149+
endpoint_context = EndpointContext(conf)
150+
_clients = yaml.load(io.StringIO(client_yaml))
151+
endpoint_context.cdb = _clients['oidc_clients']
152+
153+
assert set(endpoint_context.cdb.keys()) == {'client1', 'client2', 'client3'}

tests/test_24_authorization_endpoint.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import io
12
import json
23
import os
34
from http.cookies import SimpleCookie
45
from urllib.parse import parse_qs
56
from urllib.parse import urlparse
67

78
import pytest
9+
import yaml
810
from cryptojwt.jwt import utc_time_sans_frac
911
from cryptojwt.utils import as_bytes
1012
from cryptojwt.utils import b64e
@@ -148,6 +150,38 @@ def get_cookie_value(cookie=None, cookie_name=None):
148150
return None
149151

150152

153+
client_yaml = """
154+
oidc_clients:
155+
client_1:
156+
"client_secret": 'hemligt'
157+
"redirect_uris":
158+
- ['https://example.com/cb', '']
159+
"client_salt": "salted"
160+
'token_endpoint_auth_method': 'client_secret_post'
161+
'response_types':
162+
- 'code'
163+
- 'token'
164+
- 'code id_token'
165+
- 'id_token'
166+
- 'code id_token token'
167+
client2:
168+
client_secret: "spraket"
169+
redirect_uris:
170+
- ['https://app1.example.net/foo', '']
171+
- ['https://app2.example.net/bar', '']
172+
response_types:
173+
- code
174+
client3:
175+
client_secret: '2222222222222222222222222222222222222222'
176+
redirect_uris:
177+
- ['https://127.0.0.1:8090/authz_cb/bobcat', '']
178+
post_logout_redirect_uris:
179+
- ['https://openidconnect.net/', '']
180+
response_types:
181+
- code
182+
"""
183+
184+
151185
class TestEndpoint(object):
152186
@pytest.fixture(autouse=True)
153187
def create_endpoint(self):
@@ -233,14 +267,8 @@ def create_endpoint(self):
233267
}
234268
}
235269
endpoint_context = EndpointContext(conf)
236-
endpoint_context.cdb['client_1'] = {
237-
"client_secret": 'hemligt',
238-
"redirect_uris": [("https://example.com/cb", None)],
239-
"client_salt": "salted",
240-
'token_endpoint_auth_method': 'client_secret_post',
241-
'response_types': ['code', 'token', 'code id_token', 'id_token',
242-
'code id_token token']
243-
}
270+
_clients = yaml.load(io.StringIO(client_yaml))
271+
endpoint_context.cdb = _clients['oidc_clients']
244272
endpoint_context.keyjar.import_jwks(
245273
endpoint_context.keyjar.export_jwks(True, ''), conf['issuer'])
246274
self.endpoint = Authorization(endpoint_context)
@@ -731,6 +759,8 @@ def test_setup_auth_login_hint2acrs(self):
731759
assert isinstance(res['method'], NoAuthn)
732760
assert res['method'].user == 'knoll'
733761

762+
def test_post_logout_uri(self):
763+
pass
734764

735765
def test_inputs():
736766
elems = inputs({'foo': 'bar', 'home': 'stead'})

0 commit comments

Comments
 (0)