diff --git a/packages/uipath-platform/pyproject.toml b/packages/uipath-platform/pyproject.toml index 19119f851..0d6d59836 100644 --- a/packages/uipath-platform/pyproject.toml +++ b/packages/uipath-platform/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-platform" -version = "0.1.0" +version = "0.1.1" description = "HTTP client library for programmatic access to UiPath Platform" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/packages/uipath-platform/src/uipath/platform/common/__init__.py b/packages/uipath-platform/src/uipath/platform/common/__init__.py index f0a82f355..34ff726cd 100644 --- a/packages/uipath-platform/src/uipath/platform/common/__init__.py +++ b/packages/uipath-platform/src/uipath/platform/common/__init__.py @@ -18,7 +18,7 @@ from ._execution_context import UiPathExecutionContext from ._external_application_service import ExternalApplicationService from ._folder_context import FolderContext, header_folder -from ._http_config import get_httpx_client_kwargs +from ._http_config import get_httpx_client_kwargs, is_ssl_verification_disabled from ._models import Endpoint, RequestSpec from ._service_url_overrides import inject_routing_headers, resolve_service_url from ._span_utils import UiPathSpan, _SpanUtils @@ -93,6 +93,7 @@ "UiPathUrl", "user_agent_value", "get_httpx_client_kwargs", + "is_ssl_verification_disabled", "resource_override", "header_folder", "validate_pagination_params", diff --git a/packages/uipath-platform/src/uipath/platform/common/_http_config.py b/packages/uipath-platform/src/uipath/platform/common/_http_config.py index 400c17a5c..599e63a9c 100644 --- a/packages/uipath-platform/src/uipath/platform/common/_http_config.py +++ b/packages/uipath-platform/src/uipath/platform/common/_http_config.py @@ -34,6 +34,16 @@ def create_ssl_context(): ) +def is_ssl_verification_disabled() -> bool: + """Check if SSL verification is disabled via UIPATH_DISABLE_SSL_VERIFY.""" + return os.environ.get("UIPATH_DISABLE_SSL_VERIFY", "").lower() in ( + "1", + "true", + "yes", + "on", + ) + + def get_httpx_client_kwargs( headers: Dict[str, str] | None = None, ) -> Dict[str, Any]: @@ -44,10 +54,8 @@ def get_httpx_client_kwargs( Caller headers take priority on key conflicts. """ client_kwargs: Dict[str, Any] = {"follow_redirects": True, "timeout": 30.0} - disable_ssl_env = os.environ.get("UIPATH_DISABLE_SSL_VERIFY", "").lower() - disable_ssl_from_env = disable_ssl_env in ("1", "true", "yes", "on") - if disable_ssl_from_env: + if is_ssl_verification_disabled(): client_kwargs["verify"] = False else: client_kwargs["verify"] = create_ssl_context() diff --git a/packages/uipath-platform/tests/services/test_http_config.py b/packages/uipath-platform/tests/services/test_http_config.py index 628d69a59..fa8ae3c6a 100644 --- a/packages/uipath-platform/tests/services/test_http_config.py +++ b/packages/uipath-platform/tests/services/test_http_config.py @@ -3,7 +3,10 @@ import pytest from uipath.platform.common._config import ConfigurationManager -from uipath.platform.common._http_config import get_httpx_client_kwargs +from uipath.platform.common._http_config import ( + get_httpx_client_kwargs, + is_ssl_verification_disabled, +) @pytest.fixture(autouse=True) @@ -12,6 +15,27 @@ def _clean_env(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delenv("UIPATH_DISABLE_SSL_VERIFY", raising=False) +class TestIsSslVerificationDisabled: + """Tests for is_ssl_verification_disabled().""" + + def test_disabled_when_not_set(self) -> None: + assert is_ssl_verification_disabled() is False + + @pytest.mark.parametrize("value", ["1", "true", "True", "TRUE", "yes", "on"]) + def test_disabled_with_truthy_values( + self, monkeypatch: pytest.MonkeyPatch, value: str + ) -> None: + monkeypatch.setenv("UIPATH_DISABLE_SSL_VERIFY", value) + assert is_ssl_verification_disabled() is True + + @pytest.mark.parametrize("value", ["0", "false", "no", "off", ""]) + def test_enabled_with_falsy_values( + self, monkeypatch: pytest.MonkeyPatch, value: str + ) -> None: + monkeypatch.setenv("UIPATH_DISABLE_SSL_VERIFY", value) + assert is_ssl_verification_disabled() is False + + class TestGetHttpxClientKwargsHeaders: """Tests for header merging in get_httpx_client_kwargs().""" diff --git a/packages/uipath-platform/uv.lock b/packages/uipath-platform/uv.lock index c6003cde0..f5e838f0a 100644 --- a/packages/uipath-platform/uv.lock +++ b/packages/uipath-platform/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.11" [[package]] @@ -1088,7 +1088,7 @@ dev = [ [[package]] name = "uipath-platform" -version = "0.1.0" +version = "0.1.1" source = { editable = "." } dependencies = [ { name = "httpx" }, diff --git a/packages/uipath/uv.lock b/packages/uipath/uv.lock index d6b014372..11f25c7bc 100644 --- a/packages/uipath/uv.lock +++ b/packages/uipath/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.11" [[package]] @@ -2679,7 +2679,7 @@ dev = [ [[package]] name = "uipath-platform" -version = "0.1.0" +version = "0.1.1" source = { editable = "../uipath-platform" } dependencies = [ { name = "httpx" },