MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / test_l7_tls_log_fields

Function test_l7_tls_log_fields

e2e/python/test_sandbox_policy.py:1169–1205  ·  view source on GitHub ↗

L7-T7: L7 request logging includes structured fields.

(
    sandbox: Callable[..., Sandbox],
)

Source from the content-addressed store, hash-verified

1167
1168
1169def test_l7_tls_log_fields(
1170 sandbox: Callable[..., Sandbox],
1171) -> None:
1172 """L7-T7: L7 request logging includes structured fields."""
1173 policy = _base_policy(
1174 network_policies={
1175 "anthropic": sandbox_pb2.NetworkPolicyRule(
1176 name="anthropic",
1177 endpoints=[
1178 sandbox_pb2.NetworkEndpoint(
1179 host="api.anthropic.com",
1180 port=443,
1181 protocol="rest",
1182 tls="terminate",
1183 enforcement="enforce",
1184 access="full",
1185 ),
1186 ],
1187 binaries=[sandbox_pb2.NetworkBinary(path="/**")],
1188 ),
1189 },
1190 )
1191 spec = datamodel_pb2.SandboxSpec(policy=policy)
1192 with sandbox(spec=spec, delete_on_exit=True) as sb:
1193 sb.exec_python(
1194 _proxy_connect_then_http(),
1195 args=("api.anthropic.com", 443, "GET", "/v1/models"),
1196 )
1197
1198 log_result = sb.exec_python(_read_openshell_log())
1199 assert log_result.exit_code == 0, log_result.stderr
1200 log = log_result.stdout
1201
1202 # OCSF shorthand: L7 requests show as HTTP:method events
1203 assert "HTTP:" in log, "Expected OCSF HTTP activity event in log"
1204 assert "ALLOWED" in log or "DENIED" in log, "Expected L7 decision in log"
1205 assert "policy:" in log, "Expected policy context in log"
1206
1207
1208def test_l7_query_matchers_enforced(

Callers

nothing calls this directly

Calls 5

_base_policyFunction · 0.85
_proxy_connect_then_httpFunction · 0.85
_read_openshell_logFunction · 0.85
sandboxFunction · 0.70
exec_pythonMethod · 0.45

Tested by

no test coverage detected