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

Function round_trip_preserves_allowed_ips

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

Source from the content-addressed store, hash-verified

1392 /// Verify that `allowed_ips` survives the round-trip.
1393 #[test]
1394 fn round_trip_preserves_allowed_ips() {
1395 let yaml = r#"
1396version: 1
1397network_policies:
1398 internal:
1399 name: internal
1400 endpoints:
1401 - host: db.internal.corp
1402 port: 5432
1403 allowed_ips:
1404 - "10.0.5.0/24"
1405 - "10.0.6.0/24"
1406 binaries:
1407 - path: /usr/bin/curl
1408"#;
1409 let proto1 = parse_sandbox_policy(yaml).expect("parse failed");
1410 let yaml_out = serialize_sandbox_policy(&proto1).expect("serialize failed");
1411 let proto2 = parse_sandbox_policy(&yaml_out).expect("re-parse failed");
1412
1413 let ep1 = &proto1.network_policies["internal"].endpoints[0];
1414 let ep2 = &proto2.network_policies["internal"].endpoints[0];
1415 assert_eq!(ep1.allowed_ips, ep2.allowed_ips);
1416 assert_eq!(ep1.allowed_ips, vec!["10.0.5.0/24", "10.0.6.0/24"]);
1417 }
1418
1419 /// Verify that the network policy `name` field survives the round-trip.
1420 #[test]

Callers

nothing calls this directly

Calls 2

parse_sandbox_policyFunction · 0.85
serialize_sandbox_policyFunction · 0.85

Tested by

no test coverage detected