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

Function round_trip_preserves_deny_rules

crates/openshell-policy/src/lib.rs:2433–2465  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2431
2432 #[test]
2433 fn round_trip_preserves_deny_rules() {
2434 let yaml = r#"
2435version: 1
2436network_policies:
2437 github:
2438 name: github
2439 endpoints:
2440 - host: api.github.com
2441 port: 443
2442 protocol: rest
2443 access: full
2444 deny_rules:
2445 - method: POST
2446 path: "/repos/*/pulls/*/reviews"
2447 - method: DELETE
2448 path: "/repos/*/branches/*/protection"
2449 query:
2450 force: "true"
2451 binaries:
2452 - path: /usr/bin/curl
2453"#;
2454 let proto1 = parse_sandbox_policy(yaml).expect("parse failed");
2455 let yaml_out = serialize_sandbox_policy(&proto1).expect("serialize failed");
2456 let proto2 = parse_sandbox_policy(&yaml_out).expect("re-parse failed");
2457
2458 let ep1 = &proto1.network_policies["github"].endpoints[0];
2459 let ep2 = &proto2.network_policies["github"].endpoints[0];
2460 assert_eq!(ep1.deny_rules.len(), ep2.deny_rules.len());
2461 assert_eq!(ep2.deny_rules[0].method, "POST");
2462 assert_eq!(ep2.deny_rules[0].path, "/repos/*/pulls/*/reviews");
2463 assert_eq!(ep2.deny_rules[1].method, "DELETE");
2464 assert_eq!(ep2.deny_rules[1].query["force"].glob, "true");
2465 }
2466
2467 #[test]
2468 fn parse_deny_rules_with_query_any() {

Callers

nothing calls this directly

Calls 2

parse_sandbox_policyFunction · 0.85
serialize_sandbox_policyFunction · 0.85

Tested by

no test coverage detected