diff options
author | Wez Furlong <wez@wezfurlong.org> | 2019-07-23 16:39:28 -0700 |
---|---|---|
committer | Wez Furlong <wez@wezfurlong.org> | 2019-07-29 08:55:06 -0700 |
commit | 18dc0f59e0b29c50da525dbe85d36fb5cb0ecf62 (patch) | |
tree | 5f424e77c3bc053a39aea417fea6fe75b963f1d9 /tests | |
parent | 78d2e3d9dbf1530cdf4bc152b91f0ddd7ce4895b (diff) | |
download | ssh2-rs-18dc0f59e0b29c50da525dbe85d36fb5cb0ecf62.zip |
cargo fmt
No functional changes, just formatting
Diffstat (limited to 'tests')
-rw-r--r-- | tests/all/channel.rs | 16 | ||||
-rw-r--r-- | tests/all/knownhosts.rs | 29 | ||||
-rw-r--r-- | tests/all/main.rs | 2 | ||||
-rw-r--r-- | tests/all/session.rs | 19 | ||||
-rw-r--r-- | tests/all/sftp.rs | 21 |
5 files changed, 55 insertions, 32 deletions
diff --git a/tests/all/channel.rs b/tests/all/channel.rs index 2ade997..294eecf 100644 --- a/tests/all/channel.rs +++ b/tests/all/channel.rs @@ -1,5 +1,5 @@ use std::io::prelude::*; -use std::net::{TcpStream, TcpListener}; +use std::net::{TcpListener, TcpStream}; use std::thread; #[test] @@ -84,7 +84,7 @@ fn setenv() { fn direct() { let a = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = a.local_addr().unwrap(); - let t = thread::spawn(move|| { + let t = thread::spawn(move || { let mut s = a.accept().unwrap().0; let mut b = [0, 0, 0]; s.read(&mut b).unwrap(); @@ -92,8 +92,9 @@ fn direct() { s.write_all(&[4, 5, 6]).unwrap(); }); let (_tcp, sess) = ::authed_session(); - let mut channel = sess.channel_direct_tcpip("127.0.0.1", - addr.port(), None).unwrap(); + let mut channel = sess + .channel_direct_tcpip("127.0.0.1", addr.port(), None) + .unwrap(); channel.write_all(&[1, 2, 3]).unwrap(); let mut r = [0, 0, 0]; channel.read(&mut r).unwrap(); @@ -104,9 +105,8 @@ fn direct() { #[test] fn forward() { let (_tcp, sess) = ::authed_session(); - let (mut listen, port) = sess.channel_forward_listen(39249, None, None) - .unwrap(); - let t = thread::spawn(move|| { + 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(); let mut b = [0, 0, 0]; s.read(&mut b).unwrap(); @@ -149,8 +149,8 @@ fn nonblocking_before_exit_code() { sess.set_blocking(false); assert!(channel.read_to_string(&mut output).is_err()); { - use std::time::Duration; use std::thread; + use std::time::Duration; thread::sleep(Duration::from_millis(1500)); } sess.set_blocking(true); diff --git a/tests/all/knownhosts.rs b/tests/all/knownhosts.rs index f3a67fd..1847797 100644 --- a/tests/all/knownhosts.rs +++ b/tests/all/knownhosts.rs @@ -1,4 +1,4 @@ -use ssh2::{Session, KnownHostFileKind}; +use ssh2::{KnownHostFileKind, Session}; #[test] fn smoke() { @@ -26,16 +26,23 @@ PW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi\ assert_eq!(hosts.iter().count(), 1); let host = hosts.iter().next().unwrap().unwrap(); assert_eq!(host.name(), None); - assert_eq!(host.key(), "\ -AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9I\ -DSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVD\ -BfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eF\ -zLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKS\ -CZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2R\ -PW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi\ -/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="); + assert_eq!( + host.key(), + "\ + AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9I\ + DSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVD\ + BfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eF\ + zLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKS\ + CZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2R\ + PW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi\ + /w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" + ); - assert_eq!(hosts.write_string(&host, KnownHostFileKind::OpenSSH).unwrap(), - encoded); + assert_eq!( + hosts + .write_string(&host, KnownHostFileKind::OpenSSH) + .unwrap(), + encoded + ); hosts.remove(host).unwrap(); } diff --git a/tests/all/main.rs b/tests/all/main.rs index 777c899..7f150bc 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -7,9 +7,9 @@ use std::env; use std::net::TcpStream; mod agent; -mod session; mod channel; mod knownhosts; +mod session; mod sftp; pub fn socket() -> TcpStream { diff --git a/tests/all/session.rs b/tests/all/session.rs index 85fa321..42f1dd5 100644 --- a/tests/all/session.rs +++ b/tests/all/session.rs @@ -4,7 +4,7 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use tempdir::TempDir; -use ssh2::{Session, MethodType, HashType}; +use ssh2::{HashType, MethodType, Session}; #[test] fn smoke() { @@ -15,7 +15,8 @@ fn smoke() { assert_eq!(sess.timeout(), 0); sess.set_compress(true); assert!(sess.host_key().is_none()); - sess.method_pref(MethodType::Kex, "diffie-hellman-group14-sha1").unwrap(); + sess.method_pref(MethodType::Kex, "diffie-hellman-group14-sha1") + .unwrap(); assert!(sess.methods(MethodType::Kex).is_none()); sess.set_blocking(true); sess.set_timeout(0); @@ -61,7 +62,10 @@ fn scp_recv() { ch.read_to_string(&mut data).unwrap(); let p = PathBuf::from(env::var("HOME").unwrap()).join(".ssh/authorized_keys"); let mut expected = String::new(); - File::open(&p).unwrap().read_to_string(&mut expected).unwrap(); + File::open(&p) + .unwrap() + .read_to_string(&mut expected) + .unwrap(); assert!(data == expected); } @@ -69,10 +73,15 @@ fn scp_recv() { fn scp_send() { let td = TempDir::new("test").unwrap(); let (_tcp, sess) = ::authed_session(); - let mut ch = sess.scp_send(&td.path().join("foo"), 0o644, 6, None).unwrap(); + let mut ch = sess + .scp_send(&td.path().join("foo"), 0o644, 6, None) + .unwrap(); ch.write_all(b"foobar").unwrap(); drop(ch); let mut actual = Vec::new(); - File::open(&td.path().join("foo")).unwrap().read_to_end(&mut actual).unwrap(); + File::open(&td.path().join("foo")) + .unwrap() + .read_to_end(&mut actual) + .unwrap(); assert_eq!(actual, b"foobar"); } diff --git a/tests/all/sftp.rs b/tests/all/sftp.rs index d9ae8c5..415bcae 100644 --- a/tests/all/sftp.rs +++ b/tests/all/sftp.rs @@ -1,5 +1,5 @@ -use std::io::prelude::*; use std::fs::{self, File}; +use std::io::prelude::*; use tempdir::TempDir; #[test] @@ -19,13 +19,20 @@ fn ops() { sftp.opendir(&td.path().join("bar")).unwrap(); let mut foo = sftp.open(&td.path().join("foo")).unwrap(); sftp.mkdir(&td.path().join("bar2"), 0o755).unwrap(); - assert!(fs::metadata(&td.path().join("bar2")).map(|m| m.is_dir()) - .unwrap_or(false)); + assert!(fs::metadata(&td.path().join("bar2")) + .map(|m| m.is_dir()) + .unwrap_or(false)); sftp.rmdir(&td.path().join("bar2")).unwrap(); - sftp.create(&td.path().join("foo5")).unwrap().write_all(b"foo").unwrap(); + sftp.create(&td.path().join("foo5")) + .unwrap() + .write_all(b"foo") + .unwrap(); let mut v = Vec::new(); - File::open(&td.path().join("foo5")).unwrap().read_to_end(&mut v).unwrap(); + File::open(&td.path().join("foo5")) + .unwrap() + .read_to_end(&mut v) + .unwrap(); assert_eq!(v, b"foo"); assert_eq!(sftp.stat(&td.path().join("foo")).unwrap().size, Some(0)); @@ -33,8 +40,8 @@ fn ops() { foo.read_to_end(&mut v).unwrap(); assert_eq!(v, Vec::new()); - sftp.symlink(&td.path().join("foo"), - &td.path().join("foo2")).unwrap(); + sftp.symlink(&td.path().join("foo"), &td.path().join("foo2")) + .unwrap(); let readlink = sftp.readlink(&td.path().join("foo2")).unwrap(); assert!(readlink == td.path().join("foo")); let realpath = sftp.realpath(&td.path().join("foo2")).unwrap(); |