@@ -974,6 +974,77 @@ def test_for_model_with_autocomplete_model(self) -> None:
974974 assert provider_config .tools is None
975975
976976
977+ class TestSSLConfiguration :
978+ """Tests for SSL configuration across all OpenAI-like providers."""
979+
980+ @pytest .mark .parametrize (
981+ ("provider_name" , "provider_method" , "api_key_config" ),
982+ [
983+ ("openai" , "for_openai" , {"open_ai" : {"api_key" : "test-key" }}),
984+ ("github" , "for_github" , {"github" : {"api_key" : "test-key" }}),
985+ ("ollama" , "for_ollama" , {"ollama" : {"api_key" : "test-key" }}),
986+ ],
987+ )
988+ def test_ssl_config_from_provider_config (
989+ self ,
990+ provider_name : str ,
991+ provider_method : str ,
992+ api_key_config : AiConfig ,
993+ ) -> None :
994+ """Test SSL configuration is read from provider config."""
995+ # Get the provider key from api_key_config
996+ provider_key = next (iter (api_key_config .keys ()))
997+
998+ config : AiConfig = {
999+ ** api_key_config ,
1000+ }
1001+ config [provider_key ]["ssl_verify" ] = False
1002+ config [provider_key ]["ca_bundle_path" ] = "/custom/path/to/ca.pem"
1003+ config [provider_key ]["client_pem" ] = "/custom/path/to/client.pem"
1004+ config [provider_key ]["extra_headers" ] = {"X-Custom" : "header" }
1005+
1006+ method = getattr (AnyProviderConfig , provider_method )
1007+ provider_config = method (config )
1008+
1009+ assert provider_config .ssl_verify is False , (
1010+ f"{ provider_name } : ssl_verify should be False"
1011+ )
1012+ assert provider_config .ca_bundle_path == "/custom/path/to/ca.pem" , (
1013+ f"{ provider_name } : ca_bundle_path should match"
1014+ )
1015+ assert provider_config .client_pem == "/custom/path/to/client.pem" , (
1016+ f"{ provider_name } : client_pem should match"
1017+ )
1018+ assert provider_config .extra_headers == {"X-Custom" : "header" }, (
1019+ f"{ provider_name } : extra_headers should match"
1020+ )
1021+
1022+ @pytest .mark .parametrize (
1023+ ("provider_name" , "provider_method" , "api_key_config" ),
1024+ [
1025+ ("openai" , "for_openai" , {"open_ai" : {"api_key" : "test-key" }}),
1026+ ("github" , "for_github" , {"github" : {"api_key" : "test-key" }}),
1027+ ("ollama" , "for_ollama" , {"ollama" : {"api_key" : "test-key" }}),
1028+ ],
1029+ )
1030+ @patch .dict (os .environ , {"SSL_CERT_FILE" : "/env/path/to/ca.pem" })
1031+ def test_ssl_cert_file_fallback (
1032+ self ,
1033+ provider_name : str ,
1034+ provider_method : str ,
1035+ api_key_config : AiConfig ,
1036+ ) -> None :
1037+ """Test SSL_CERT_FILE environment variable is used as fallback."""
1038+ config : AiConfig = {** api_key_config }
1039+
1040+ method = getattr (AnyProviderConfig , provider_method )
1041+ provider_config = method (config )
1042+
1043+ assert provider_config .ca_bundle_path == "/env/path/to/ca.pem" , (
1044+ f"{ provider_name } : should use SSL_CERT_FILE env var as fallback"
1045+ )
1046+
1047+
9771048class TestEdgeCases :
9781049 """Tests for edge cases and error conditions."""
9791050
0 commit comments