@@ -2038,81 +2038,92 @@ async fn detached_ephemeral_command_delegates_cleanup_to_gateway() {
20382038#[ tokio:: test]
20392039async fn sandbox_create_sends_annotations ( ) {
20402040 let server = run_server ( ) . await ;
2041- let fake_ssh_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
2042- let xdg_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
2043- let _env = test_env ( & fake_ssh_dir, & xdg_dir) ;
2044- let tls = test_tls ( & server) ;
2045- install_fake_ssh ( & fake_ssh_dir) ;
2041+ let fake_ssh_dir = helpers:: tempdir ( ) . unwrap ( ) ;
2042+ let xdg_dir = helpers:: tempdir ( ) . unwrap ( ) ;
20462043
2047- let source = "/home/you/my policy.yaml=1" . to_string ( ) ;
2048- run:: sandbox_create (
2049- & server. endpoint ,
2050- "openshell" ,
2051- run:: SandboxCreateConfig {
2052- name : Some ( "annotated" ) ,
2053- keep : true ,
2054- command : & [ "echo" . into ( ) , "OK" . into ( ) ] ,
2055- annotations : HashMap :: from ( [ ( "policy-source-file" . to_string ( ) , source. clone ( ) ) ] ) ,
2056- ..test_config ( )
2057- } ,
2058- "default" ,
2059- & tls,
2060- )
2061- . await
2062- . expect ( "sandbox create should succeed" ) ;
2044+ test_env ( & fake_ssh_dir, & xdg_dir)
2045+ . run_async ( async {
2046+ let tls = test_tls ( & server) ;
2047+ install_fake_ssh ( & fake_ssh_dir) ;
20632048
2064- let requests = create_requests ( & server) . await ;
2065- assert_eq ! (
2066- requests[ 0 ]
2067- . annotations
2068- . get( "policy-source-file" )
2069- . map( String :: as_str) ,
2070- Some ( source. as_str( ) )
2071- ) ;
2072- assert ! (
2073- !requests[ 0 ]
2074- . annotations
2075- . contains_key( "openshell.nvidia.com/retention" ) ,
2076- "a kept sandbox must not be marked ephemeral"
2077- ) ;
2049+ let source = "/home/you/my policy.yaml=1" . to_string ( ) ;
2050+ run:: sandbox_create (
2051+ & server. endpoint ,
2052+ "openshell" ,
2053+ run:: SandboxCreateConfig {
2054+ name : Some ( "annotated" ) ,
2055+ keep : true ,
2056+ command : & [ "echo" . into ( ) , "OK" . into ( ) ] ,
2057+ annotations : HashMap :: from ( [ (
2058+ "policy-source-file" . to_string ( ) ,
2059+ source. clone ( ) ,
2060+ ) ] ) ,
2061+ ..test_config ( )
2062+ } ,
2063+ "default" ,
2064+ & tls,
2065+ )
2066+ . await
2067+ . expect ( "sandbox create should succeed" ) ;
2068+
2069+ let requests = create_requests ( & server) . await ;
2070+ assert_eq ! (
2071+ requests[ 0 ]
2072+ . annotations
2073+ . get( "policy-source-file" )
2074+ . map( String :: as_str) ,
2075+ Some ( source. as_str( ) )
2076+ ) ;
2077+ assert ! (
2078+ !requests[ 0 ]
2079+ . annotations
2080+ . contains_key( "openshell.nvidia.com/retention" ) ,
2081+ "a kept sandbox must not be marked ephemeral"
2082+ ) ;
2083+ } )
2084+ . await ;
20782085}
20792086
20802087#[ tokio:: test]
20812088async fn ephemeral_sandbox_create_keeps_annotations_and_retention ( ) {
20822089 let server = run_server ( ) . await ;
2083- let fake_ssh_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
2084- let xdg_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
2085- let _env = test_env ( & fake_ssh_dir, & xdg_dir) ;
2086- let tls = test_tls ( & server) ;
2087- install_fake_ssh ( & fake_ssh_dir) ;
2090+ let fake_ssh_dir = helpers:: tempdir ( ) . unwrap ( ) ;
2091+ let xdg_dir = helpers:: tempdir ( ) . unwrap ( ) ;
20882092
2089- run:: sandbox_create (
2090- & server. endpoint ,
2091- "openshell" ,
2092- run:: SandboxCreateConfig {
2093- name : Some ( "annotated-ephemeral" ) ,
2094- keep : false ,
2095- command : & [ "echo" . into ( ) , "OK" . into ( ) ] ,
2096- annotations : HashMap :: from ( [ ( "owner" . to_string ( ) , "platform" . to_string ( ) ) ] ) ,
2097- ..test_config ( )
2098- } ,
2099- "default" ,
2100- & tls,
2101- )
2102- . await
2103- . expect ( "sandbox create should succeed" ) ;
2093+ test_env ( & fake_ssh_dir, & xdg_dir)
2094+ . run_async ( async {
2095+ let tls = test_tls ( & server) ;
2096+ install_fake_ssh ( & fake_ssh_dir) ;
21042097
2105- let annotations = & create_requests ( & server) . await [ 0 ] . annotations ;
2106- assert_eq ! (
2107- annotations. get( "owner" ) . map( String :: as_str) ,
2108- Some ( "platform" )
2109- ) ;
2110- assert_eq ! (
2111- annotations
2112- . get( "openshell.nvidia.com/retention" )
2113- . map( String :: as_str) ,
2114- Some ( "ephemeral" )
2115- ) ;
2098+ run:: sandbox_create (
2099+ & server. endpoint ,
2100+ "openshell" ,
2101+ run:: SandboxCreateConfig {
2102+ name : Some ( "annotated-ephemeral" ) ,
2103+ keep : false ,
2104+ command : & [ "echo" . into ( ) , "OK" . into ( ) ] ,
2105+ annotations : HashMap :: from ( [ ( "owner" . to_string ( ) , "platform" . to_string ( ) ) ] ) ,
2106+ ..test_config ( )
2107+ } ,
2108+ "default" ,
2109+ & tls,
2110+ )
2111+ . await
2112+ . expect ( "sandbox create should succeed" ) ;
2113+
2114+ let annotations = & create_requests ( & server) . await [ 0 ] . annotations ;
2115+ assert_eq ! (
2116+ annotations. get( "owner" ) . map( String :: as_str) ,
2117+ Some ( "platform" )
2118+ ) ;
2119+ assert_eq ! (
2120+ annotations
2121+ . get( "openshell.nvidia.com/retention" )
2122+ . map( String :: as_str) ,
2123+ Some ( "ephemeral" )
2124+ ) ;
2125+ } )
2126+ . await ;
21162127}
21172128
21182129#[ tokio:: test]
0 commit comments