diff options
author | Wez Furlong <wez@wezfurlong.org> | 2019-07-23 17:12:18 -0700 |
---|---|---|
committer | Wez Furlong <wez@wezfurlong.org> | 2019-07-29 08:55:06 -0700 |
commit | 1bbdfca88957747a9ad2d6010c84abe4189b2439 (patch) | |
tree | 7e09eae032a5cf49a5f57d6bfcff1f0be5223f08 /tests | |
parent | 19c95e8c79723e22a35de302cb8f768f9d133dbc (diff) | |
download | ssh2-rs-1bbdfca88957747a9ad2d6010c84abe4189b2439.zip |
Session::handshake now takes ownership of TcpStream
Refs: https://github.com/alexcrichton/ssh2-rs/issues/17
Diffstat (limited to 'tests')
-rw-r--r-- | tests/all/channel.rs | 24 | ||||
-rw-r--r-- | tests/all/main.rs | 6 | ||||
-rw-r--r-- | tests/all/session.rs | 8 | ||||
-rw-r--r-- | tests/all/sftp.rs | 4 |
4 files changed, 21 insertions, 21 deletions
diff --git a/tests/all/channel.rs b/tests/all/channel.rs index 294eecf..2a9dfdf 100644 --- a/tests/all/channel.rs +++ b/tests/all/channel.rs @@ -4,7 +4,7 @@ use std::thread; #[test] fn smoke() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.flush().unwrap(); channel.exec("true").unwrap(); @@ -18,7 +18,7 @@ fn smoke() { #[test] fn bad_smoke() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.flush().unwrap(); channel.exec("false").unwrap(); @@ -32,7 +32,7 @@ fn bad_smoke() { #[test] fn reading_data() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.exec("echo foo").unwrap(); let mut output = String::new(); @@ -42,7 +42,7 @@ fn reading_data() { #[test] fn writing_data() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.exec("read foo && echo $foo").unwrap(); channel.write_all(b"foo\n").unwrap(); @@ -53,7 +53,7 @@ fn writing_data() { #[test] fn eof() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.adjust_receive_window(10, false).unwrap(); channel.exec("read foo").unwrap(); @@ -65,7 +65,7 @@ fn eof() { #[test] fn shell() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.request_pty("xterm", None, None).unwrap(); channel.shell().unwrap(); @@ -74,7 +74,7 @@ fn shell() { #[test] fn setenv() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); let _ = channel.setenv("FOO", "BAR"); channel.close().unwrap(); @@ -91,7 +91,7 @@ fn direct() { assert_eq!(b, [1, 2, 3]); s.write_all(&[4, 5, 6]).unwrap(); }); - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess .channel_direct_tcpip("127.0.0.1", addr.port(), None) .unwrap(); @@ -104,7 +104,7 @@ fn direct() { #[test] fn forward() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let (mut listen, port) = sess.channel_forward_listen(39249, None, None).unwrap(); let t = thread::spawn(move || { let mut s = TcpStream::connect(&("127.0.0.1", port)).unwrap(); @@ -127,7 +127,7 @@ fn drop_nonblocking() { let listener = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap(); - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); sess.set_blocking(false); thread::spawn(move || { @@ -140,7 +140,7 @@ fn drop_nonblocking() { #[test] fn nonblocking_before_exit_code() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.send_eof().unwrap(); let mut output = String::new(); @@ -165,7 +165,7 @@ fn nonblocking_before_exit_code() { #[test] fn exit_code_ignores_other_errors() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut channel = sess.channel_session().unwrap(); channel.exec("true").unwrap(); channel.wait_eof().unwrap(); diff --git a/tests/all/main.rs b/tests/all/main.rs index 7f150bc..6f4335d 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -16,11 +16,11 @@ pub fn socket() -> TcpStream { TcpStream::connect("127.0.0.1:22").unwrap() } -pub fn authed_session() -> (TcpStream, ssh2::Session) { +pub fn authed_session() -> ssh2::Session { let user = env::var("USER").unwrap(); let socket = socket(); let mut sess = ssh2::Session::new().unwrap(); - sess.handshake(&socket).unwrap(); + sess.handshake(socket).unwrap(); assert!(!sess.authenticated()); { @@ -31,5 +31,5 @@ pub fn authed_session() -> (TcpStream, ssh2::Session) { agent.userauth(&user, &identity).unwrap(); } assert!(sess.authenticated()); - (socket, sess) + sess } diff --git a/tests/all/session.rs b/tests/all/session.rs index 42f1dd5..77fb824 100644 --- a/tests/all/session.rs +++ b/tests/all/session.rs @@ -30,7 +30,7 @@ fn smoke_handshake() { let user = env::var("USER").unwrap(); let socket = ::socket(); let mut sess = Session::new().unwrap(); - sess.handshake(&socket).unwrap(); + sess.handshake(socket).unwrap(); sess.host_key().unwrap(); let methods = sess.auth_methods(&user).unwrap(); assert!(methods.contains("publickey"), "{}", methods); @@ -49,14 +49,14 @@ fn smoke_handshake() { #[test] fn keepalive() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); sess.set_keepalive(false, 10); sess.keepalive_send().unwrap(); } #[test] fn scp_recv() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let (mut ch, _) = sess.scp_recv(Path::new(".ssh/authorized_keys")).unwrap(); let mut data = String::new(); ch.read_to_string(&mut data).unwrap(); @@ -72,7 +72,7 @@ fn scp_recv() { #[test] fn scp_send() { let td = TempDir::new("test").unwrap(); - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let mut ch = sess .scp_send(&td.path().join("foo"), 0o644, 6, None) .unwrap(); diff --git a/tests/all/sftp.rs b/tests/all/sftp.rs index 415bcae..ad9eed5 100644 --- a/tests/all/sftp.rs +++ b/tests/all/sftp.rs @@ -4,7 +4,7 @@ use tempdir::TempDir; #[test] fn smoke() { - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); sess.sftp().unwrap(); } @@ -14,7 +14,7 @@ fn ops() { File::create(&td.path().join("foo")).unwrap(); fs::create_dir(&td.path().join("bar")).unwrap(); - let (_tcp, sess) = ::authed_session(); + let sess = ::authed_session(); let sftp = sess.sftp().unwrap(); sftp.opendir(&td.path().join("bar")).unwrap(); let mut foo = sftp.open(&td.path().join("foo")).unwrap(); |