Add option to pass through arguments to brwap, use shlex for dry-run
This commit is contained in:
@@ -245,6 +245,20 @@ fn dry_run_prints_and_exits() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dry_run_output_is_copy_pasteable_shell() {
|
||||
let dry = sandbox(&["--dry-run"])
|
||||
.args(["--", "bash", "-c", "echo $HOME"])
|
||||
.output()
|
||||
.expect("agent-sandbox binary failed to execute");
|
||||
|
||||
let dry_cmd = String::from_utf8_lossy(&dry.stdout).trim().to_string();
|
||||
let args = shlex::split(&dry_cmd).expect("dry-run output is not valid shell");
|
||||
assert_eq!(args[0], "bwrap");
|
||||
assert_eq!(args[args.len() - 1], "echo $HOME");
|
||||
assert_eq!(args[args.len() - 2], "-c");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blacklist_overlays_survive_tmp_bind() {
|
||||
fs::write("/tmp/ssh-sandbox-test", "secret").expect("failed to write sentinel");
|
||||
@@ -649,6 +663,20 @@ fn mask_hides_file() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bwrap_arg_setenv_passes_through() {
|
||||
let output = sandbox(&["--bwrap-arg", "--setenv MYVAR hello"])
|
||||
.args(["--", "bash", "-c", "echo $MYVAR"])
|
||||
.output()
|
||||
.expect("agent-sandbox binary failed to execute");
|
||||
|
||||
let stdout = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
assert_eq!(
|
||||
stdout, "hello",
|
||||
"expected --bwrap-arg to pass --setenv through to bwrap, got: {stdout}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mask_nonexistent_path_becomes_tmpfs() {
|
||||
let dir = TempDir::new().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user