Skip to content

Commit f61ef2a

Browse files
committed
Add a test for overssh that requires escaping the argument passed to the command.
Signed-off-by: Aalekh Patel <[email protected]>
1 parent ff93c96 commit f61ef2a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/openssh.rs

+26
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,32 @@ async fn over_session_ok() {
317317
}
318318
}
319319

320+
321+
#[tokio::test]
322+
#[cfg_attr(not(ci), ignore)]
323+
async fn over_session_ok_require_escaping_arguments() {
324+
for session in connects().await {
325+
let mut command = std::process::Command::new("echo")
326+
.arg("\"\'\'foo\'\'\"")
327+
.over_ssh(&session).expect("No env vars or current working dir is set.");
328+
329+
let child = command.output().await.unwrap();
330+
assert_eq!(child.stdout, b"\"\'\'foo\'\'\"\n");
331+
332+
let child = session
333+
.command("echo")
334+
.arg("foo")
335+
.raw_arg(">")
336+
.arg("/dev/stderr")
337+
.output()
338+
.await
339+
.unwrap();
340+
assert!(child.stdout.is_empty());
341+
342+
session.close().await.unwrap();
343+
}
344+
}
345+
320346
/// Test that `over_ssh` errors if the source command has env vars specified.
321347
#[tokio::test]
322348
#[cfg_attr(not(ci), ignore)]

0 commit comments

Comments
 (0)