diff options
Diffstat (limited to 'tests/client_ui.rs')
| -rw-r--r-- | tests/client_ui.rs | 42 |
1 files changed, 42 insertions, 0 deletions
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() { | |||
| 226 | ); | 226 | ); |
| 227 | } | 227 | } |
| 228 | } | 228 | } |
| 229 | |||
| 230 | #[test] | ||
| 231 | fn hosts_sharing_a_fingerprint_are_shown_as_one_server() { | ||
| 232 | let key = "5a15c712230831cb7270a36f5841bc5a52325db683073c845654a956d074f8ef"; | ||
| 233 | let lines = host_lines(&[ | ||
| 234 | ("10.0.0.100:11525".to_string(), Some(key.to_string())), | ||
| 235 | ("127.0.0.1:11525".to_string(), Some(key.to_string())), | ||
| 236 | ( | ||
| 237 | "other.example:11525".to_string(), | ||
| 238 | Some("ff".repeat(32)), | ||
| 239 | ), | ||
| 240 | ]); | ||
| 241 | |||
| 242 | assert_eq!( | ||
| 243 | lines, | ||
| 244 | vec![ | ||
| 245 | "Remembered hosts:", | ||
| 246 | " 10.0.0.100:11525, 127.0.0.1:11525", | ||
| 247 | &format!(" fingerprint: {key}"), | ||
| 248 | " other.example:11525", | ||
| 249 | &format!(" fingerprint: {}", "ff".repeat(32)), | ||
| 250 | ] | ||
| 251 | ); | ||
| 252 | |||
| 253 | // The shared key is printed once, not once per address. | ||
| 254 | assert_eq!(lines.iter().filter(|line| line.contains(key)).count(), 1); | ||
| 255 | } | ||
| 256 | |||
| 257 | #[test] | ||
| 258 | fn hosts_without_a_fingerprint_are_never_merged() { | ||
| 259 | let lines = host_lines(&[ | ||
| 260 | ("a.example:443".to_string(), None), | ||
| 261 | ("b.example:443".to_string(), None), | ||
| 262 | ]); | ||
| 263 | |||
| 264 | assert!(lines.contains(&" a.example:443".to_string())); | ||
| 265 | assert!(lines.contains(&" b.example:443".to_string())); | ||
| 266 | assert_eq!( | ||
| 267 | lines.iter().filter(|line| line.contains("no fingerprint")).count(), | ||
| 268 | 2 | ||
| 269 | ); | ||
| 270 | } | ||
