From bc64868415220dd9b2bd7f4a2527675715e4bb51 Mon Sep 17 00:00:00 2001 From: Hannes de Jager Date: Thu, 7 Sep 2023 23:06:51 +0200 Subject: [PATCH] Upgrade to Rust 1.72.0 --- .github/workflows/rust.yml | 2 +- crates/unftp-auth-jsonfile/src/lib.rs | 24 ++++++++++++------------ crates/unftp-sbe-fs/tests/main.rs | 9 +++------ src/auth/authenticator.rs | 2 +- src/server/mod.rs | 2 +- src/server/proxy_protocol.rs | 2 +- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 84f15b36..d6d93841 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,7 +2,7 @@ name: build env: CARGO_TERM_COLOR: always - RUST_VERSION: 1.67.1 + RUST_VERSION: 1.72.0 on: push: diff --git a/crates/unftp-auth-jsonfile/src/lib.rs b/crates/unftp-auth-jsonfile/src/lib.rs index 3397b520..d6403b62 100644 --- a/crates/unftp-auth-jsonfile/src/lib.rs +++ b/crates/unftp-auth-jsonfile/src/lib.rs @@ -501,18 +501,18 @@ mod test { ); assert_eq!(json_authenticator.authenticate("carol", &"not so secure".into()).await.unwrap(), DefaultUser); assert_eq!(json_authenticator.authenticate("dan", &"".into()).await.unwrap(), DefaultUser); - match json_authenticator.authenticate("carol", &"this is the wrong password".into()).await { - Err(AuthenticationError::BadPassword) => assert!(true), - _ => assert!(false), - } - match json_authenticator.authenticate("bella", &"this is the wrong password".into()).await { - Err(AuthenticationError::BadPassword) => assert!(true), - _ => assert!(false), - } - match json_authenticator.authenticate("chuck", &"12345678".into()).await { - Err(AuthenticationError::BadUser) => assert!(true), - _ => assert!(false), - } + assert_eq!( + json_authenticator.authenticate("carol", &"this is the wrong password".into()).await, + Err(AuthenticationError::BadPassword) + ); + assert_eq!( + json_authenticator.authenticate("bella", &"this is the wrong password".into()).await, + Err(AuthenticationError::BadPassword) + ); + assert_eq!( + json_authenticator.authenticate("chuck", &"12345678".into()).await, + Err(AuthenticationError::BadUser) + ); assert_eq!( json_authenticator diff --git a/crates/unftp-sbe-fs/tests/main.rs b/crates/unftp-sbe-fs/tests/main.rs index 50c2ae98..a0305116 100644 --- a/crates/unftp-sbe-fs/tests/main.rs +++ b/crates/unftp-sbe-fs/tests/main.rs @@ -42,7 +42,7 @@ where let server = s(root.clone()).listen(addr.clone()); tokio::spawn(server); - while !async_ftp::FtpStream::connect(&addr).await.is_ok() { + while async_ftp::FtpStream::connect(&addr).await.is_err() { tokio::time::sleep(std::time::Duration::from_millis(10)).await; } @@ -51,7 +51,7 @@ where #[fixture] async fn harness() -> Harness { - custom_server_harness(|root| libunftp::Server::with_fs(root)).await + custom_server_harness(libunftp::Server::with_fs).await } #[rstest] @@ -285,10 +285,7 @@ mod list { ensure_login_required(ftp_stream.list(None).await); ftp_stream.login("hoi", "jij").await.unwrap(); - let list = ftp_stream - .list(dir_in_root.path().file_name().map(std::ffi::OsStr::to_str).flatten()) - .await - .unwrap(); + let list = ftp_stream.list(dir_in_root.path().file_name().and_then(std::ffi::OsStr::to_str)).await.unwrap(); let mut found = false; for entry in list { if entry.contains("test.txt") { diff --git a/src/auth/authenticator.rs b/src/auth/authenticator.rs index 81ea86ae..b5638516 100644 --- a/src/auth/authenticator.rs +++ b/src/auth/authenticator.rs @@ -19,7 +19,7 @@ where /// Tells whether its OK to not ask for a password when a valid client cert /// was presented. async fn cert_auth_sufficient(&self, _username: &str) -> bool { - return false; + false } /// Implement to set the name of the authenticator. By default it returns the type signature. diff --git a/src/server/mod.rs b/src/server/mod.rs index 848d7638..8e87d9c0 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -17,4 +17,4 @@ pub(crate) use controlchan::reply::{Reply, ReplyCode}; pub(crate) use controlchan::ControlChanMiddleware; pub(crate) use controlchan::Event; pub(crate) use controlchan::{ControlChanError, ControlChanErrorKind}; -pub(self) use session::{Session, SessionState}; +use session::{Session, SessionState}; diff --git a/src/server/proxy_protocol.rs b/src/server/proxy_protocol.rs index e5f599f3..a1d81800 100644 --- a/src/server/proxy_protocol.rs +++ b/src/server/proxy_protocol.rs @@ -25,7 +25,7 @@ impl From for ProxyMode { #[derive(Error, Debug)] #[error("Proxy Protocol Error")] -pub(self) enum ProxyError { +enum ProxyError { #[error("header doesn't end with CRLF")] CrlfError, #[error("header size is incorrect")]