diff --git a/server/src/ssh.rs b/server/src/ssh.rs index dc971a9..7551475 100644 --- a/server/src/ssh.rs +++ b/server/src/ssh.rs @@ -129,6 +129,19 @@ mod tests { .collect() } + /// A host with nothing configured but a name to dial, so `~/.ssh/config` + /// decides everything else -- the case that proves this adds no flags of + /// its own when it was not told to. + fn bare_host() -> HostConfig { + HostConfig { + name: "vm".to_string(), + address: "vm".to_string(), + port: None, + identity_file: None, + options: vec![], + } + } + #[test] fn a_session_with_no_host_runs_the_command_directly() { let command = command( @@ -177,13 +190,7 @@ mod tests { #[test] fn a_remote_command_without_a_cwd_just_execs() { - let ssh = HostConfig { - name: "vm".to_string(), - address: "vm".to_string(), - port: None, - identity_file: None, - options: vec![], - }; + let ssh = bare_host(); let rendered = argv(&command(Some(&ssh), "claude", &args(["-p"]), None)); assert_eq!(rendered.last().unwrap(), "exec 'claude' '-p'"); // No -i means no IdentitiesOnly: ~/.ssh/config decides instead. @@ -200,13 +207,7 @@ mod tests { // The end-to-end version of the same worry: a working directory // that tries to close the quote and start a new command. - let ssh = HostConfig { - name: "vm".to_string(), - address: "vm".to_string(), - port: None, - identity_file: None, - options: vec![], - }; + let ssh = bare_host(); let evil = Path::new("/tmp/'; touch /tmp/pwned; '"); let rendered = argv(&command(Some(&ssh), "claude", &[], Some(evil))); let script = rendered.last().unwrap();