From 1b030dc82da2b603382c764beb62183ea21ea9ac Mon Sep 17 00:00:00 2001 From: Xuan Yang Date: Wed, 24 Jun 2026 12:15:51 -0700 Subject: [PATCH] chore: mark mtls_utils.py as private Co-authored-by: Xuan Yang PiperOrigin-RevId: 937487133 --- .../parameter_manager/parameter_client.py | 4 +-- .../utils/{mtls_utils.py => _mtls_utils.py} | 0 .../test_parameter_client.py | 2 +- tests/unittests/utils/test_mtls_utils.py | 36 +++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) rename src/google/adk/utils/{mtls_utils.py => _mtls_utils.py} (100%) diff --git a/src/google/adk/integrations/parameter_manager/parameter_client.py b/src/google/adk/integrations/parameter_manager/parameter_client.py index 41e5bab9..7d206c4c 100644 --- a/src/google/adk/integrations/parameter_manager/parameter_client.py +++ b/src/google/adk/integrations/parameter_manager/parameter_client.py @@ -26,7 +26,7 @@ from google.cloud import parametermanager_v1 from google.oauth2 import service_account from ... import version -from ...utils import mtls_utils +from ...utils import _mtls_utils USER_AGENT = f"google-adk/{version.__version__}" @@ -121,7 +121,7 @@ class ParameterManagerClient: client_options = None if location: client_options = { - "api_endpoint": mtls_utils.get_api_endpoint( + "api_endpoint": _mtls_utils.get_api_endpoint( location, _DEFAULT_REGIONAL_ENDPOINT_TEMPLATE, _DEFAULT_MTLS_REGIONAL_ENDPOINT_TEMPLATE, diff --git a/src/google/adk/utils/mtls_utils.py b/src/google/adk/utils/_mtls_utils.py similarity index 100% rename from src/google/adk/utils/mtls_utils.py rename to src/google/adk/utils/_mtls_utils.py diff --git a/tests/unittests/integrations/parameter_manager/test_parameter_client.py b/tests/unittests/integrations/parameter_manager/test_parameter_client.py index c17ac368..c2a1efe2 100644 --- a/tests/unittests/integrations/parameter_manager/test_parameter_client.py +++ b/tests/unittests/integrations/parameter_manager/test_parameter_client.py @@ -123,7 +123,7 @@ class TestParameterManagerClient: "google.adk.integrations.parameter_manager.parameter_client.default_service_credential" ) @patch( - "google.adk.integrations.parameter_manager.parameter_client.mtls_utils.get_api_endpoint" + "google.adk.integrations.parameter_manager.parameter_client._mtls_utils.get_api_endpoint" ) def test_init_with_location( self, diff --git a/tests/unittests/utils/test_mtls_utils.py b/tests/unittests/utils/test_mtls_utils.py index 76ea88e7..cfe381ed 100644 --- a/tests/unittests/utils/test_mtls_utils.py +++ b/tests/unittests/utils/test_mtls_utils.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Unit tests for mtls_utils.""" +"""Unit tests for _mtls_utils.""" import os from unittest.mock import MagicMock from unittest.mock import patch -from google.adk.utils import mtls_utils +from google.adk.utils import _mtls_utils import pytest _DEFAULT_TEMPLATE = "service.{location}.rep.googleapis.com" @@ -27,14 +27,14 @@ _LOCATION = "us-central1" class TestMtlsUtils: - """Tests for mtls_utils functions.""" + """Tests for _mtls_utils functions.""" @patch("google.auth.transport.mtls.should_use_client_cert") def test_use_client_cert_effective_with_mtls_cert_true( self, mock_should_use_client_cert ): mock_should_use_client_cert.return_value = True - assert mtls_utils.use_client_cert_effective() is True + assert _mtls_utils.use_client_cert_effective() is True mock_should_use_client_cert.assert_called_once() @patch("google.auth.transport.mtls.should_use_client_cert") @@ -42,7 +42,7 @@ class TestMtlsUtils: self, mock_should_use_client_cert ): mock_should_use_client_cert.return_value = False - assert mtls_utils.use_client_cert_effective() is False + assert _mtls_utils.use_client_cert_effective() is False mock_should_use_client_cert.assert_called_once() @patch("google.auth.transport.mtls.should_use_client_cert") @@ -51,7 +51,7 @@ class TestMtlsUtils: self, mock_should_use_client_cert ): mock_should_use_client_cert.side_effect = AttributeError - assert mtls_utils.use_client_cert_effective() is True + assert _mtls_utils.use_client_cert_effective() is True @patch("google.auth.transport.mtls.should_use_client_cert") @patch.dict("os.environ", {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}) @@ -59,7 +59,7 @@ class TestMtlsUtils: self, mock_should_use_client_cert ): mock_should_use_client_cert.side_effect = AttributeError - assert mtls_utils.use_client_cert_effective() is False + assert _mtls_utils.use_client_cert_effective() is False @patch("google.auth.transport.mtls.should_use_client_cert") @patch.dict("os.environ", {}, clear=True) @@ -67,53 +67,53 @@ class TestMtlsUtils: self, mock_should_use_client_cert ): mock_should_use_client_cert.side_effect = AttributeError - assert mtls_utils.use_client_cert_effective() is False + assert _mtls_utils.use_client_cert_effective() is False - @patch("google.adk.utils.mtls_utils.use_client_cert_effective") + @patch("google.adk.utils._mtls_utils.use_client_cert_effective") @patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}) def test_get_api_endpoint_always(self, mock_use_client_cert): - endpoint = mtls_utils.get_api_endpoint( + endpoint = _mtls_utils.get_api_endpoint( _LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE ) assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION) mock_use_client_cert.assert_not_called() - @patch("google.adk.utils.mtls_utils.use_client_cert_effective") + @patch("google.adk.utils._mtls_utils.use_client_cert_effective") @patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}) def test_get_api_endpoint_never(self, mock_use_client_cert): - endpoint = mtls_utils.get_api_endpoint( + endpoint = _mtls_utils.get_api_endpoint( _LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE ) assert endpoint == _DEFAULT_TEMPLATE.format(location=_LOCATION) mock_use_client_cert.assert_not_called() - @patch("google.adk.utils.mtls_utils.use_client_cert_effective") + @patch("google.adk.utils._mtls_utils.use_client_cert_effective") @patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) def test_get_api_endpoint_auto_with_cert(self, mock_use_client_cert): mock_use_client_cert.return_value = True - endpoint = mtls_utils.get_api_endpoint( + endpoint = _mtls_utils.get_api_endpoint( _LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE ) assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION) mock_use_client_cert.assert_called_once() - @patch("google.adk.utils.mtls_utils.use_client_cert_effective") + @patch("google.adk.utils._mtls_utils.use_client_cert_effective") @patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) def test_get_api_endpoint_auto_without_cert(self, mock_use_client_cert): mock_use_client_cert.return_value = False - endpoint = mtls_utils.get_api_endpoint( + endpoint = _mtls_utils.get_api_endpoint( _LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE ) assert endpoint == _DEFAULT_TEMPLATE.format(location=_LOCATION) mock_use_client_cert.assert_called_once() - @patch("google.adk.utils.mtls_utils.use_client_cert_effective") + @patch("google.adk.utils._mtls_utils.use_client_cert_effective") @patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "invalid_value"}) def test_get_api_endpoint_invalid_fallback_to_auto( self, mock_use_client_cert ): mock_use_client_cert.return_value = True - endpoint = mtls_utils.get_api_endpoint( + endpoint = _mtls_utils.get_api_endpoint( _LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE ) assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION)