From 6ddebec575aa8c9c5a357c673cbd8e8a5cc5769d Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 21:43:24 +0100 Subject: v2.3.2: group hosts by certificate fingerprint --- tests/client_ui.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/client_ui.rs b/tests/client_ui.rs index f5e3c0e..7a1b675 100644 --- a/tests/client_ui.rs +++ b/tests/client_ui.rs @@ -226,3 +226,45 @@ fn host_lines_fit_an_80_column_terminal() { ); } } + +#[test] +fn hosts_sharing_a_fingerprint_are_shown_as_one_server() { + let key = "5a15c712230831cb7270a36f5841bc5a52325db683073c845654a956d074f8ef"; + let lines = host_lines(&[ + ("10.0.0.100:11525".to_string(), Some(key.to_string())), + ("127.0.0.1:11525".to_string(), Some(key.to_string())), + ( + "other.example:11525".to_string(), + Some("ff".repeat(32)), + ), + ]); + + assert_eq!( + lines, + vec![ + "Remembered hosts:", + " 10.0.0.100:11525, 127.0.0.1:11525", + &format!(" fingerprint: {key}"), + " other.example:11525", + &format!(" fingerprint: {}", "ff".repeat(32)), + ] + ); + + // The shared key is printed once, not once per address. + assert_eq!(lines.iter().filter(|line| line.contains(key)).count(), 1); +} + +#[test] +fn hosts_without_a_fingerprint_are_never_merged() { + let lines = host_lines(&[ + ("a.example:443".to_string(), None), + ("b.example:443".to_string(), None), + ]); + + assert!(lines.contains(&" a.example:443".to_string())); + assert!(lines.contains(&" b.example:443".to_string())); + assert_eq!( + lines.iter().filter(|line| line.contains("no fingerprint")).count(), + 2 + ); +} -- cgit v1.2.3