Skip to content

Commit 1b030dc

Browse files
xuanyang15copybara-github
authored andcommitted
chore: mark mtls_utils.py as private
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 937487133
1 parent 5d4a13f commit 1b030dc

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/google/adk/integrations/parameter_manager/parameter_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from google.oauth2 import service_account
2727

2828
from ... import version
29-
from ...utils import mtls_utils
29+
from ...utils import _mtls_utils
3030

3131
USER_AGENT = f"google-adk/{version.__version__}"
3232

@@ -121,7 +121,7 @@ def __init__(
121121
client_options = None
122122
if location:
123123
client_options = {
124-
"api_endpoint": mtls_utils.get_api_endpoint(
124+
"api_endpoint": _mtls_utils.get_api_endpoint(
125125
location,
126126
_DEFAULT_REGIONAL_ENDPOINT_TEMPLATE,
127127
_DEFAULT_MTLS_REGIONAL_ENDPOINT_TEMPLATE,

tests/unittests/integrations/parameter_manager/test_parameter_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_init_with_auth_token(self, mock_pm_client_class):
123123
"google.adk.integrations.parameter_manager.parameter_client.default_service_credential"
124124
)
125125
@patch(
126-
"google.adk.integrations.parameter_manager.parameter_client.mtls_utils.get_api_endpoint"
126+
"google.adk.integrations.parameter_manager.parameter_client._mtls_utils.get_api_endpoint"
127127
)
128128
def test_init_with_location(
129129
self,

tests/unittests/utils/test_mtls_utils.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Unit tests for mtls_utils."""
15+
"""Unit tests for _mtls_utils."""
1616

1717
import os
1818
from unittest.mock import MagicMock
1919
from unittest.mock import patch
2020

21-
from google.adk.utils import mtls_utils
21+
from google.adk.utils import _mtls_utils
2222
import pytest
2323

2424
_DEFAULT_TEMPLATE = "service.{location}.rep.googleapis.com"
@@ -27,22 +27,22 @@
2727

2828

2929
class TestMtlsUtils:
30-
"""Tests for mtls_utils functions."""
30+
"""Tests for _mtls_utils functions."""
3131

3232
@patch("google.auth.transport.mtls.should_use_client_cert")
3333
def test_use_client_cert_effective_with_mtls_cert_true(
3434
self, mock_should_use_client_cert
3535
):
3636
mock_should_use_client_cert.return_value = True
37-
assert mtls_utils.use_client_cert_effective() is True
37+
assert _mtls_utils.use_client_cert_effective() is True
3838
mock_should_use_client_cert.assert_called_once()
3939

4040
@patch("google.auth.transport.mtls.should_use_client_cert")
4141
def test_use_client_cert_effective_with_mtls_cert_false(
4242
self, mock_should_use_client_cert
4343
):
4444
mock_should_use_client_cert.return_value = False
45-
assert mtls_utils.use_client_cert_effective() is False
45+
assert _mtls_utils.use_client_cert_effective() is False
4646
mock_should_use_client_cert.assert_called_once()
4747

4848
@patch("google.auth.transport.mtls.should_use_client_cert")
@@ -51,69 +51,69 @@ def test_use_client_cert_effective_fallback_true(
5151
self, mock_should_use_client_cert
5252
):
5353
mock_should_use_client_cert.side_effect = AttributeError
54-
assert mtls_utils.use_client_cert_effective() is True
54+
assert _mtls_utils.use_client_cert_effective() is True
5555

5656
@patch("google.auth.transport.mtls.should_use_client_cert")
5757
@patch.dict("os.environ", {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"})
5858
def test_use_client_cert_effective_fallback_false(
5959
self, mock_should_use_client_cert
6060
):
6161
mock_should_use_client_cert.side_effect = AttributeError
62-
assert mtls_utils.use_client_cert_effective() is False
62+
assert _mtls_utils.use_client_cert_effective() is False
6363

6464
@patch("google.auth.transport.mtls.should_use_client_cert")
6565
@patch.dict("os.environ", {}, clear=True)
6666
def test_use_client_cert_effective_fallback_default_false(
6767
self, mock_should_use_client_cert
6868
):
6969
mock_should_use_client_cert.side_effect = AttributeError
70-
assert mtls_utils.use_client_cert_effective() is False
70+
assert _mtls_utils.use_client_cert_effective() is False
7171

72-
@patch("google.adk.utils.mtls_utils.use_client_cert_effective")
72+
@patch("google.adk.utils._mtls_utils.use_client_cert_effective")
7373
@patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"})
7474
def test_get_api_endpoint_always(self, mock_use_client_cert):
75-
endpoint = mtls_utils.get_api_endpoint(
75+
endpoint = _mtls_utils.get_api_endpoint(
7676
_LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE
7777
)
7878
assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION)
7979
mock_use_client_cert.assert_not_called()
8080

81-
@patch("google.adk.utils.mtls_utils.use_client_cert_effective")
81+
@patch("google.adk.utils._mtls_utils.use_client_cert_effective")
8282
@patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"})
8383
def test_get_api_endpoint_never(self, mock_use_client_cert):
84-
endpoint = mtls_utils.get_api_endpoint(
84+
endpoint = _mtls_utils.get_api_endpoint(
8585
_LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE
8686
)
8787
assert endpoint == _DEFAULT_TEMPLATE.format(location=_LOCATION)
8888
mock_use_client_cert.assert_not_called()
8989

90-
@patch("google.adk.utils.mtls_utils.use_client_cert_effective")
90+
@patch("google.adk.utils._mtls_utils.use_client_cert_effective")
9191
@patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
9292
def test_get_api_endpoint_auto_with_cert(self, mock_use_client_cert):
9393
mock_use_client_cert.return_value = True
94-
endpoint = mtls_utils.get_api_endpoint(
94+
endpoint = _mtls_utils.get_api_endpoint(
9595
_LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE
9696
)
9797
assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION)
9898
mock_use_client_cert.assert_called_once()
9999

100-
@patch("google.adk.utils.mtls_utils.use_client_cert_effective")
100+
@patch("google.adk.utils._mtls_utils.use_client_cert_effective")
101101
@patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"})
102102
def test_get_api_endpoint_auto_without_cert(self, mock_use_client_cert):
103103
mock_use_client_cert.return_value = False
104-
endpoint = mtls_utils.get_api_endpoint(
104+
endpoint = _mtls_utils.get_api_endpoint(
105105
_LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE
106106
)
107107
assert endpoint == _DEFAULT_TEMPLATE.format(location=_LOCATION)
108108
mock_use_client_cert.assert_called_once()
109109

110-
@patch("google.adk.utils.mtls_utils.use_client_cert_effective")
110+
@patch("google.adk.utils._mtls_utils.use_client_cert_effective")
111111
@patch.dict("os.environ", {"GOOGLE_API_USE_MTLS_ENDPOINT": "invalid_value"})
112112
def test_get_api_endpoint_invalid_fallback_to_auto(
113113
self, mock_use_client_cert
114114
):
115115
mock_use_client_cert.return_value = True
116-
endpoint = mtls_utils.get_api_endpoint(
116+
endpoint = _mtls_utils.get_api_endpoint(
117117
_LOCATION, _DEFAULT_TEMPLATE, _MTLS_TEMPLATE
118118
)
119119
assert endpoint == _MTLS_TEMPLATE.format(location=_LOCATION)

0 commit comments

Comments
 (0)