33
44#![ cfg( feature = "e2e-podman" ) ]
55
6- //! Podman-specific E2E coverage for immutable-image launch and the isolated
7- //! workload/supervisor container pair.
6+ //! Podman-specific E2E coverage for the supervisor companion container.
87//!
9- //! The test builds an image through the selected Podman engine, creates a
10- //! sandbox from its mutable tag, and inspects the real Podman containers: the
11- //! image ID recorded on the workload, each container's user, the supervisor's
12- //! capabilities, networking, and mounts. This exercises the Podman API
13- //! inspect → protected metadata → create path rather than only its unit
14- //! serialization boundaries. The sandbox identity, privileges, and workspace
15- //! seen by the main process and `sandbox exec` are shared with Docker and
16- //! covered by the `oci-image` feature suite in `tests/suites/features`.
8+ //! Podman runs the supervisor as the resolved OCI workload identity with no
9+ //! effective capabilities; Docker runs it as a fixed unprivileged user. The
10+ //! test builds an image through the selected Podman engine, creates a sandbox
11+ //! from it, and inspects the real supervisor container. The workload's image
12+ //! ID, identity, network, and mounts, and what the main process and
13+ //! `sandbox exec` see, are shared with Docker and covered by the `oci-image`
14+ //! feature suite in `tests/suites/features`.
1715
1816use std:: process:: Stdio ;
1917
@@ -39,7 +37,6 @@ network_policies: {}
3937struct ImageGuard {
4038 engine : ContainerEngine ,
4139 tag : String ,
42- id : String ,
4340}
4441
4542impl ImageGuard {
@@ -90,7 +87,6 @@ USER {OCI_UID}:{OCI_GID}
9087 . ok_or_else ( || "build context path is not UTF-8" . to_string ( ) ) ?,
9188 ] ,
9289 ) ?;
93- let id = run_engine ( & engine, & [ "image" , "inspect" , "--format" , "{{.Id}}" , & tag] ) ?;
9490 let user = run_engine (
9591 & engine,
9692 & [ "image" , "inspect" , "--format" , "{{.Config.User}}" , & tag] ,
@@ -101,7 +97,7 @@ USER {OCI_UID}:{OCI_GID}
10197 ) ) ;
10298 }
10399
104- Ok ( Self { engine, tag, id } )
100+ Ok ( Self { engine, tag } )
105101 }
106102}
107103
@@ -138,10 +134,6 @@ fn run_engine(engine: &ContainerEngine, args: &[&str]) -> Result<String, String>
138134 Ok ( stdout. trim ( ) . to_string ( ) )
139135}
140136
141- fn sandbox_container_id ( engine : & ContainerEngine , sandbox_name : & str ) -> Result < String , String > {
142- container_id_for_role ( engine, sandbox_name, "sandbox" )
143- }
144-
145137fn container_id_for_role (
146138 engine : & ContainerEngine ,
147139 sandbox_name : & str ,
@@ -178,15 +170,8 @@ fn container_id_for_role(
178170 }
179171}
180172
181- fn normalized_image_id ( image_id : & str ) -> & str {
182- image_id
183- . trim ( )
184- . strip_prefix ( "sha256:" )
185- . unwrap_or ( image_id. trim ( ) )
186- }
187-
188173#[ tokio:: test]
189- async fn podman_uses_oci_identity_and_inspected_image_id ( ) {
174+ async fn podman_supervisor_runs_as_oci_identity_without_capabilities ( ) {
190175 if !is_e2e_driver ( "podman" ) {
191176 eprintln ! ( "Skipping Podman OCI identity test: e2e driver is not podman" ) ;
192177 return ;
@@ -207,43 +192,8 @@ async fn podman_uses_oci_identity_and_inspected_image_id() {
207192 . await
208193 . expect ( "create sandbox from Podman-built OCI identity image" ) ;
209194
210- let container_id =
211- sandbox_container_id ( & image. engine , & sandbox. name ) . expect ( "find Podman sandbox container" ) ;
212- let launched_image_id = run_engine (
213- & image. engine ,
214- & [
215- "container" ,
216- "inspect" ,
217- "--format" ,
218- "{{.Image}}" ,
219- & container_id,
220- ] ,
221- )
222- . expect ( "inspect Podman sandbox container image" ) ;
223- assert_eq ! (
224- normalized_image_id( & launched_image_id) ,
225- normalized_image_id( & image. id) ,
226- "Podman sandbox must launch the immutable image ID inspected before creation"
227- ) ;
228-
229- assert_isolated_pair ( & image, & sandbox, & container_id) ;
230- sandbox. cleanup ( ) . await ;
231- }
232-
233- fn assert_isolated_pair ( image : & ImageGuard , sandbox : & SandboxGuard , container_id : & str ) {
234195 let supervisor_id = container_id_for_role ( & image. engine , & sandbox. name , "supervisor" )
235196 . expect ( "find separate supervisor companion" ) ;
236- assert_ne ! ( supervisor_id, container_id) ;
237- let workload_user = run_engine (
238- & image. engine ,
239- & [ "inspect" , "--format" , "{{.Config.User}}" , container_id] ,
240- )
241- . unwrap ( ) ;
242- assert_eq ! (
243- workload_user,
244- format!( "{OCI_UID}:{OCI_GID}" ) ,
245- "a custom OCI workspace must start directly as the final identity"
246- ) ;
247197 let supervisor_user = run_engine (
248198 & image. engine ,
249199 & [ "inspect" , "--format" , "{{.Config.User}}" , & supervisor_id] ,
@@ -259,27 +209,5 @@ fn assert_isolated_pair(image: &ImageGuard, sandbox: &SandboxGuard, container_id
259209 supervisor_caps, "[]" ,
260210 "the supervisor companion may not have effective capabilities"
261211 ) ;
262- let network = run_engine (
263- & image. engine ,
264- & [
265- "inspect" ,
266- "--format" ,
267- "{{.HostConfig.NetworkMode}}" ,
268- container_id,
269- ] ,
270- )
271- . unwrap ( ) ;
272- assert_eq ! ( network, "none" ) ;
273- let mounts = run_engine (
274- & image. engine ,
275- & [
276- "inspect" ,
277- "--format" ,
278- "{{range .Mounts}}{{println .Destination}}{{end}}" ,
279- container_id,
280- ] ,
281- )
282- . unwrap ( ) ;
283- assert ! ( !mounts. contains( "/etc/openshell/tls" ) ) ;
284- assert ! ( !mounts. contains( "/.openshell/supervisor" ) ) ;
212+ sandbox. cleanup ( ) . await ;
285213}
0 commit comments