From bb3f2a4663580ae005ba0bcd28ea0b2cf9b011a1 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 8 Oct 2026 17:55:28 +0800 Subject: [PATCH] test(settings): the SSH editor's credential rows follow the auth method --- src/ui/settings.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/ui/settings.rs b/src/ui/settings.rs index 0465beec..d5b1dada 100644 --- a/src/ui/settings.rs +++ b/src/ui/settings.rs @@ -3942,6 +3942,39 @@ mod gpui_tests { }); } + /// The credential rows follow the auth method the same way connecting + /// does: a password only for methods that offer one, a passphrase never + /// for a method that does not try keys. (Whether Auto / PublicKey show the + /// passphrase depends on the default keys in this machine's `~/.ssh`, so + /// that half is not pinned here.) + #[gpui::test] + fn the_credential_rows_follow_the_auth_method(cx: &mut TestAppContext) { + use crate::core::ssh_profile::{AuthMode, SshProfile}; + crate::core::config::pin_test_config_dir(); + let (app, mut vcx) = harness(cx); + for (auth, password, keys) in [ + (AuthMode::Auto, true, true), + (AuthMode::Password, true, false), + (AuthMode::PublicKey, false, true), + (AuthMode::Agent, false, false), + ] { + let mut profile = SshProfile::new("creds"); + profile.auth = auth; + let id = profile.id; + app.update_in(&mut vcx, |app, window, cx| { + cx.global_mut::().ssh_profiles.push(profile); + app.open_ssh_profile_in_settings(id, window, cx); + let form = app.active_settings().unwrap().ssh_form.as_ref().unwrap(); + assert_eq!(form.wants_password(), password, "{auth:?}"); + if !keys { + assert!(!form.wants_passphrase(), "{auth:?} never tries a key"); + } + app.cancel_ssh_form(cx); + }); + vcx.run_until_parked(); + } + } + #[gpui::test] fn failed_settings_writes_remain_visible_until_retry_succeeds(cx: &mut TestAppContext) { crate::core::config::pin_test_config_dir();