@@ -97,7 +97,7 @@ def test_read_validate_params_all_valid(self):
9797 client_mock .redirect_uris = [redirect_uri ]
9898
9999 request_mock = Mock (spec = Request )
100- request_mock .get_param .side_effect = [client_id , redirect_uri , state ]
100+ request_mock .get_param .side_effect = [client_id , None , state ]
101101
102102 scope_handler_mock = Mock (Scope )
103103
@@ -197,6 +197,43 @@ def test_read_validate_params_invalid_redirect_uri(self):
197197 clientStoreMock .fetch_by_client_id .assert_called_with (client_id )
198198 self .assertEqual (e .error , "invalid_request" )
199199 self .assertEqual (e .explanation , "redirect_uri is not registered for this client" )
200+
201+ def test_read_validate_params_default_redirect_uri (self ):
202+ """
203+ AuthRequestMixin.read_validate_params should use the correct redirect uri when the client has registered more than one
204+ """
205+ client_id = "cid"
206+ redirect_uri = "http://somewhere"
207+ state = "state"
208+
209+ client_mock = Mock (Client )
210+ client_mock .redirect_uris = ["http://somewhere-else" , redirect_uri ]
211+
212+ request_mock = Mock (spec = Request )
213+ request_mock .get_param .side_effect = [client_id , redirect_uri , state ]
214+
215+ scope_handler_mock = Mock (Scope )
216+
217+ clientStoreMock = Mock (spec = ClientStore )
218+ clientStoreMock .fetch_by_client_id .return_value = client_mock
219+
220+ handler = AuthRequestMixin (client_store = clientStoreMock ,
221+ site_adapter = Mock (),
222+ scope_handler = scope_handler_mock ,
223+ token_generator = Mock ())
224+
225+ result = handler .read_validate_params (request_mock )
226+
227+ request_mock .get_param .assert_has_calls ([call ("client_id" ),
228+ call ("redirect_uri" ),
229+ call ("state" )])
230+ scope_handler_mock .parse .assert_called_with (request_mock )
231+ clientStoreMock .fetch_by_client_id .assert_called_with (client_id )
232+ self .assertEqual (handler .client_id , client_id )
233+ self .assertEqual (handler .redirect_uri , redirect_uri )
234+ self .assertEqual (handler .state , state )
235+ self .assertTrue (result )
236+
200237
201238class AuthorizationCodeAuthHandlerTestCase (unittest .TestCase ):
202239 def test_process (self ):
0 commit comments