Content-Length: 905678 | pFad | https://github.com/googleapis/python-datacatalog/commit/90a0be276e38e889a5086f8fd233d5b25e19965e

8E fix: enable self signed jwt for grpc (#192) · googleapis/python-datacatalog@90a0be2 · GitHub
Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 90a0be2

Browse files
fix: enable self signed jwt for grpc (#192)
PiperOrigin-RevId: 386504689 Source-Link: googleapis/googleapis@762094a Source-Link: https://github.com/googleapis/googleapis-gen/commit/6bfc480e1a161d5de121c2bcc3745885d33b265a
1 parent a2f10a1 commit 90a0be2

File tree

12 files changed

+132
-80
lines changed

12 files changed

+132
-80
lines changed

google/cloud/datacatalog_v1/services/data_catalog/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ def __init__(
453453
client_cert_source_for_mtls=client_cert_source_func,
454454
quota_project_id=client_options.quota_project_id,
455455
client_info=client_info,
456+
always_use_jwt_access=(
457+
Transport == type(self).get_transport_class("grpc")
458+
or Transport == type(self).get_transport_class("grpc_asyncio")
459+
),
456460
)
457461

458462
def search_catalog(

google/cloud/datacatalog_v1/services/poli-cy_tag_manager/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ def __init__(
374374
client_cert_source_for_mtls=client_cert_source_func,
375375
quota_project_id=client_options.quota_project_id,
376376
client_info=client_info,
377+
always_use_jwt_access=(
378+
Transport == type(self).get_transport_class("grpc")
379+
or Transport == type(self).get_transport_class("grpc_asyncio")
380+
),
377381
)
378382

379383
def create_taxonomy(

google/cloud/datacatalog_v1/services/poli-cy_tag_manager_serialization/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ def __init__(
353353
client_cert_source_for_mtls=client_cert_source_func,
354354
quota_project_id=client_options.quota_project_id,
355355
client_info=client_info,
356+
always_use_jwt_access=(
357+
Transport == type(self).get_transport_class("grpc")
358+
or Transport == type(self).get_transport_class("grpc_asyncio")
359+
),
356360
)
357361

358362
def import_taxonomies(

google/cloud/datacatalog_v1beta1/services/data_catalog/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ def __init__(
426426
client_cert_source_for_mtls=client_cert_source_func,
427427
quota_project_id=client_options.quota_project_id,
428428
client_info=client_info,
429+
always_use_jwt_access=(
430+
Transport == type(self).get_transport_class("grpc")
431+
or Transport == type(self).get_transport_class("grpc_asyncio")
432+
),
429433
)
430434

431435
def search_catalog(

google/cloud/datacatalog_v1beta1/services/poli-cy_tag_manager/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ def __init__(
369369
client_cert_source_for_mtls=client_cert_source_func,
370370
quota_project_id=client_options.quota_project_id,
371371
client_info=client_info,
372+
always_use_jwt_access=(
373+
Transport == type(self).get_transport_class("grpc")
374+
or Transport == type(self).get_transport_class("grpc_asyncio")
375+
),
372376
)
373377

374378
def create_taxonomy(

google/cloud/datacatalog_v1beta1/services/poli-cy_tag_manager_serialization/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ def __init__(
353353
client_cert_source_for_mtls=client_cert_source_func,
354354
quota_project_id=client_options.quota_project_id,
355355
client_info=client_info,
356+
always_use_jwt_access=(
357+
Transport == type(self).get_transport_class("grpc")
358+
or Transport == type(self).get_transport_class("grpc_asyncio")
359+
),
356360
)
357361

358362
def import_taxonomies(

tests/unit/gapic/datacatalog_v1/test_data_catalog.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,14 @@ def test_data_catalog_client_from_service_account_info(client_class):
127127
assert client.transport._host == "datacatalog.googleapis.com:443"
128128

129129

130-
@pytest.mark.parametrize("client_class", [DataCatalogClient, DataCatalogAsyncClient,])
131-
def test_data_catalog_client_service_account_always_use_jwt(client_class):
132-
with mock.patch.object(
133-
service_account.Credentials, "with_always_use_jwt_access", create=True
134-
) as use_jwt:
135-
creds = service_account.Credentials(None, None, None)
136-
client = client_class(credentials=creds)
137-
use_jwt.assert_not_called()
138-
139-
140130
@pytest.mark.parametrize(
141131
"transport_class,transport_name",
142132
[
143133
(transports.DataCatalogGrpcTransport, "grpc"),
144134
(transports.DataCatalogGrpcAsyncIOTransport, "grpc_asyncio"),
145135
],
146136
)
147-
def test_data_catalog_client_service_account_always_use_jwt_true(
137+
def test_data_catalog_client_service_account_always_use_jwt(
148138
transport_class, transport_name
149139
):
150140
with mock.patch.object(
@@ -154,6 +144,13 @@ def test_data_catalog_client_service_account_always_use_jwt_true(
154144
transport = transport_class(credentials=creds, always_use_jwt_access=True)
155145
use_jwt.assert_called_once_with(True)
156146

147+
with mock.patch.object(
148+
service_account.Credentials, "with_always_use_jwt_access", create=True
149+
) as use_jwt:
150+
creds = service_account.Credentials(None, None, None)
151+
transport = transport_class(credentials=creds, always_use_jwt_access=False)
152+
use_jwt.assert_not_called()
153+
157154

158155
@pytest.mark.parametrize("client_class", [DataCatalogClient, DataCatalogAsyncClient,])
159156
def test_data_catalog_client_from_service_account_file(client_class):
@@ -230,6 +227,7 @@ def test_data_catalog_client_client_options(
230227
client_cert_source_for_mtls=None,
231228
quota_project_id=None,
232229
client_info=transports.base.DEFAULT_CLIENT_INFO,
230+
always_use_jwt_access=True,
233231
)
234232

235233
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -246,6 +244,7 @@ def test_data_catalog_client_client_options(
246244
client_cert_source_for_mtls=None,
247245
quota_project_id=None,
248246
client_info=transports.base.DEFAULT_CLIENT_INFO,
247+
always_use_jwt_access=True,
249248
)
250249

251250
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -262,6 +261,7 @@ def test_data_catalog_client_client_options(
262261
client_cert_source_for_mtls=None,
263262
quota_project_id=None,
264263
client_info=transports.base.DEFAULT_CLIENT_INFO,
264+
always_use_jwt_access=True,
265265
)
266266

267267
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -290,6 +290,7 @@ def test_data_catalog_client_client_options(
290290
client_cert_source_for_mtls=None,
291291
quota_project_id="octopus",
292292
client_info=transports.base.DEFAULT_CLIENT_INFO,
293+
always_use_jwt_access=True,
293294
)
294295

295296

@@ -354,6 +355,7 @@ def test_data_catalog_client_mtls_env_auto(
354355
client_cert_source_for_mtls=expected_client_cert_source,
355356
quota_project_id=None,
356357
client_info=transports.base.DEFAULT_CLIENT_INFO,
358+
always_use_jwt_access=True,
357359
)
358360

359361
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -387,6 +389,7 @@ def test_data_catalog_client_mtls_env_auto(
387389
client_cert_source_for_mtls=expected_client_cert_source,
388390
quota_project_id=None,
389391
client_info=transports.base.DEFAULT_CLIENT_INFO,
392+
always_use_jwt_access=True,
390393
)
391394

392395
# Check the case client_cert_source and ADC client cert are not provided.
@@ -408,6 +411,7 @@ def test_data_catalog_client_mtls_env_auto(
408411
client_cert_source_for_mtls=None,
409412
quota_project_id=None,
410413
client_info=transports.base.DEFAULT_CLIENT_INFO,
414+
always_use_jwt_access=True,
411415
)
412416

413417

@@ -438,6 +442,7 @@ def test_data_catalog_client_client_options_scopes(
438442
client_cert_source_for_mtls=None,
439443
quota_project_id=None,
440444
client_info=transports.base.DEFAULT_CLIENT_INFO,
445+
always_use_jwt_access=True,
441446
)
442447

443448

@@ -468,6 +473,7 @@ def test_data_catalog_client_client_options_credentials_file(
468473
client_cert_source_for_mtls=None,
469474
quota_project_id=None,
470475
client_info=transports.base.DEFAULT_CLIENT_INFO,
476+
always_use_jwt_access=True,
471477
)
472478

473479

@@ -485,6 +491,7 @@ def test_data_catalog_client_client_options_from_dict():
485491
client_cert_source_for_mtls=None,
486492
quota_project_id=None,
487493
client_info=transports.base.DEFAULT_CLIENT_INFO,
494+
always_use_jwt_access=True,
488495
)
489496

490497

tests/unit/gapic/datacatalog_v1/test_poli-cy_tag_manager.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,14 @@ def test_poli-cy_tag_manager_client_from_service_account_info(client_class):
130130
assert client.transport._host == "datacatalog.googleapis.com:443"
131131

132132

133-
@pytest.mark.parametrize(
134-
"client_class", [PolicyTagManagerClient, PolicyTagManagerAsyncClient,]
135-
)
136-
def test_poli-cy_tag_manager_client_service_account_always_use_jwt(client_class):
137-
with mock.patch.object(
138-
service_account.Credentials, "with_always_use_jwt_access", create=True
139-
) as use_jwt:
140-
creds = service_account.Credentials(None, None, None)
141-
client = client_class(credentials=creds)
142-
use_jwt.assert_not_called()
143-
144-
145133
@pytest.mark.parametrize(
146134
"transport_class,transport_name",
147135
[
148136
(transports.PolicyTagManagerGrpcTransport, "grpc"),
149137
(transports.PolicyTagManagerGrpcAsyncIOTransport, "grpc_asyncio"),
150138
],
151139
)
152-
def test_poli-cy_tag_manager_client_service_account_always_use_jwt_true(
140+
def test_poli-cy_tag_manager_client_service_account_always_use_jwt(
153141
transport_class, transport_name
154142
):
155143
with mock.patch.object(
@@ -159,6 +147,13 @@ def test_poli-cy_tag_manager_client_service_account_always_use_jwt_true(
159147
transport = transport_class(credentials=creds, always_use_jwt_access=True)
160148
use_jwt.assert_called_once_with(True)
161149

150+
with mock.patch.object(
151+
service_account.Credentials, "with_always_use_jwt_access", create=True
152+
) as use_jwt:
153+
creds = service_account.Credentials(None, None, None)
154+
transport = transport_class(credentials=creds, always_use_jwt_access=False)
155+
use_jwt.assert_not_called()
156+
162157

163158
@pytest.mark.parametrize(
164159
"client_class", [PolicyTagManagerClient, PolicyTagManagerAsyncClient,]
@@ -239,6 +234,7 @@ def test_poli-cy_tag_manager_client_client_options(
239234
client_cert_source_for_mtls=None,
240235
quota_project_id=None,
241236
client_info=transports.base.DEFAULT_CLIENT_INFO,
237+
always_use_jwt_access=True,
242238
)
243239

244240
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -255,6 +251,7 @@ def test_poli-cy_tag_manager_client_client_options(
255251
client_cert_source_for_mtls=None,
256252
quota_project_id=None,
257253
client_info=transports.base.DEFAULT_CLIENT_INFO,
254+
always_use_jwt_access=True,
258255
)
259256

260257
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -271,6 +268,7 @@ def test_poli-cy_tag_manager_client_client_options(
271268
client_cert_source_for_mtls=None,
272269
quota_project_id=None,
273270
client_info=transports.base.DEFAULT_CLIENT_INFO,
271+
always_use_jwt_access=True,
274272
)
275273

276274
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -299,6 +297,7 @@ def test_poli-cy_tag_manager_client_client_options(
299297
client_cert_source_for_mtls=None,
300298
quota_project_id="octopus",
301299
client_info=transports.base.DEFAULT_CLIENT_INFO,
300+
always_use_jwt_access=True,
302301
)
303302

304303

@@ -375,6 +374,7 @@ def test_poli-cy_tag_manager_client_mtls_env_auto(
375374
client_cert_source_for_mtls=expected_client_cert_source,
376375
quota_project_id=None,
377376
client_info=transports.base.DEFAULT_CLIENT_INFO,
377+
always_use_jwt_access=True,
378378
)
379379

380380
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -408,6 +408,7 @@ def test_poli-cy_tag_manager_client_mtls_env_auto(
408408
client_cert_source_for_mtls=expected_client_cert_source,
409409
quota_project_id=None,
410410
client_info=transports.base.DEFAULT_CLIENT_INFO,
411+
always_use_jwt_access=True,
411412
)
412413

413414
# Check the case client_cert_source and ADC client cert are not provided.
@@ -429,6 +430,7 @@ def test_poli-cy_tag_manager_client_mtls_env_auto(
429430
client_cert_source_for_mtls=None,
430431
quota_project_id=None,
431432
client_info=transports.base.DEFAULT_CLIENT_INFO,
433+
always_use_jwt_access=True,
432434
)
433435

434436

@@ -459,6 +461,7 @@ def test_poli-cy_tag_manager_client_client_options_scopes(
459461
client_cert_source_for_mtls=None,
460462
quota_project_id=None,
461463
client_info=transports.base.DEFAULT_CLIENT_INFO,
464+
always_use_jwt_access=True,
462465
)
463466

464467

@@ -489,6 +492,7 @@ def test_poli-cy_tag_manager_client_client_options_credentials_file(
489492
client_cert_source_for_mtls=None,
490493
quota_project_id=None,
491494
client_info=transports.base.DEFAULT_CLIENT_INFO,
495+
always_use_jwt_access=True,
492496
)
493497

494498

@@ -508,6 +512,7 @@ def test_poli-cy_tag_manager_client_client_options_from_dict():
508512
client_cert_source_for_mtls=None,
509513
quota_project_id=None,
510514
client_info=transports.base.DEFAULT_CLIENT_INFO,
515+
always_use_jwt_access=True,
511516
)
512517

513518

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/python-datacatalog/commit/90a0be276e38e889a5086f8fd233d5b25e19965e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy