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

Commit 8322361

Browse files
committed
Corrected attribute name. Must use priv_key/pub_key instead of key for asymmetric keys.
1 parent 40a89c6 commit 8322361

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

tests/test_11_oauth2.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import os
2-
import pytest
32
import sys
43
import time
54

6-
from cherrypy import HTTPError
7-
5+
import pytest
86
from cryptojwt.jwk.rsa import import_private_rsa_key_from_file
97
from cryptojwt.key_bundle import KeyBundle
10-
118
from oidcmsg.oauth2 import AccessTokenRequest
129
from oidcmsg.oauth2 import AccessTokenResponse
1310
from oidcmsg.oauth2 import AuthorizationRequest
@@ -27,7 +24,7 @@
2724
BASE_PATH = os.path.join(_dirname, "data", "keys")
2825

2926
_key = import_private_rsa_key_from_file(os.path.join(BASE_PATH, "rsa.key"))
30-
KC_RSA = KeyBundle({"key": _key, "kty": "RSA", "use": "sig"})
27+
KC_RSA = KeyBundle({"priv_key": _key, "kty": "RSA", "use": "sig"})
3128

3229
CLIENT_ID = "client_1"
3330
IDTOKEN = IdToken(iss="http://oidc.example.org/", sub="sub",
@@ -67,11 +64,13 @@ def create_client(self):
6764
self.client = Client(DB(), config=conf)
6865

6966
def test_construct_authorization_request(self):
70-
req_args = {'state': 'ABCDE',
71-
'redirect_uri': 'https://example.com/auth_cb',
72-
'response_type': ['code']}
67+
req_args = {
68+
'state': 'ABCDE',
69+
'redirect_uri': 'https://example.com/auth_cb',
70+
'response_type': ['code']
71+
}
7372

74-
self.client.session_interface.create_state('issuer',key='ABCDE')
73+
self.client.session_interface.create_state('issuer', key='ABCDE')
7574
msg = self.client.service['authorization'].construct(
7675
request_args=req_args)
7776
assert isinstance(msg, AuthorizationRequest)
@@ -101,16 +100,17 @@ def test_construct_accesstoken_request(self):
101100
request_args=req_args, state='ABCDE')
102101

103102
assert isinstance(msg, AccessTokenRequest)
104-
assert msg.to_dict() == {'client_id': 'client_1',
105-
'code': 'access_code',
106-
'client_secret': 'abcdefghijklmnop',
107-
'grant_type': 'authorization_code',
108-
'redirect_uri':
109-
'https://example.com/cli/authz_cb',
110-
'state': 'ABCDE'}
103+
assert msg.to_dict() == {
104+
'client_id': 'client_1',
105+
'code': 'access_code',
106+
'client_secret': 'abcdefghijklmnop',
107+
'grant_type': 'authorization_code',
108+
'redirect_uri':
109+
'https://example.com/cli/authz_cb',
110+
'state': 'ABCDE'
111+
}
111112

112113
def test_construct_refresh_token_request(self):
113-
114114
self.client.session_interface.create_state('issuer', 'ABCDE')
115115

116116
auth_request = AuthorizationRequest(
@@ -140,7 +140,8 @@ def test_construct_refresh_token_request(self):
140140
'client_id': 'client_1',
141141
'client_secret': 'abcdefghijklmnop',
142142
'grant_type': 'refresh_token',
143-
'refresh_token': 'refresh_with_me'}
143+
'refresh_token': 'refresh_with_me'
144+
}
144145

145146
def test_error_response(self):
146147
err = ResponseMessage(error='Illegal')
@@ -167,4 +168,3 @@ def test_error_response_2(self):
167168
with pytest.raises(OidcServiceError):
168169
self.client.parse_request_response(
169170
self.client.service['authorization'], http_resp)
170-

tests/test_14_oidc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
BASE_PATH = os.path.join(_dirname, "data", "keys")
2424

2525
_key = import_private_rsa_key_from_file(os.path.join(BASE_PATH, "rsa.key"))
26-
KC_RSA = KeyBundle({"key": _key, "kty": "RSA", "use": "sig"})
26+
KC_RSA = KeyBundle({"priv_key": _key, "kty": "RSA", "use": "sig"})
2727

2828
CLIENT_ID = "client_1"
2929
IDTOKEN = IdToken(iss="http://oidc.example.org/", sub="sub",

0 commit comments

Comments
 (0)