35
35
from google .iam .v1 import options_pb2 # type: ignore
36
36
from google .iam .v1 import policy_pb2 # type: ignore
37
37
from google .oauth2 import service_account
38
- from google .protobuf import duration_pb2 # type: ignore
39
38
from google .protobuf import field_mask_pb2 # type: ignore
40
39
from google .protobuf import timestamp_pb2 # type: ignore
41
40
from google .pubsub_v1 .services .publisher import PublisherAsyncClient
@@ -116,24 +115,14 @@ def test_publisher_client_from_service_account_info(client_class):
116
115
assert client .transport ._host == "pubsub.googleapis.com:443"
117
116
118
117
119
- @pytest .mark .parametrize ("client_class" , [PublisherClient , PublisherAsyncClient ,])
120
- def test_publisher_client_service_account_always_use_jwt (client_class ):
121
- with mock .patch .object (
122
- service_account .Credentials , "with_always_use_jwt_access" , create = True
123
- ) as use_jwt :
124
- creds = service_account .Credentials (None , None , None )
125
- client = client_class (credentials = creds )
126
- use_jwt .assert_not_called ()
127
-
128
-
129
118
@pytest .mark .parametrize (
130
119
"transport_class,transport_name" ,
131
120
[
132
121
(transports .PublisherGrpcTransport , "grpc" ),
133
122
(transports .PublisherGrpcAsyncIOTransport , "grpc_asyncio" ),
134
123
],
135
124
)
136
- def test_publisher_client_service_account_always_use_jwt_true (
125
+ def test_publisher_client_service_account_always_use_jwt (
137
126
transport_class , transport_name
138
127
):
139
128
with mock .patch .object (
@@ -143,6 +132,13 @@ def test_publisher_client_service_account_always_use_jwt_true(
143
132
transport = transport_class (credentials = creds , always_use_jwt_access = True )
144
133
use_jwt .assert_called_once_with (True )
145
134
135
+ with mock .patch .object (
136
+ service_account .Credentials , "with_always_use_jwt_access" , create = True
137
+ ) as use_jwt :
138
+ creds = service_account .Credentials (None , None , None )
139
+ transport = transport_class (credentials = creds , always_use_jwt_access = False )
140
+ use_jwt .assert_not_called ()
141
+
146
142
147
143
@pytest .mark .parametrize ("client_class" , [PublisherClient , PublisherAsyncClient ,])
148
144
def test_publisher_client_from_service_account_file (client_class ):
@@ -217,6 +213,7 @@ def test_publisher_client_client_options(client_class, transport_class, transpor
217
213
client_cert_source_for_mtls = None ,
218
214
quota_project_id = None ,
219
215
client_info = transports .base .DEFAULT_CLIENT_INFO ,
216
+ always_use_jwt_access = True ,
220
217
)
221
218
222
219
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -233,6 +230,7 @@ def test_publisher_client_client_options(client_class, transport_class, transpor
233
230
client_cert_source_for_mtls = None ,
234
231
quota_project_id = None ,
235
232
client_info = transports .base .DEFAULT_CLIENT_INFO ,
233
+ always_use_jwt_access = True ,
236
234
)
237
235
238
236
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -249,6 +247,7 @@ def test_publisher_client_client_options(client_class, transport_class, transpor
249
247
client_cert_source_for_mtls = None ,
250
248
quota_project_id = None ,
251
249
client_info = transports .base .DEFAULT_CLIENT_INFO ,
250
+ always_use_jwt_access = True ,
252
251
)
253
252
254
253
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -277,6 +276,7 @@ def test_publisher_client_client_options(client_class, transport_class, transpor
277
276
client_cert_source_for_mtls = None ,
278
277
quota_project_id = "octopus" ,
279
278
client_info = transports .base .DEFAULT_CLIENT_INFO ,
279
+ always_use_jwt_access = True ,
280
280
)
281
281
282
282
@@ -341,6 +341,7 @@ def test_publisher_client_mtls_env_auto(
341
341
client_cert_source_for_mtls = expected_client_cert_source ,
342
342
quota_project_id = None ,
343
343
client_info = transports .base .DEFAULT_CLIENT_INFO ,
344
+ always_use_jwt_access = True ,
344
345
)
345
346
346
347
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -374,6 +375,7 @@ def test_publisher_client_mtls_env_auto(
374
375
client_cert_source_for_mtls = expected_client_cert_source ,
375
376
quota_project_id = None ,
376
377
client_info = transports .base .DEFAULT_CLIENT_INFO ,
378
+ always_use_jwt_access = True ,
377
379
)
378
380
379
381
# Check the case client_cert_source and ADC client cert are not provided.
@@ -395,6 +397,7 @@ def test_publisher_client_mtls_env_auto(
395
397
client_cert_source_for_mtls = None ,
396
398
quota_project_id = None ,
397
399
client_info = transports .base .DEFAULT_CLIENT_INFO ,
400
+ always_use_jwt_access = True ,
398
401
)
399
402
400
403
@@ -425,6 +428,7 @@ def test_publisher_client_client_options_scopes(
425
428
client_cert_source_for_mtls = None ,
426
429
quota_project_id = None ,
427
430
client_info = transports .base .DEFAULT_CLIENT_INFO ,
431
+ always_use_jwt_access = True ,
428
432
)
429
433
430
434
@@ -455,6 +459,7 @@ def test_publisher_client_client_options_credentials_file(
455
459
client_cert_source_for_mtls = None ,
456
460
quota_project_id = None ,
457
461
client_info = transports .base .DEFAULT_CLIENT_INFO ,
462
+ always_use_jwt_access = True ,
458
463
)
459
464
460
465
@@ -472,6 +477,7 @@ def test_publisher_client_client_options_from_dict():
472
477
client_cert_source_for_mtls = None ,
473
478
quota_project_id = None ,
474
479
client_info = transports .base .DEFAULT_CLIENT_INFO ,
480
+ always_use_jwt_access = True ,
475
481
)
476
482
477
483
0 commit comments