11import pytest
22from .service_config import ServiceConfig
3- from aikido_zen .helpers .iplist import IPList
3+ from aikido_zen .helpers .ip_matcher import IPMatcher
44
55
66def test_service_config_initialization ():
@@ -66,10 +66,10 @@ def test_service_config_initialization():
6666 assert service_config .endpoints [1 ]["route" ] == "/v3"
6767 assert service_config .endpoints [2 ]["route" ] == "/admin"
6868 assert service_config .last_updated_at == last_updated_at
69- assert isinstance (service_config .bypassed_ips , IPList )
70- assert service_config .bypassed_ips .matches ("127.0.0.1" )
71- assert service_config .bypassed_ips .matches ("123.1.2.2" )
72- assert not service_config .bypassed_ips .matches ("1.1.1.1" )
69+ assert isinstance (service_config .bypassed_ips , IPMatcher )
70+ assert service_config .bypassed_ips .has ("127.0.0.1" )
71+ assert service_config .bypassed_ips .has ("123.1.2.2" )
72+ assert not service_config .bypassed_ips .has ("1.1.1.1" )
7373 assert service_config .blocked_uids == set (["1" , "0" , "5" ])
7474
7575 v1_endpoint = service_config .get_endpoints (
@@ -90,10 +90,10 @@ def test_service_config_initialization():
9090 }
9191 )[0 ]
9292 assert admin_endpoint ["route" ] == "/admin"
93- assert isinstance (admin_endpoint ["allowedIPAddresses" ], IPList )
94- assert admin_endpoint ["allowedIPAddresses" ].matches ("192.168.2.1" )
95- assert admin_endpoint ["allowedIPAddresses" ].matches ("1.2.3.4" )
96- assert not admin_endpoint ["allowedIPAddresses" ].matches ("192.168.0.1" )
93+ assert isinstance (admin_endpoint ["allowedIPAddresses" ], IPMatcher )
94+ assert admin_endpoint ["allowedIPAddresses" ].has ("192.168.2.1" )
95+ assert admin_endpoint ["allowedIPAddresses" ].has ("1.2.3.4" )
96+ assert not admin_endpoint ["allowedIPAddresses" ].has ("192.168.0.1" )
9797
9898
9999# Sample data for testing
@@ -118,7 +118,7 @@ def service_config():
118118def test_initialization (service_config ):
119119 assert len (service_config .endpoints ) == 2 # Only non-graphql endpoints
120120 assert service_config .last_updated_at == "2023-10-01T00:00:00Z"
121- assert isinstance (service_config .bypassed_ips , IPList )
121+ assert isinstance (service_config .bypassed_ips , IPMatcher )
122122 assert service_config .blocked_uids == {"user1" , "user2" }
123123
124124
@@ -194,10 +194,10 @@ def test_service_config_with_empty_allowlist():
194194 assert len (service_config .endpoints ) == 1
195195 assert service_config .endpoints [0 ]["route" ] == "/admin"
196196 assert service_config .last_updated_at == last_updated_at
197- assert isinstance (service_config .bypassed_ips , IPList )
198- assert service_config .bypassed_ips .matches ("127.0.0.1" )
199- assert service_config .bypassed_ips .matches ("123.1.2.2" )
200- assert not service_config .bypassed_ips .matches ("1.1.1.1" )
197+ assert isinstance (service_config .bypassed_ips , IPMatcher )
198+ assert service_config .bypassed_ips .has ("127.0.0.1" )
199+ assert service_config .bypassed_ips .has ("123.1.2.2" )
200+ assert not service_config .bypassed_ips .has ("1.1.1.1" )
201201 assert service_config .blocked_uids == set (["1" , "0" , "5" ])
202202
203203 admin_endpoint = service_config .get_endpoints (
0 commit comments