11118. Header utilities (extract_matching_headers, context vars)
12129. Logging config (LoggingConfig)
131310. SSL config (expand_path, get_httpx_ssl_client_kwargs)
14- 11. LLMGateway S2S auth (get_llmgw_token_header )
14+ 11. LLMGateway S2S auth (get_llmgw_token )
151512. LLMGateway BYOM validation (validate_byo_model)
161613. Wait strategy (wait_retry_after_with_fallback)
171714. HTTPX client send() behavior (streaming header, URL freezing, header capture)
@@ -105,24 +105,16 @@ def platform_env_vars():
105105
106106@pytest .fixture
107107def mock_platform_auth ():
108- """Context manager that patches get_auth_data and parse_access_token for PlatformSettings tests."""
109- mock_auth_data = MagicMock ()
110- mock_auth_data .access_token = "test-access-token"
111- mock_auth_data .refresh_token = None
112-
108+ """Patches is_token_expired and parse_access_token for PlatformSettings tests."""
113109 with (
114110 patch (
115- "uipath.llm_client.settings.platform.settings.get_auth_data " ,
116- return_value = mock_auth_data ,
111+ "uipath.llm_client.settings.platform.settings.is_token_expired " ,
112+ return_value = False ,
117113 ),
118114 patch (
119115 "uipath.llm_client.settings.platform.settings.parse_access_token" ,
120116 return_value = {"client_id" : "test-client-id" },
121117 ),
122- patch (
123- "uipath.llm_client.settings.platform.settings.is_token_expired" ,
124- return_value = False ,
125- ),
126118 ):
127119 yield
128120
@@ -439,7 +431,7 @@ def test_auth_flow_refreshes_on_401(self, llmgw_s2s_env_vars):
439431
440432 # Mock the token retrieval
441433 with patch .object (
442- LLMGatewayS2SAuth , "get_llmgw_token_header " , return_value = "new-token"
434+ LLMGatewayS2SAuth , "get_llmgw_token " , return_value = "new-token"
443435 ) as mock_get_token :
444436 auth = LLMGatewayS2SAuth (settings = settings )
445437 # First call is during __init__
@@ -1702,7 +1694,7 @@ def test_response_patched_with_raise_for_status(self):
17021694
17031695
17041696class TestLLMGatewayS2STokenAcquisition :
1705- """Tests for LLMGatewayS2SAuth.get_llmgw_token_header ."""
1697+ """Tests for LLMGatewayS2SAuth.get_llmgw_token ."""
17061698
17071699 def test_s2s_token_success (self , llmgw_s2s_env_vars ):
17081700 from uipath .llm_client .settings .llmgateway .auth import LLMGatewayS2SAuth
@@ -1718,53 +1710,45 @@ def test_s2s_token_success(self, llmgw_s2s_env_vars):
17181710 auth = LLMGatewayS2SAuth (settings = settings )
17191711 assert auth .access_token == "s2s-token-value"
17201712
1721- def test_s2s_token_client_error_raises_auth_error (self , llmgw_s2s_env_vars ):
1713+ def test_s2s_token_client_error_returns_none (self , llmgw_s2s_env_vars ):
17221714 from uipath .llm_client .settings .llmgateway .auth import LLMGatewayS2SAuth
17231715
17241716 mock_response = MagicMock ()
1725- mock_response .is_client_error = True
1726- mock_response .json .return_value = {"error" : "invalid_client" }
1727- mock_response .request = MagicMock (spec = Request )
1717+ mock_response .is_error = True
17281718 mock_response .status_code = 401
17291719 mock_response .reason_phrase = "Unauthorized"
1730- mock_response .headers = {}
17311720
17321721 with patch .dict (os .environ , llmgw_s2s_env_vars , clear = True ):
17331722 settings = LLMGatewaySettings ()
17341723 with patch .object (Client , "post" , return_value = mock_response ):
1735- with pytest . raises ( UiPathAuthenticationError , match = "invalid credentials" ):
1736- LLMGatewayS2SAuth ( settings = settings )
1724+ auth = LLMGatewayS2SAuth ( settings = settings )
1725+ assert auth . access_token is None
17371726
1738- def test_s2s_token_server_error_raises_api_error (self , llmgw_s2s_env_vars ):
1727+ def test_s2s_token_server_error_returns_none (self , llmgw_s2s_env_vars ):
17391728 from uipath .llm_client .settings .llmgateway .auth import LLMGatewayS2SAuth
17401729
17411730 mock_response = MagicMock ()
1742- mock_response .is_client_error = False
17431731 mock_response .is_error = True
17441732 mock_response .status_code = 500
17451733 mock_response .reason_phrase = "Server Error"
1746- mock_response .json .return_value = {"error" : "internal" }
1747- mock_response .request = MagicMock (spec = Request )
1748- mock_response .headers = {}
17491734
17501735 with patch .dict (os .environ , llmgw_s2s_env_vars , clear = True ):
17511736 settings = LLMGatewaySettings ()
17521737 with patch .object (Client , "post" , return_value = mock_response ):
1753- with pytest . raises ( UiPathAPIError ):
1754- LLMGatewayS2SAuth ( settings = settings )
1738+ auth = LLMGatewayS2SAuth ( settings = settings )
1739+ assert auth . access_token is None
17551740
1756- def test_s2s_missing_credentials_raises_value_error (self , llmgw_env_vars ):
1741+ def test_s2s_missing_credentials_returns_none (self , llmgw_env_vars ):
17571742 from uipath .llm_client .settings .llmgateway .auth import LLMGatewayS2SAuth
17581743
17591744 with patch .dict (os .environ , llmgw_env_vars , clear = True ):
17601745 settings = LLMGatewaySettings ()
17611746 # Clear access_token to force S2S flow, but credentials are missing
17621747 settings .access_token = None
17631748 settings .client_id = None
1764- with pytest .raises (ValueError , match = "client_id and client_secret are required" ):
1765- auth = LLMGatewayS2SAuth .__new__ (LLMGatewayS2SAuth )
1766- auth .settings = settings
1767- auth .get_llmgw_token_header ()
1749+ auth = LLMGatewayS2SAuth .__new__ (LLMGatewayS2SAuth )
1750+ auth .settings = settings
1751+ assert auth .get_llmgw_token () is None
17681752
17691753
17701754# ============================================================================
0 commit comments