@@ -32,6 +32,11 @@ use openshell_e2e::harness::output::{extract_field, strip_ansi};
3232use openshell_e2e:: harness:: sandbox:: SandboxGuard ;
3333use tempfile:: NamedTempFile ;
3434
35+ const SPARSE_POLICY : & str = include_str ! ( concat!(
36+ env!( "CARGO_MANIFEST_DIR" ) ,
37+ "/../../examples/policy-advisor/sandbox-policy.yaml"
38+ ) ) ;
39+
3540// ---------------------------------------------------------------------------
3641// Policy YAML builders
3742// ---------------------------------------------------------------------------
@@ -126,6 +131,15 @@ landlock:
126131 Ok ( file)
127132}
128133
134+ fn write_sparse_policy ( ) -> Result < NamedTempFile , String > {
135+ let mut file = NamedTempFile :: new ( ) . map_err ( |e| format ! ( "create temp policy file: {e}" ) ) ?;
136+ file. write_all ( SPARSE_POLICY . as_bytes ( ) )
137+ . map_err ( |e| format ! ( "write temp policy file: {e}" ) ) ?;
138+ file. flush ( )
139+ . map_err ( |e| format ! ( "flush temp policy file: {e}" ) ) ?;
140+ Ok ( file)
141+ }
142+
129143// ---------------------------------------------------------------------------
130144// CLI helpers
131145// ---------------------------------------------------------------------------
@@ -629,18 +643,18 @@ async fn live_policy_update_from_empty_network_policies() {
629643/// no revision remaining `Pending` once the acknowledgement lands.
630644#[ tokio:: test]
631645async fn initial_sparse_policy_is_acknowledged_as_loaded ( ) {
632- // Repo-relative path to the sparse network-only policy fixture.
633- let sparse_policy = concat ! (
634- env! ( "CARGO_MANIFEST_DIR" ) ,
635- "/../../examples/policy-advisor/sandbox-policy.yaml"
636- ) ;
646+ let sparse_policy = write_sparse_policy ( ) . expect ( "write sparse policy fixture" ) ;
647+ let sparse_policy_path = sparse_policy
648+ . path ( )
649+ . to_str ( )
650+ . expect ( "sparse policy path is not UTF-8" ) ;
637651
638652 let mut guard = SandboxGuard :: create_keep_with_args (
639653 & [
640654 "--name" ,
641655 "e2e-sparse-enrich" ,
642656 "--policy" ,
643- sparse_policy ,
657+ sparse_policy_path ,
644658 "--no-tty" ,
645659 ] ,
646660 & [ "sh" , "-c" , "echo Ready && sleep infinity" ] ,
0 commit comments