Skip to content

Commit 524739b

Browse files
committed
Try, so far unsuccessfully, to add missing -G test
This is to test a code path where a host is passed to an ssh command and it's important to ensure it doesn't start with `-`. This code path uses `-G` to help figure out what SSH client is being used, and most of the time it is not followed. The existing check is sufficiently simple it is most likely correct. But it seems never to to have been covered in automated tests: neither unit tests nor any journey tests. This does not yet manage to test is successfully, because it does not succeed at getting that specific code path to be followed.
1 parent 2911623 commit 524739b

File tree

1 file changed

+16
-2
lines changed
  • gix-transport/src/client/blocking_io

1 file changed

+16
-2
lines changed

gix-transport/src/client/blocking_io/file.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn connect(
291291
mod tests {
292292
mod ssh {
293293
mod connect {
294-
use crate::{client::blocking_io::ssh::connect, Protocol};
294+
use crate::{client::blocking_io::ssh, Protocol};
295295

296296
#[test]
297297
fn path() {
@@ -304,10 +304,24 @@ mod tests {
304304
("[email protected]:~/repo", "~/repo"),
305305
] {
306306
let url = gix_url::parse((*url).into()).expect("valid url");
307-
let cmd = connect(url, Protocol::V1, Default::default(), false).expect("parse success");
307+
let cmd = ssh::connect(url, Protocol::V1, Default::default(), false).expect("parse success");
308308
assert_eq!(cmd.path, expected, "the path will be substituted by the remote shell");
309309
}
310310
}
311+
312+
#[test]
313+
fn ambiguous_host_disallowed() {
314+
for url in [
315+
"ssh://-oProxyCommand=open$IFS-aCalculator/foo",
316+
"user@-oProxyCommand=open$IFS-aCalculator:username/repo",
317+
] {
318+
let url = gix_url::parse((*url).into()).expect("valid url");
319+
assert!(matches!(
320+
ssh::connect(url, Protocol::V1, Default::default(), false),
321+
Err(ssh::Error::AmbiguousHostName { host }) if host == "-oProxyCommand=open$IFS-aCalculator",
322+
));
323+
}
324+
}
311325
}
312326
}
313327
}

0 commit comments

Comments
 (0)