@@ -79,9 +79,7 @@ def test_oauth_client_credentials_auth_provider_exchange_token():
79
79
mock_session = MagicMock (spec = Session )
80
80
mock_session .headers = MagicMock ()
81
81
82
- token = OAuthClientCredentials (
83
- "access-token" , 3600 , int (datetime .now ().timestamp ())
84
- )
82
+ token = OAuthClientCredentials ("access-token" , 3600 , int (datetime .now ().timestamp ()))
85
83
oauth_client .client_credentials .return_value = token
86
84
87
85
provider .add_auth_header (mock_session )
@@ -104,9 +102,7 @@ def test_oauth_client_credentials_auth_provider_reuse_token():
104
102
mock_session = MagicMock (spec = Session )
105
103
mock_session .headers = MagicMock ()
106
104
107
- valid_token = OAuthClientCredentials (
108
- "valid-token" , 3600 , int (datetime .now ().timestamp ())
109
- )
105
+ valid_token = OAuthClientCredentials ("valid-token" , 3600 , int (datetime .now ().timestamp ()))
110
106
provider .current_token = valid_token
111
107
112
108
provider .add_auth_header (mock_session )
@@ -132,9 +128,7 @@ def test_oauth_client_credentials_auth_provider_refresh_token():
132
128
expired_token = OAuthClientCredentials (
133
129
"expired-token" , 1 , int (datetime .now ().timestamp ()) - 3600
134
130
)
135
- new_token = OAuthClientCredentials (
136
- "new-token" , 3600 , int (datetime .now ().timestamp ())
137
- )
131
+ new_token = OAuthClientCredentials ("new-token" , 3600 , int (datetime .now ().timestamp ()))
138
132
provider .current_token = expired_token
139
133
oauth_client .client_credentials .return_value = new_token
140
134
@@ -166,9 +160,7 @@ def test_oauth_client_credentials_auth_provider_needs_refresh():
166
160
)
167
161
assert provider .needs_refresh (token_expiring_soon )
168
162
169
- valid_token = OAuthClientCredentials (
170
- "valid-token" , 600 + 10 , int (datetime .now ().timestamp ())
171
- )
163
+ valid_token = OAuthClientCredentials ("valid-token" , 600 + 10 , int (datetime .now ().timestamp ()))
172
164
assert not provider .needs_refresh (valid_token )
173
165
174
166
@@ -208,9 +200,7 @@ def test_basic_auth_provider_add_auth_header():
208
200
session .headers = MagicMock ()
209
201
session .auth = MagicMock ()
210
202
provider .add_auth_header (session )
211
- session .post (
212
- "https://localhost/delta-sharing/" , data = {"grant_type" : "client_credentials" }
213
- )
203
+ session .post ("https://localhost/delta-sharing/" , data = {"grant_type" : "client_credentials" })
214
204
assert session .auth == ("username" , "password" )
215
205
216
206
@@ -232,9 +222,7 @@ def test_factory_creation():
232
222
username = "username" ,
233
223
password = "password" ,
234
224
)
235
- provider = AuthCredentialProviderFactory .create_auth_credential_provider (
236
- profile_basic
237
- )
225
+ provider = AuthCredentialProviderFactory .create_auth_credential_provider (profile_basic )
238
226
assert isinstance (provider , BasicAuthProvider )
239
227
240
228
profile_bearer = DeltaSharingProfile (
@@ -244,9 +232,7 @@ def test_factory_creation():
244
232
bearer_token = "token" ,
245
233
expiration_time = (datetime .now () + timedelta (hours = 1 )).isoformat (),
246
234
)
247
- provider = AuthCredentialProviderFactory .create_auth_credential_provider (
248
- profile_bearer
249
- )
235
+ provider = AuthCredentialProviderFactory .create_auth_credential_provider (profile_bearer )
250
236
assert isinstance (provider , BearerTokenAuthProvider )
251
237
252
238
profile_oauth = DeltaSharingProfile (
@@ -257,9 +243,7 @@ def test_factory_creation():
257
243
client_id = "clientId" ,
258
244
client_secret = "clientSecret" ,
259
245
)
260
- provider = AuthCredentialProviderFactory .create_auth_credential_provider (
261
- profile_oauth
262
- )
246
+ provider = AuthCredentialProviderFactory .create_auth_credential_provider (profile_oauth )
263
247
assert isinstance (provider , OAuthClientCredentialsAuthProvider )
264
248
265
249
profile_pk = DeltaSharingProfile (
@@ -287,9 +271,7 @@ def test_oauth_auth_provider_reused():
287
271
client_id = "clientId" ,
288
272
client_secret = "clientSecret" ,
289
273
)
290
- provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (
291
- profile_oauth1
292
- )
274
+ provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_oauth1 )
293
275
assert isinstance (provider1 , OAuthClientCredentialsAuthProvider )
294
276
295
277
profile_oauth2 = DeltaSharingProfile (
@@ -301,9 +283,7 @@ def test_oauth_auth_provider_reused():
301
283
client_secret = "clientSecret" ,
302
284
)
303
285
304
- provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (
305
- profile_oauth2
306
- )
286
+ provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_oauth2 )
307
287
308
288
assert provider1 == provider2
309
289
@@ -317,9 +297,7 @@ def test_oauth_auth_provider_with_different_profiles():
317
297
client_id = "clientId" ,
318
298
client_secret = "clientSecret" ,
319
299
)
320
- provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (
321
- profile_oauth1
322
- )
300
+ provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_oauth1 )
323
301
assert isinstance (provider1 , OAuthClientCredentialsAuthProvider )
324
302
325
303
profile_oauth2 = DeltaSharingProfile (
@@ -331,9 +309,7 @@ def test_oauth_auth_provider_with_different_profiles():
331
309
client_secret = "clientSecret" ,
332
310
)
333
311
334
- provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (
335
- profile_oauth2
336
- )
312
+ provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_oauth2 )
337
313
338
314
assert provider1 != provider2
339
315
@@ -351,9 +327,7 @@ def test_oauth_private_key_auth_provider_reused():
351
327
scope = "scope" ,
352
328
audience = "audience" ,
353
329
)
354
- provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (
355
- profile_pk1
356
- )
330
+ provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_pk1 )
357
331
assert isinstance (provider1 , OAuthClientCredentialsAuthProvider )
358
332
359
333
profile_pk2 = DeltaSharingProfile (
@@ -368,9 +342,7 @@ def test_oauth_private_key_auth_provider_reused():
368
342
scope = "scope" ,
369
343
audience = "audience" ,
370
344
)
371
- provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (
372
- profile_pk2
373
- )
345
+ provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_pk2 )
374
346
assert provider1 == provider2
375
347
376
348
@@ -387,9 +359,7 @@ def test_oauth_private_key_auth_provider_with_different_profiles():
387
359
scope = "scope" ,
388
360
audience = "audience" ,
389
361
)
390
- provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (
391
- profile_pk1
392
- )
362
+ provider1 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_pk1 )
393
363
assert isinstance (provider1 , OAuthClientCredentialsAuthProvider )
394
364
395
365
profile_pk2 = DeltaSharingProfile (
@@ -404,7 +374,5 @@ def test_oauth_private_key_auth_provider_with_different_profiles():
404
374
scope = "scope" ,
405
375
audience = "audience" ,
406
376
)
407
- provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (
408
- profile_pk2
409
- )
377
+ provider2 = AuthCredentialProviderFactory .create_auth_credential_provider (profile_pk2 )
410
378
assert provider1 != provider2
0 commit comments