@@ -124,6 +124,10 @@ def executable_candidate_paths = test_executable_candidate_paths
124124 describe "::configuration_commands" do
125125 let ( :sandbox_class ) { Class . new ( klass ) }
126126
127+ around do |example |
128+ with_env ( GITHUB_ACTIONS : nil , ImageOS : nil , RUNNER_ENVIRONMENT : nil ) { example . run }
129+ end
130+
127131 def expect_sandbox_configuration_command ( sandbox_class , assignment , result :)
128132 command = [ "sudo" , "sysctl" , "-w" , assignment ]
129133
@@ -160,6 +164,26 @@ def expect_sandbox_configuration_command(sandbox_class, assignment, result:)
160164 sandbox_class . configure!
161165 end
162166
167+ it "installs Bubblewrap with apt-get on default GitHub Actions Ubuntu runners" do
168+ expect ( sandbox_class ) . to receive ( :bubblewrap_executable )
169+ . twice
170+ . and_return ( nil , Pathname ( "/usr/bin/bwrap" ) )
171+ expect ( sandbox_class ) . to receive ( :ohai ) . with ( "Installing Bubblewrap..." )
172+ expect ( sandbox_class ) . to receive ( :system )
173+ . with ( "sudo" , "apt-get" , "install" , "--yes" , "bubblewrap" )
174+ . and_return ( true )
175+ expect ( sandbox_class ) . not_to receive ( :ensure_sandbox_installed! )
176+ expect ( sandbox_class ) . to receive ( :ohai ) . with ( "Configuring Bubblewrap..." ) . ordered
177+ expect_sandbox_configuration_command ( sandbox_class , "kernel.unprivileged_userns_clone=1" , result : true )
178+ expect_sandbox_configuration_command ( sandbox_class , "user.max_user_namespaces=28633" , result : true )
179+ expect_sandbox_configuration_command ( sandbox_class , "kernel.apparmor_restrict_unprivileged_userns=0" ,
180+ result : false )
181+
182+ with_env ( GITHUB_ACTIONS : "true" , ImageOS : "ubuntu24" , RUNNER_ENVIRONMENT : "github-hosted" ) do
183+ sandbox_class . configure!
184+ end
185+ end
186+
163187 it "installs Bubblewrap and configures Linux sandbox sysctls" do
164188 expect ( sandbox_class ) . to receive ( :bubblewrap_executable )
165189 . twice
0 commit comments