Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

test(egress): stream held H2 fixture headers

leo pein4dd430e89480
diff --git a/components/egress/tests/test_credential_bound_h2_runtime.py b/components/egress/tests/test_credential_bound_h2_runtime.py
index 6bec1a9eb..d67fd4b46 100644
--- a/components/egress/tests/test_credential_bound_h2_runtime.py
+++ b/components/egress/tests/test_credential_bound_h2_runtime.py
@@ -357,7 +357,11 @@ class OriginServer(socketserver.ThreadingTCPServer):
def response(self, path, token):
body = BODY if path in ("/v1/old", "/v1/old-two") else SMALL_BODY
- return body, [("content-type", "application/octet-stream"),
+ held_h2_old = (self.protocol == "h2"
+ and self.scenario in ("go_retry", "go_retry_early_notice")
+ and path == "/v1/old")
+ content_type = "text/event-stream" if held_h2_old else "application/octet-stream"
+ return body, [("content-type", content_type),
("content-length", str(len(body))), ("x-credential-echo", token)]
def finish(self):
diff --git a/components/egress/tests/test_credential_bound_h2_runtime_selection.py b/components/egress/tests/test_credential_bound_h2_runtime_selection.py
index 5bb58fbc9..6007dde05 100644
--- a/components/egress/tests/test_credential_bound_h2_runtime_selection.py
+++ b/components/egress/tests/test_credential_bound_h2_runtime_selection.py
@@ -177,6 +177,26 @@ class _BarrierScheduleHarness:
class RuntimeSelectionTests(unittest.TestCase):
+ def test_only_held_h2_old_response_uses_existing_streaming_mime(self):
+ cases = (
+ ("h2", "go_retry_early_notice", "/v1/old", "text/event-stream"),
+ ("h2", "go_retry", "/v1/old", "text/event-stream"),
+ ("h2", "normal", "/v1/old", "application/octet-stream"),
+ ("h2", "go_retry_early_notice", "/v1/new", "application/octet-stream"),
+ ("h1", "go_retry_early_notice", "/v1/old", "application/octet-stream"),
+ )
+ for protocol, scenario, path, expected_type in cases:
+ with self.subTest(protocol=protocol, scenario=scenario, path=path):
+ origin = SimpleNamespace(protocol=protocol, scenario=scenario)
+ body, fields = runner.OriginServer.response(origin, path, "one")
+ headers = dict(fields)
+ expected_body = (runner.BODY if path == "/v1/old"
+ else runner.SMALL_BODY)
+ self.assertEqual(body, expected_body)
+ self.assertEqual(headers["content-type"], expected_type)
+ self.assertEqual(headers["content-length"], str(len(expected_body)))
+ self.assertNotIn("transfer-encoding", headers)
+
def test_pre_admission_barrier_requires_enter_ack_release_result_order(self):
self.assertTrue(
runner.pre_admission_order_is_valid(10, 20, 30, 30, 1, 2, 3)