Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00d1a78

Browse filesBrowse files
fix: enable self signed jwt for grpc (#185)
PiperOrigin-RevId: 386504689 Source-Link: googleapis/googleapis@762094a Source-Link: googleapis/googleapis-gen@6bfc480
1 parent 0ff5828 commit 00d1a78
Copy full SHA for 00d1a78

File tree

Expand file treeCollapse file tree

2 files changed

+22
-13
lines changed
Filter options
  • packages/google-cloud-bigquery-datatransfer
Expand file treeCollapse file tree

2 files changed

+22
-13
lines changed

‎packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/client.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/client.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ def __init__(
388388
client_cert_source_for_mtls=client_cert_source_func,
389389
quota_project_id=client_options.quota_project_id,
390390
client_info=client_info,
391+
always_use_jwt_access=(
392+
Transport == type(self).get_transport_class("grpc")
393+
or Transport == type(self).get_transport_class("grpc_asyncio")
394+
),
391395
)
392396

393397
def get_data_source(

‎packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py

Copy file name to clipboardExpand all lines: packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py
+18-13Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,14 @@ def test_data_transfer_service_client_from_service_account_info(client_class):
131131
assert client.transport._host == "bigquerydatatransfer.googleapis.com:443"
132132

133133

134-
@pytest.mark.parametrize(
135-
"client_class", [DataTransferServiceClient, DataTransferServiceAsyncClient,]
136-
)
137-
def test_data_transfer_service_client_service_account_always_use_jwt(client_class):
138-
with mock.patch.object(
139-
service_account.Credentials, "with_always_use_jwt_access", create=True
140-
) as use_jwt:
141-
creds = service_account.Credentials(None, None, None)
142-
client = client_class(credentials=creds)
143-
use_jwt.assert_not_called()
144-
145-
146134
@pytest.mark.parametrize(
147135
"transport_class,transport_name",
148136
[
149137
(transports.DataTransferServiceGrpcTransport, "grpc"),
150138
(transports.DataTransferServiceGrpcAsyncIOTransport, "grpc_asyncio"),
151139
],
152140
)
153-
def test_data_transfer_service_client_service_account_always_use_jwt_true(
141+
def test_data_transfer_service_client_service_account_always_use_jwt(
154142
transport_class, transport_name
155143
):
156144
with mock.patch.object(
@@ -160,6 +148,13 @@ def test_data_transfer_service_client_service_account_always_use_jwt_true(
160148
transport = transport_class(credentials=creds, always_use_jwt_access=True)
161149
use_jwt.assert_called_once_with(True)
162150

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

164159
@pytest.mark.parametrize(
165160
"client_class", [DataTransferServiceClient, DataTransferServiceAsyncClient,]
@@ -244,6 +239,7 @@ def test_data_transfer_service_client_client_options(
244239
client_cert_source_for_mtls=None,
245240
quota_project_id=None,
246241
client_info=transports.base.DEFAULT_CLIENT_INFO,
242+
always_use_jwt_access=True,
247243
)
248244

249245
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -260,6 +256,7 @@ def test_data_transfer_service_client_client_options(
260256
client_cert_source_for_mtls=None,
261257
quota_project_id=None,
262258
client_info=transports.base.DEFAULT_CLIENT_INFO,
259+
always_use_jwt_access=True,
263260
)
264261

265262
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is
@@ -276,6 +273,7 @@ def test_data_transfer_service_client_client_options(
276273
client_cert_source_for_mtls=None,
277274
quota_project_id=None,
278275
client_info=transports.base.DEFAULT_CLIENT_INFO,
276+
always_use_jwt_access=True,
279277
)
280278

281279
# Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has
@@ -304,6 +302,7 @@ def test_data_transfer_service_client_client_options(
304302
client_cert_source_for_mtls=None,
305303
quota_project_id="octopus",
306304
client_info=transports.base.DEFAULT_CLIENT_INFO,
305+
always_use_jwt_access=True,
307306
)
308307

309308

@@ -380,6 +379,7 @@ def test_data_transfer_service_client_mtls_env_auto(
380379
client_cert_source_for_mtls=expected_client_cert_source,
381380
quota_project_id=None,
382381
client_info=transports.base.DEFAULT_CLIENT_INFO,
382+
always_use_jwt_access=True,
383383
)
384384

385385
# Check the case ADC client cert is provided. Whether client cert is used depends on
@@ -413,6 +413,7 @@ def test_data_transfer_service_client_mtls_env_auto(
413413
client_cert_source_for_mtls=expected_client_cert_source,
414414
quota_project_id=None,
415415
client_info=transports.base.DEFAULT_CLIENT_INFO,
416+
always_use_jwt_access=True,
416417
)
417418

418419
# Check the case client_cert_source and ADC client cert are not provided.
@@ -434,6 +435,7 @@ def test_data_transfer_service_client_mtls_env_auto(
434435
client_cert_source_for_mtls=None,
435436
quota_project_id=None,
436437
client_info=transports.base.DEFAULT_CLIENT_INFO,
438+
always_use_jwt_access=True,
437439
)
438440

439441

@@ -468,6 +470,7 @@ def test_data_transfer_service_client_client_options_scopes(
468470
client_cert_source_for_mtls=None,
469471
quota_project_id=None,
470472
client_info=transports.base.DEFAULT_CLIENT_INFO,
473+
always_use_jwt_access=True,
471474
)
472475

473476

@@ -502,6 +505,7 @@ def test_data_transfer_service_client_client_options_credentials_file(
502505
client_cert_source_for_mtls=None,
503506
quota_project_id=None,
504507
client_info=transports.base.DEFAULT_CLIENT_INFO,
508+
always_use_jwt_access=True,
505509
)
506510

507511

@@ -521,6 +525,7 @@ def test_data_transfer_service_client_client_options_from_dict():
521525
client_cert_source_for_mtls=None,
522526
quota_project_id=None,
523527
client_info=transports.base.DEFAULT_CLIENT_INFO,
528+
always_use_jwt_access=True,
524529
)
525530

526531

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.