44classifier assigns `TCPLayer`. This test starts the pinned proxy image and a
55local origin, then asserts what a live cell would observe.
66
7- It needs Docker and the pinned image, so it is opt-in:
7+ It needs Docker, the pinned proxy image, and `python:3.12-slim` , so it is opt-in:
88
99 MAKA_EVAL_EGRESS_PROXY_TEST=1 python3 harbor/test_egress_filter_live.py
1010"""
@@ -133,6 +133,15 @@ def docker_available() -> bool:
133133 return probe .returncode == 0
134134
135135
136+ def docker_image_present (image : str ) -> bool :
137+ inspect = subprocess .run (
138+ ["docker" , "image" , "inspect" , image ],
139+ capture_output = True ,
140+ timeout = COMMAND_TIMEOUT_S ,
141+ )
142+ return inspect .returncode == 0
143+
144+
136145@unittest .skipUnless (
137146 os .environ .get ("MAKA_EVAL_EGRESS_PROXY_TEST" ) == "1" ,
138147 "set MAKA_EVAL_EGRESS_PROXY_TEST=1 to run the live mitmproxy proxy test" ,
@@ -148,13 +157,10 @@ class LiveEgressFilterTest(unittest.TestCase):
148157 def setUpClass (cls ) -> None :
149158 if not docker_available ():
150159 raise unittest .SkipTest ("Docker daemon is unavailable" )
151- images = subprocess .run (
152- ["docker" , "image" , "inspect" , PROXY_IMAGE ],
153- capture_output = True ,
154- timeout = COMMAND_TIMEOUT_S ,
155- )
156- if images .returncode != 0 :
160+ if not docker_image_present (PROXY_IMAGE ):
157161 raise unittest .SkipTest (f"{ PROXY_IMAGE } is not present" )
162+ if not docker_image_present (ORIGIN_IMAGE ):
163+ raise unittest .SkipTest (f"{ ORIGIN_IMAGE } is not present" )
158164 run_id = f"{ os .getpid ()} -{ uuid .uuid4 ().hex [:8 ]} "
159165 cls .network = f"maka-eval-egress-live-{ run_id } -net"
160166 cls .proxy = f"maka-eval-egress-live-{ run_id } -proxy"
@@ -322,6 +328,8 @@ def audit_records(cls) -> list[dict[str, object]]:
322328 text = True ,
323329 timeout = COMMAND_TIMEOUT_S ,
324330 )
331+ if listed .returncode != 0 :
332+ raise AssertionError (listed .stderr )
325333 return [json .loads (line ) for line in listed .stdout .splitlines () if line .strip ()]
326334
327335 @classmethod
0 commit comments