11import os
2- import pytest
32import sys
43import time
54
6- from cherrypy import HTTPError
7-
5+ import pytest
86from cryptojwt .jwk .rsa import import_private_rsa_key_from_file
97from cryptojwt .key_bundle import KeyBundle
10-
118from oidcmsg .oauth2 import AccessTokenRequest
129from oidcmsg .oauth2 import AccessTokenResponse
1310from oidcmsg .oauth2 import AuthorizationRequest
2724BASE_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
3229CLIENT_ID = "client_1"
3330IDTOKEN = 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-
0 commit comments