Skip to content

Commit 60b1590

Browse files
smflorentinoclaude
andcommitted
feat: extract is_ssl_verification_disabled from get_httpx_client_kwargs
Extract the UIPATH_DISABLE_SSL_VERIFY check into a standalone is_ssl_verification_disabled() function so non-httpx HTTP clients can reuse the same SSL disable logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2c18dfa commit 60b1590

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

packages/uipath-platform/src/uipath/platform/common/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ._execution_context import UiPathExecutionContext
1919
from ._external_application_service import ExternalApplicationService
2020
from ._folder_context import FolderContext, header_folder
21-
from ._http_config import get_httpx_client_kwargs
21+
from ._http_config import get_httpx_client_kwargs, is_ssl_verification_disabled
2222
from ._models import Endpoint, RequestSpec
2323
from ._service_url_overrides import inject_routing_headers, resolve_service_url
2424
from ._span_utils import UiPathSpan, _SpanUtils
@@ -93,6 +93,7 @@
9393
"UiPathUrl",
9494
"user_agent_value",
9595
"get_httpx_client_kwargs",
96+
"is_ssl_verification_disabled",
9697
"resource_override",
9798
"header_folder",
9899
"validate_pagination_params",

packages/uipath-platform/src/uipath/platform/common/_http_config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ def create_ssl_context():
3434
)
3535

3636

37+
def is_ssl_verification_disabled() -> bool:
38+
"""Check if SSL verification is disabled via UIPATH_DISABLE_SSL_VERIFY."""
39+
return os.environ.get("UIPATH_DISABLE_SSL_VERIFY", "").lower() in (
40+
"1",
41+
"true",
42+
"yes",
43+
"on",
44+
)
45+
46+
3747
def get_httpx_client_kwargs(
3848
headers: Dict[str, str] | None = None,
3949
) -> Dict[str, Any]:
@@ -44,10 +54,8 @@ def get_httpx_client_kwargs(
4454
Caller headers take priority on key conflicts.
4555
"""
4656
client_kwargs: Dict[str, Any] = {"follow_redirects": True, "timeout": 30.0}
47-
disable_ssl_env = os.environ.get("UIPATH_DISABLE_SSL_VERIFY", "").lower()
48-
disable_ssl_from_env = disable_ssl_env in ("1", "true", "yes", "on")
4957

50-
if disable_ssl_from_env:
58+
if is_ssl_verification_disabled():
5159
client_kwargs["verify"] = False
5260
else:
5361
client_kwargs["verify"] = create_ssl_context()

packages/uipath-platform/tests/services/test_http_config.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import pytest
44

55
from uipath.platform.common._config import ConfigurationManager
6-
from uipath.platform.common._http_config import get_httpx_client_kwargs
6+
from uipath.platform.common._http_config import (
7+
get_httpx_client_kwargs,
8+
is_ssl_verification_disabled,
9+
)
710

811

912
@pytest.fixture(autouse=True)
@@ -12,6 +15,27 @@ def _clean_env(monkeypatch: pytest.MonkeyPatch) -> None:
1215
monkeypatch.delenv("UIPATH_DISABLE_SSL_VERIFY", raising=False)
1316

1417

18+
class TestIsSslVerificationDisabled:
19+
"""Tests for is_ssl_verification_disabled()."""
20+
21+
def test_disabled_when_not_set(self) -> None:
22+
assert is_ssl_verification_disabled() is False
23+
24+
@pytest.mark.parametrize("value", ["1", "true", "True", "TRUE", "yes", "on"])
25+
def test_disabled_with_truthy_values(
26+
self, monkeypatch: pytest.MonkeyPatch, value: str
27+
) -> None:
28+
monkeypatch.setenv("UIPATH_DISABLE_SSL_VERIFY", value)
29+
assert is_ssl_verification_disabled() is True
30+
31+
@pytest.mark.parametrize("value", ["0", "false", "no", "off", ""])
32+
def test_enabled_with_falsy_values(
33+
self, monkeypatch: pytest.MonkeyPatch, value: str
34+
) -> None:
35+
monkeypatch.setenv("UIPATH_DISABLE_SSL_VERIFY", value)
36+
assert is_ssl_verification_disabled() is False
37+
38+
1539
class TestGetHttpxClientKwargsHeaders:
1640
"""Tests for header merging in get_httpx_client_kwargs()."""
1741

0 commit comments

Comments
 (0)