forked from wez/wezterm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire up agent forward for libssh backend (wez#5345)
* Wire up agent forward for libssh backend TSIA. There's a drive-by change in sftpwrap.rs for bumping to new libssh-rs.
- Loading branch information
Showing
10 changed files
with
179 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use crate::sshd::*; | ||
use portable_pty::{MasterPty, PtySize}; | ||
use rstest::*; | ||
use std::io::Read; | ||
use wezterm_ssh::Config; | ||
|
||
#[fixture] | ||
async fn session_with_agent_forward( | ||
#[future] | ||
#[with({ let mut config = Config::new(); config.set_option("forwardagent", "yes"); config })] | ||
session: SessionWithSshd, | ||
) -> SessionWithSshd { | ||
session.await | ||
} | ||
|
||
#[rstest] | ||
#[smol_potat::test] | ||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] | ||
#[cfg_attr(not(feature = "libssh-rs"), ignore)] | ||
async fn ssh_add_should_be_able_to_list_identities_with_agent_forward( | ||
#[future] session_with_agent_forward: SessionWithSshd, | ||
) { | ||
let session: SessionWithSshd = session_with_agent_forward.await; | ||
|
||
let (pty, _child_process) = session | ||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None) | ||
.await | ||
.unwrap(); | ||
let mut reader = pty.try_clone_reader().unwrap(); | ||
let mut output: String = String::new(); | ||
reader.read_to_string(&mut output).unwrap(); | ||
assert_eq!(output, "The agent has no identities.\r\n"); | ||
} | ||
|
||
#[rstest] | ||
#[smol_potat::test] | ||
#[cfg_attr(not(any(target_os = "macos", target_os = "linux")), ignore)] | ||
#[cfg_attr(not(feature = "libssh-rs"), ignore)] | ||
async fn no_agent_forward_should_happen_when_disabled(#[future] session: SessionWithSshd) { | ||
let session: SessionWithSshd = session.await; | ||
|
||
let (pty, _child_process) = session | ||
.request_pty("dumb", PtySize::default(), Some("ssh-add -l"), None) | ||
.await | ||
.unwrap(); | ||
let mut reader = pty.try_clone_reader().unwrap(); | ||
let mut output: String = String::new(); | ||
reader.read_to_string(&mut output).unwrap(); | ||
assert_eq!( | ||
output, | ||
"Could not open a connection to your authentication agent.\r\n" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod agent_forward; | ||
mod sftp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters