33import sys
44import time
55
6- from cryptojwt .jwk import rsa_load
6+ from cryptojwt .jwk .rsa import rsa_load
7+ from cryptojwt .key_bundle import KeyBundle
78
8- from oidcmsg .key_bundle import KeyBundle
9- from oidcmsg .oauth2 import AccessTokenRequest , AuthorizationResponse
9+ from oidcmsg .oauth2 import AccessTokenRequest
1010from oidcmsg .oauth2 import AccessTokenResponse
1111from oidcmsg .oauth2 import AuthorizationRequest
12+ from oidcmsg .oauth2 import AuthorizationResponse
1213from oidcmsg .oauth2 import RefreshAccessTokenRequest
1314from oidcmsg .oidc import IdToken
1415from oidcmsg .time_util import utc_time_sans_frac
1516
16- from oidcservice .client_auth import CLIENT_AUTHN_METHOD
1717from oidcservice .state_interface import State
1818
1919from oidcrp .oauth2 import Client
@@ -60,7 +60,7 @@ def test_construct_authorization_request(self):
6060 'redirect_uri' : 'https://example.com/auth_cb' ,
6161 'response_type' : ['code' ]}
6262
63- self .client .state_db . set ( 'ABCDE' , State ( iss = 'issuer' ). to_json () )
63+ self .client .session_interface . create_state ( 'issuer' , key = 'ABCDE' )
6464 msg = self .client .service ['authorization' ].construct (
6565 request_args = req_args )
6666 assert isinstance (msg , AuthorizationRequest )
@@ -71,17 +71,24 @@ def test_construct_accesstoken_request(self):
7171 # Bind access code to state
7272 req_args = {}
7373
74+ self .client .session_interface .create_state ('issuer' , 'ABCDE' )
75+
7476 auth_request = AuthorizationRequest (
7577 redirect_uri = 'https://example.com/cli/authz_cb' ,
7678 state = 'state'
7779 )
80+
81+ self .client .session_interface .store_item (auth_request , 'auth_request' ,
82+ 'ABCDE' )
83+
7884 auth_response = AuthorizationResponse (code = 'access_code' )
79- _state = State ( auth_response = auth_response . to_json (),
80- auth_request = auth_request . to_json ())
81- self . client . state_db . set ( 'ABCDE ' , _state . to_json () )
85+
86+ self . client . session_interface . store_item ( auth_response ,
87+ 'auth_response ' , 'ABCDE' )
8288
8389 msg = self .client .service ['accesstoken' ].construct (
8490 request_args = req_args , state = 'ABCDE' )
91+
8592 assert isinstance (msg , AccessTokenRequest )
8693 assert msg .to_dict () == {'client_id' : 'client_1' ,
8794 'code' : 'access_code' ,
@@ -92,18 +99,28 @@ def test_construct_accesstoken_request(self):
9299 'state' : 'state' }
93100
94101 def test_construct_refresh_token_request (self ):
102+
103+ self .client .session_interface .create_state ('issuer' , 'ABCDE' )
104+
95105 auth_request = AuthorizationRequest (
96106 redirect_uri = 'https://example.com/cli/authz_cb' ,
97107 state = 'state'
98108 )
109+
110+ self .client .session_interface .store_item (auth_request , 'auth_request' ,
111+ 'ABCDE' )
112+
99113 auth_response = AuthorizationResponse (code = 'access_code' )
114+
115+ self .client .session_interface .store_item (auth_response ,
116+ 'auth_response' , 'ABCDE' )
117+
100118 token_response = AccessTokenResponse (refresh_token = "refresh_with_me" ,
101119 access_token = "access" )
102- _state = State (auth_response = auth_response .to_json (),
103- auth_request = auth_request .to_json (),
104- token_response = token_response .to_json ())
105120
106- self .client .state_db .set ('ABCDE' , _state .to_json ())
121+ self .client .session_interface .store_item (token_response ,
122+ 'token_response' , 'ABCDE' )
123+
107124 req_args = {}
108125 msg = self .client .service ['refresh_token' ].construct (
109126 request_args = req_args , state = 'ABCDE' )
0 commit comments