@@ -13,7 +13,7 @@ use std::time::{Duration, Instant};
1313
1414use serde_json:: Value ;
1515use testkit:: sdk:: raw:: proto;
16- use testkit:: { Context , Error , Sandbox } ;
16+ use testkit:: { Context , Error , ResultExt as _ , Sandbox } ;
1717
1818const READY_TIMEOUT : Duration = Duration :: from_mins ( 4 ) ;
1919const PROPOSAL_TIMEOUT : Duration = Duration :: from_secs ( 90 ) ;
@@ -161,12 +161,13 @@ async fn denied_address_produces_draft_rule(cx: &mut Context) -> testkit::Result
161161 "printf 'BINARY=%s\\ n' \" $(readlink -f /proc/$$/exe)\" ; \
162162 if exec 3<>/dev/tcp/1.1.1.1/443; then echo UNEXPECTED_ALLOWED; exit 1; else echo DENIED; fi",
163163 ] )
164- . await ?;
164+ . await ?
165+ . success ( )
166+ . context ( "the connection to 1.1.1.1:443 must be denied" ) ?;
165167 testkit:: ensure!(
166- probe. exit_code == 0 && probe. stdout. lines( ) . any( |line| line == "DENIED" ) ,
167- "the connection to 1.1.1.1:443 was not denied: stdout {:?}, stderr {:?}" ,
168- probe. stdout,
169- probe. stderr
168+ probe. stdout. lines( ) . any( |line| line == "DENIED" ) ,
169+ "the connection to 1.1.1.1:443 was not denied: stdout {:?}" ,
170+ probe. stdout
170171 ) ;
171172 let binary = probe
172173 . stdout
@@ -199,12 +200,13 @@ async fn denied_hostname_produces_draft_rule(cx: &mut Context) -> testkit::Resul
199200 "-c" ,
200201 "if exec 3<>/dev/tcp/pypi.org/80; then echo UNEXPECTED_ALLOWED; exit 1; else echo DENIED; fi" ,
201202 ] )
202- . await ?;
203+ . await ?
204+ . success ( )
205+ . context ( "the connection to pypi.org:80 must be denied" ) ?;
203206 testkit:: ensure!(
204- probe. exit_code == 0 && probe. stdout. lines( ) . any( |line| line == "DENIED" ) ,
205- "the connection to pypi.org:80 was not denied: stdout {:?}, stderr {:?}" ,
206- probe. stdout,
207- probe. stderr
207+ probe. stdout. lines( ) . any( |line| line == "DENIED" ) ,
208+ "the connection to pypi.org:80 was not denied: stdout {:?}" ,
209+ probe. stdout
208210 ) ;
209211
210212 expect_draft (
@@ -289,13 +291,13 @@ async fn bash_path(sandbox: &Sandbox) -> testkit::Result<String> {
289291 "-c" ,
290292 "printf '%s\\ n' \" $(readlink -f /proc/$$/exe)\" " ,
291293 ] )
292- . await ?;
294+ . await ?
295+ . success ( ) ?;
293296 let path = output. stdout . trim ( ) ;
294297 testkit:: ensure!(
295- output. exit_code == 0 && is_bash_path( path) ,
296- "expected one absolute Bash path; got {:?}, stderr {:?}" ,
297- output. stdout,
298- output. stderr
298+ is_bash_path( path) ,
299+ "expected one absolute Bash path; got {:?}" ,
300+ output. stdout
299301 ) ;
300302 Ok ( path. to_string ( ) )
301303}
@@ -326,13 +328,9 @@ async fn policy_local(
326328 path,
327329 body,
328330 ] )
329- . await ?;
330- testkit:: ensure!(
331- output. exit_code == 0 ,
332- "{method} http://policy.local{path} exited {}; stderr: {}" ,
333- output. exit_code,
334- output. stderr
335- ) ;
331+ . await ?
332+ . success ( )
333+ . context ( format ! ( "{method} http://policy.local{path}" ) ) ?;
336334 let ( headers, json) = output. stdout . split_once ( "\r \n \r \n " ) . ok_or_else ( || {
337335 Error :: msg ( format ! (
338336 "{method} http://policy.local{path} returned no complete HTTP response: {:?}" ,
0 commit comments