@@ -195,47 +195,6 @@ def test_service_config_set_block_new_outgoing_requests():
195195 assert not config .block_new_outgoing_requests
196196
197197
198- def test_socket_getaddrinfo_bypassed_ip ():
199- """Test that getaddrinfo works when IP is in bypassed_ips list"""
200- # Reset cache and set up bypassed IPs
201- cache = get_cache ()
202- cache .reset ()
203- cache .config .set_bypassed_ips (["192.168.1.0/24" ])
204- cache .config .set_block_new_outgoing_requests (True )
205- cache .config .update_outbound_domains ([{"hostname" : "allowed.com" , "mode" : "allow" }])
206-
207- # Bypassed IP not enforced : no context
208- with pytest .raises (Exception ) as exc_info :
209- socket .getaddrinfo ("unknown.com" , 80 )
210- assert "Zen has blocked an outbound connection to unknown.com" in str (
211- exc_info .value
212- )
213-
214- generate_context (ip = "1.1.1.1" ).set_as_current_context ()
215- with pytest .raises (Exception ) as exc_info :
216- socket .getaddrinfo ("unknown.com" , 80 )
217- assert "Zen has blocked an outbound connection to unknown.com" in str (
218- exc_info .value
219- )
220-
221- generate_context (ip = "192.168.1.80" ).set_as_current_context ()
222- try :
223- socket .getaddrinfo ("unknown.com" , 80 )
224- except Exception :
225- pytest .fail ("getaddrinfo should not throw an error if IP is bypassed" )
226-
227- # Verify hostname was tracked even when bypassed
228- hostnames = get_cache ().hostnames .as_array ()
229- assert (
230- len (hostnames ) == 1
231- ) # All attempts to same hostname:port are tracked together
232- assert hostnames [0 ]["hostname" ] == "unknown.com"
233- assert hostnames [0 ]["port" ] == 80
234- assert (
235- hostnames [0 ]["hits" ] == 3
236- ) # All 3 attempts were tracked (2 blocked, 1 bypassed)
237-
238-
239198def test_socket_getaddrinfo_ip_address_as_hostname ():
240199 """Test that getaddrinfo works when hostname is an IP address"""
241200 # Reset cache to ensure clean state
0 commit comments