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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw
This commit is contained in:
1 parent
3c4c728ed5
commit
9e11e860e5
1 file changed
+15
-14
+15
-14
@@ -129,6 +129,19 @@ mod tests {
|
|||||||
.collect()
|
.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]
|
#[test]
|
||||||
fn a_session_with_no_host_runs_the_command_directly() {
|
fn a_session_with_no_host_runs_the_command_directly() {
|
||||||
let command = command(
|
let command = command(
|
||||||
@@ -177,13 +190,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_remote_command_without_a_cwd_just_execs() {
|
fn a_remote_command_without_a_cwd_just_execs() {
|
||||||
let ssh = HostConfig {
|
let ssh = bare_host();
|
||||||
name: "vm".to_string(),
|
|
||||||
address: "vm".to_string(),
|
|
||||||
port: None,
|
|
||||||
identity_file: None,
|
|
||||||
options: vec![],
|
|
||||||
};
|
|
||||||
let rendered = argv(&command(Some(&ssh), "claude", &args(["-p"]), None));
|
let rendered = argv(&command(Some(&ssh), "claude", &args(["-p"]), None));
|
||||||
assert_eq!(rendered.last().unwrap(), "exec 'claude' '-p'");
|
assert_eq!(rendered.last().unwrap(), "exec 'claude' '-p'");
|
||||||
// No -i means no IdentitiesOnly: ~/.ssh/config decides instead.
|
// 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
|
// The end-to-end version of the same worry: a working directory
|
||||||
// that tries to close the quote and start a new command.
|
// that tries to close the quote and start a new command.
|
||||||
let ssh = HostConfig {
|
let ssh = bare_host();
|
||||||
name: "vm".to_string(),
|
|
||||||
address: "vm".to_string(),
|
|
||||||
port: None,
|
|
||||||
identity_file: None,
|
|
||||||
options: vec![],
|
|
||||||
};
|
|
||||||
let evil = Path::new("/tmp/'; touch /tmp/pwned; '");
|
let evil = Path::new("/tmp/'; touch /tmp/pwned; '");
|
||||||
let rendered = argv(&command(Some(&ssh), "claude", &[], Some(evil)));
|
let rendered = argv(&command(Some(&ssh), "claude", &[], Some(evil)));
|
||||||
let script = rendered.last().unwrap();
|
let script = rendered.last().unwrap();
|
||||||
|
|||||||
Reference in new issue
Block a user