@@ -123,26 +123,14 @@ def test_iam_credentials_client_from_service_account_info(client_class):
123
123
assert client .transport ._host == "iamcredentials.googleapis.com:443"
124
124
125
125
126
- @pytest .mark .parametrize (
127
- "client_class" , [IAMCredentialsClient , IAMCredentialsAsyncClient ,]
128
- )
129
- def test_iam_credentials_client_service_account_always_use_jwt (client_class ):
130
- with mock .patch .object (
131
- service_account .Credentials , "with_always_use_jwt_access" , create = True
132
- ) as use_jwt :
133
- creds = service_account .Credentials (None , None , None )
134
- client = client_class (credentials = creds )
135
- use_jwt .assert_not_called ()
136
-
137
-
138
126
@pytest .mark .parametrize (
139
127
"transport_class,transport_name" ,
140
128
[
141
129
(transports .IAMCredentialsGrpcTransport , "grpc" ),
142
130
(transports .IAMCredentialsGrpcAsyncIOTransport , "grpc_asyncio" ),
143
131
],
144
132
)
145
- def test_iam_credentials_client_service_account_always_use_jwt_true (
133
+ def test_iam_credentials_client_service_account_always_use_jwt (
146
134
transport_class , transport_name
147
135
):
148
136
with mock .patch .object (
@@ -152,6 +140,13 @@ def test_iam_credentials_client_service_account_always_use_jwt_true(
152
140
transport = transport_class (credentials = creds , always_use_jwt_access = True )
153
141
use_jwt .assert_called_once_with (True )
154
142
143
+ with mock .patch .object (
144
+ service_account .Credentials , "with_always_use_jwt_access" , create = True
145
+ ) as use_jwt :
146
+ creds = service_account .Credentials (None , None , None )
147
+ transport = transport_class (credentials = creds , always_use_jwt_access = False )
148
+ use_jwt .assert_not_called ()
149
+
155
150
156
151
@pytest .mark .parametrize (
157
152
"client_class" , [IAMCredentialsClient , IAMCredentialsAsyncClient ,]
@@ -232,6 +227,7 @@ def test_iam_credentials_client_client_options(
232
227
client_cert_source_for_mtls = None ,
233
228
quota_project_id = None ,
234
229
client_info = transports .base .DEFAULT_CLIENT_INFO ,
230
+ always_use_jwt_access = True ,
235
231
)
236
232
237
233
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -248,6 +244,7 @@ def test_iam_credentials_client_client_options(
248
244
client_cert_source_for_mtls = None ,
249
245
quota_project_id = None ,
250
246
client_info = transports .base .DEFAULT_CLIENT_INFO ,
247
+ always_use_jwt_access = True ,
251
248
)
252
249
253
250
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -264,6 +261,7 @@ def test_iam_credentials_client_client_options(
264
261
client_cert_source_for_mtls = None ,
265
262
quota_project_id = None ,
266
263
client_info = transports .base .DEFAULT_CLIENT_INFO ,
264
+ always_use_jwt_access = True ,
267
265
)
268
266
269
267
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -292,6 +290,7 @@ def test_iam_credentials_client_client_options(
292
290
client_cert_source_for_mtls = None ,
293
291
quota_project_id = "octopus" ,
294
292
client_info = transports .base .DEFAULT_CLIENT_INFO ,
293
+ always_use_jwt_access = True ,
295
294
)
296
295
297
296
@@ -358,6 +357,7 @@ def test_iam_credentials_client_mtls_env_auto(
358
357
client_cert_source_for_mtls = expected_client_cert_source ,
359
358
quota_project_id = None ,
360
359
client_info = transports .base .DEFAULT_CLIENT_INFO ,
360
+ always_use_jwt_access = True ,
361
361
)
362
362
363
363
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -391,6 +391,7 @@ def test_iam_credentials_client_mtls_env_auto(
391
391
client_cert_source_for_mtls = expected_client_cert_source ,
392
392
quota_project_id = None ,
393
393
client_info = transports .base .DEFAULT_CLIENT_INFO ,
394
+ always_use_jwt_access = True ,
394
395
)
395
396
396
397
# Check the case client_cert_source and ADC client cert are not provided.
@@ -412,6 +413,7 @@ def test_iam_credentials_client_mtls_env_auto(
412
413
client_cert_source_for_mtls = None ,
413
414
quota_project_id = None ,
414
415
client_info = transports .base .DEFAULT_CLIENT_INFO ,
416
+ always_use_jwt_access = True ,
415
417
)
416
418
417
419
@@ -442,6 +444,7 @@ def test_iam_credentials_client_client_options_scopes(
442
444
client_cert_source_for_mtls = None ,
443
445
quota_project_id = None ,
444
446
client_info = transports .base .DEFAULT_CLIENT_INFO ,
447
+ always_use_jwt_access = True ,
445
448
)
446
449
447
450
@@ -472,6 +475,7 @@ def test_iam_credentials_client_client_options_credentials_file(
472
475
client_cert_source_for_mtls = None ,
473
476
quota_project_id = None ,
474
477
client_info = transports .base .DEFAULT_CLIENT_INFO ,
478
+ always_use_jwt_access = True ,
475
479
)
476
480
477
481
@@ -491,6 +495,7 @@ def test_iam_credentials_client_client_options_from_dict():
491
495
client_cert_source_for_mtls = None ,
492
496
quota_project_id = None ,
493
497
client_info = transports .base .DEFAULT_CLIENT_INFO ,
498
+ always_use_jwt_access = True ,
494
499
)
495
500
496
501
0 commit comments