Skip to content

Commit 3b3b4f6

Browse files
committed
Merge branch 'feat/gapic-centralization-api-core-routing' into feat/gapic-centralization-api-core-mtls
2 parents 1716f4a + c0b7860 commit 3b3b4f6

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

packages/google-api-core/google/api_core/gapic_v1/client_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ def should_use_mtls_endpoint(client_cert_available: bool) -> bool:
7575
otherwise falls back to evaluation of GOOGLE_API_USE_MTLS_ENDPOINT.
7676
"""
7777
if hasattr(google.auth.transport.mtls, "should_use_mtls_endpoint"):
78-
return google.auth.transport.mtls.should_use_mtls_endpoint(client_cert_available)
78+
return google.auth.transport.mtls.should_use_mtls_endpoint(
79+
client_cert_available
80+
)
7981

8082
# Fallback logic for older google-auth versions
81-
use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").strip().lower()
83+
use_mtls_endpoint = (
84+
os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").strip().lower()
85+
)
8286
if use_mtls_endpoint == "always":
8387
return True
8488
elif use_mtls_endpoint == "never":

packages/google-api-core/tests/unit/gapic/test_client_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ def test_get_api_endpoint(
194194
default_endpoint_template,
195195
expected,
196196
):
197-
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": use_mtls_endpoint}):
197+
with mock.patch.dict(
198+
os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": use_mtls_endpoint}
199+
):
198200
if isinstance(expected, type) and issubclass(expected, Exception):
199201
with pytest.raises(expected):
200202
get_api_endpoint(

0 commit comments

Comments
 (0)