2525
2626
2727fake_time = time .time ()
28+ CODE = "asdf345xdf"
2829
2930
3031def fake_token (token ):
@@ -51,9 +52,7 @@ def setUp(self):
5152 self .client_secret = "someclientsecret"
5253 self .user_username = "user_username"
5354 self .user_password = "user_password"
54- self .client_WebApplication = WebApplicationClient (
55- self .client_id , code = "asdf345xdf"
56- )
55+ self .client_WebApplication = WebApplicationClient (self .client_id , code = CODE )
5756 self .client_LegacyApplication = LegacyApplicationClient (self .client_id )
5857 self .client_BackendApplication = BackendApplicationClient (self .client_id )
5958 self .client_MobileApplication = MobileApplicationClient (self .client_id )
@@ -291,7 +290,7 @@ def fake_send(r, **kwargs):
291290 _fetch_history [2 ][2 ], expected_auth_header
292291 ) # ensure a Basic Authorization header
293292
294- # scneario 4 - send in a username/password combo
293+ # scenario 4 - send in a username/password combo
295294 # this should send the `client_id` in the headers, like scenario 1
296295 self .assertEqual (
297296 sess .fetch_token (
@@ -312,31 +311,39 @@ def fake_send(r, **kwargs):
312311 self .assertIn ("username=%s" % self .user_username , _fetch_history [3 ][1 ])
313312 self .assertIn ("password=%s" % self .user_password , _fetch_history [3 ][1 ])
314313
314+ # scenario 5 - send data in `params` and not in `data` for providers
315+ # that expect data in URL
316+ self .assertEqual (
317+ sess .fetch_token (url , client_secret = "somesecret" , force_querystring = True ),
318+ self .token ,
319+ )
320+ self .assertIn ("code=%s" % CODE , _fetch_history [4 ][0 ])
321+
315322 # some quick tests for valid ways of supporting `client_secret`
316323
317324 # scenario 2b - force the `client_id` into the body; but the `client_secret` is `None`
318325 self .assertEqual (
319326 sess .fetch_token (url , client_secret = None , include_client_id = True ),
320327 self .token ,
321328 )
322- self .assertEqual (len (_fetch_history ), 5 )
323- self .assertIn ("client_id=%s" % self .client_id , _fetch_history [4 ][1 ])
329+ self .assertEqual (len (_fetch_history ), 6 )
330+ self .assertIn ("client_id=%s" % self .client_id , _fetch_history [5 ][1 ])
324331 self .assertNotIn (
325- "client_secret" , _fetch_history [4 ][1 ]
332+ "client_secret= " , _fetch_history [5 ][1 ]
326333 ) # no `client_secret` in the body
327334 self .assertEqual (
328- _fetch_history [4 ][2 ], None
335+ _fetch_history [5 ][2 ], None
329336 ) # ensure NO Basic Authorization header
330337
331338 # scenario 2c - force the `client_id` into the body; but the `client_secret` is an empty string
332339 self .assertEqual (
333340 sess .fetch_token (url , client_secret = "" , include_client_id = True ), self .token
334341 )
335- self .assertEqual (len (_fetch_history ), 6 )
336- self .assertIn ("client_id=%s" % self .client_id , _fetch_history [5 ][1 ])
337- self .assertIn ("client_secret=" , _fetch_history [5 ][1 ])
342+ self .assertEqual (len (_fetch_history ), 7 )
343+ self .assertIn ("client_id=%s" % self .client_id , _fetch_history [6 ][1 ])
344+ self .assertIn ("client_secret=" , _fetch_history [6 ][1 ])
338345 self .assertEqual (
339- _fetch_history [5 ][2 ], None
346+ _fetch_history [6 ][2 ], None
340347 ) # ensure NO Basic Authorization header
341348
342349 def test_cleans_previous_token_before_fetching_new_one (self ):
0 commit comments