From 9e11e860e59536903f7f653c215f07cbdfea2551 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Fri, 28 Aug 2026 03:21:58 -0400 Subject: [PATCH] Give the ssh tests one bare host instead of two copies Two tests built the same HostConfig inline -- a name, an address, and nothing else configured. It is now `bare_host()`, named for what it is about: the case that proves this adds no flags of its own when it was not told to. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw --- server/src/ssh.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) 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();