@@ -118,33 +118,28 @@ def test_gke_hub_client_from_service_account_info(client_class):
118
118
assert client .transport ._host == "gkehub.googleapis.com:443"
119
119
120
120
121
- @pytest .mark .parametrize ("client_class" , [GkeHubClient , GkeHubAsyncClient ,])
122
- def test_gke_hub_client_service_account_always_use_jwt (client_class ):
123
- with mock .patch .object (
124
- service_account .Credentials , "with_always_use_jwt_access" , create = True
125
- ) as use_jwt :
126
- creds = service_account .Credentials (None , None , None )
127
- client = client_class (credentials = creds )
128
- use_jwt .assert_not_called ()
129
-
130
-
131
121
@pytest .mark .parametrize (
132
122
"transport_class,transport_name" ,
133
123
[
134
124
(transports .GkeHubGrpcTransport , "grpc" ),
135
125
(transports .GkeHubGrpcAsyncIOTransport , "grpc_asyncio" ),
136
126
],
137
127
)
138
- def test_gke_hub_client_service_account_always_use_jwt_true (
139
- transport_class , transport_name
140
- ):
128
+ def test_gke_hub_client_service_account_always_use_jwt (transport_class , transport_name ):
141
129
with mock .patch .object (
142
130
service_account .Credentials , "with_always_use_jwt_access" , create = True
143
131
) as use_jwt :
144
132
creds = service_account .Credentials (None , None , None )
145
133
transport = transport_class (credentials = creds , always_use_jwt_access = True )
146
134
use_jwt .assert_called_once_with (True )
147
135
136
+ with mock .patch .object (
137
+ service_account .Credentials , "with_always_use_jwt_access" , create = True
138
+ ) as use_jwt :
139
+ creds = service_account .Credentials (None , None , None )
140
+ transport = transport_class (credentials = creds , always_use_jwt_access = False )
141
+ use_jwt .assert_not_called ()
142
+
148
143
149
144
@pytest .mark .parametrize ("client_class" , [GkeHubClient , GkeHubAsyncClient ,])
150
145
def test_gke_hub_client_from_service_account_file (client_class ):
@@ -213,6 +208,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_
213
208
client_cert_source_for_mtls = None ,
214
209
quota_project_id = None ,
215
210
client_info = transports .base .DEFAULT_CLIENT_INFO ,
211
+ always_use_jwt_access = True ,
216
212
)
217
213
218
214
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -229,6 +225,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_
229
225
client_cert_source_for_mtls = None ,
230
226
quota_project_id = None ,
231
227
client_info = transports .base .DEFAULT_CLIENT_INFO ,
228
+ always_use_jwt_access = True ,
232
229
)
233
230
234
231
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -245,6 +242,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_
245
242
client_cert_source_for_mtls = None ,
246
243
quota_project_id = None ,
247
244
client_info = transports .base .DEFAULT_CLIENT_INFO ,
245
+ always_use_jwt_access = True ,
248
246
)
249
247
250
248
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -273,6 +271,7 @@ def test_gke_hub_client_client_options(client_class, transport_class, transport_
273
271
client_cert_source_for_mtls = None ,
274
272
quota_project_id = "octopus" ,
275
273
client_info = transports .base .DEFAULT_CLIENT_INFO ,
274
+ always_use_jwt_access = True ,
276
275
)
277
276
278
277
@@ -335,6 +334,7 @@ def test_gke_hub_client_mtls_env_auto(
335
334
client_cert_source_for_mtls = expected_client_cert_source ,
336
335
quota_project_id = None ,
337
336
client_info = transports .base .DEFAULT_CLIENT_INFO ,
337
+ always_use_jwt_access = True ,
338
338
)
339
339
340
340
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -368,6 +368,7 @@ def test_gke_hub_client_mtls_env_auto(
368
368
client_cert_source_for_mtls = expected_client_cert_source ,
369
369
quota_project_id = None ,
370
370
client_info = transports .base .DEFAULT_CLIENT_INFO ,
371
+ always_use_jwt_access = True ,
371
372
)
372
373
373
374
# Check the case client_cert_source and ADC client cert are not provided.
@@ -389,6 +390,7 @@ def test_gke_hub_client_mtls_env_auto(
389
390
client_cert_source_for_mtls = None ,
390
391
quota_project_id = None ,
391
392
client_info = transports .base .DEFAULT_CLIENT_INFO ,
393
+ always_use_jwt_access = True ,
392
394
)
393
395
394
396
@@ -415,6 +417,7 @@ def test_gke_hub_client_client_options_scopes(
415
417
client_cert_source_for_mtls = None ,
416
418
quota_project_id = None ,
417
419
client_info = transports .base .DEFAULT_CLIENT_INFO ,
420
+ always_use_jwt_access = True ,
418
421
)
419
422
420
423
@@ -441,6 +444,7 @@ def test_gke_hub_client_client_options_credentials_file(
441
444
client_cert_source_for_mtls = None ,
442
445
quota_project_id = None ,
443
446
client_info = transports .base .DEFAULT_CLIENT_INFO ,
447
+ always_use_jwt_access = True ,
444
448
)
445
449
446
450
@@ -458,6 +462,7 @@ def test_gke_hub_client_client_options_from_dict():
458
462
client_cert_source_for_mtls = None ,
459
463
quota_project_id = None ,
460
464
client_info = transports .base .DEFAULT_CLIENT_INFO ,
465
+ always_use_jwt_access = True ,
461
466
)
462
467
463
468
0 commit comments