@@ -171,6 +171,55 @@ async def test_grpc_status(client: Client, env: WorkflowEnvironment):
171171 )
172172
173173
174+ def test_connect_config_tls_enabled_by_default_when_api_key_provided ():
175+ """Test that TLS is enabled by default when API key is provided and tls is not configured."""
176+ config = temporalio .service .ConnectConfig (
177+ target_host = "localhost:7233" ,
178+ api_key = "test-api-key" ,
179+ )
180+ # TLS should be auto-enabled when api_key is provided and tls not explicitly set
181+ bridge_config = config ._to_bridge_config ()
182+ assert bridge_config .target_url == "https://localhost:7233"
183+ assert bridge_config .tls_config is not None
184+
185+
186+ def test_connect_config_tls_can_be_explicitly_disabled_even_when_api_key_provided ():
187+ """Test that TLS can be explicitly disabled even when API key is provided."""
188+ config = temporalio .service .ConnectConfig (
189+ target_host = "localhost:7233" ,
190+ api_key = "test-api-key" ,
191+ tls = False ,
192+ )
193+ # TLS should remain disabled when explicitly set to False
194+ assert config .tls is False
195+
196+
197+ def test_connect_config_tls_disabled_by_default_when_no_api_key ():
198+ """Test that TLS is disabled by default when no API key is provided."""
199+ config = temporalio .service .ConnectConfig (
200+ target_host = "localhost:7233" ,
201+ )
202+ # TLS should remain disabled when no api_key is provided
203+ bridge_config = config ._to_bridge_config ()
204+ assert bridge_config .target_url == "http://localhost:7233"
205+ assert bridge_config .tls_config is None
206+
207+
208+ def test_connect_config_tls_explicit_config_preserved ():
209+ """Test that explicit TLS configuration is preserved regardless of API key."""
210+ tls_config = temporalio .service .TLSConfig (
211+ server_root_ca_cert = b"test-cert" ,
212+ domain = "test-domain" ,
213+ )
214+ config = temporalio .service .ConnectConfig (
215+ target_host = "localhost:7233" ,
216+ api_key = "test-api-key" ,
217+ tls = tls_config ,
218+ )
219+ # Explicit TLS config should be preserved
220+ assert config .tls == tls_config
221+
222+
174223async def test_rpc_execution_not_unknown (client : Client ):
175224 """
176225 Execute each rpc method and expect a failure, but ensure the failure is not that the rpc method is unknown
0 commit comments