Skip to content

Commit 5ecdb65

Browse files
committed
Update to tokio 1.0, simplify testing and update version
1 parent bac93e3 commit 5ecdb65

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async_ftp"
3-
version = "4.0.4"
3+
version = "5.0.0"
44
authors = ["Daniel García <[email protected]>", "Matt McCoy <[email protected]>"]
55
documentation = "https://docs.rs/async_ftp/"
66
repository = "https://github.com/dani-garcia/rust_async_ftp"
@@ -26,11 +26,11 @@ lazy_static = "1.4.0"
2626
regex = "1.3.9"
2727
chrono = "0.4.11"
2828

29-
tokio = { version = "0.3.1", features = ["net", "io-util"] }
30-
tokio-rustls = { version = "0.20.0", optional = true }
29+
tokio = { version = "1.0.1", features = ["net", "io-util"] }
30+
tokio-rustls = { version = "0.22.0", optional = true }
3131
pin-project = "1.0.0"
3232

3333
[dev-dependencies]
34-
tokio = { version = "0.3.1", features = ["macros", "stream", "rt"] }
35-
tokio-util = { version = "0.4.0", features = ["io"] }
36-
34+
tokio = { version = "1.0.1", features = ["macros", "rt"] }
35+
tokio-util = { version = "0.6.0", features = ["io"] }
36+
tokio-stream = "0.1.0"

src/ftp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,12 @@ impl FtpStream {
617617
#[cfg(test)]
618618
mod tests {
619619
use super::FtpStream;
620-
use tokio::{stream};
620+
use tokio_stream::once;
621621
use tokio_util::io::StreamReader;
622622

623623
#[tokio::test]
624624
async fn list_command_dos_newlines() {
625-
let data_stream = StreamReader::new(stream::once(Ok::<_, std::io::Error>(
625+
let data_stream = StreamReader::new(once(Ok::<_, std::io::Error>(
626626
b"Hello\r\nWorld\r\n\r\nBe\r\nHappy\r\n" as &[u8]
627627
)));
628628

@@ -637,7 +637,7 @@ mod tests {
637637

638638
#[tokio::test]
639639
async fn list_command_unix_newlines() {
640-
let data_stream = StreamReader::new(stream::once(Ok::<_, std::io::Error>(b"Hello\nWorld\n\nBe\nHappy\n" as &[u8])));
640+
let data_stream = StreamReader::new(once(Ok::<_, std::io::Error>(b"Hello\nWorld\n\nBe\nHappy\n" as &[u8])));
641641

642642
assert_eq!(
643643
FtpStream::get_lines_from_stream(data_stream).await.unwrap(),

tests/Dockerfile

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
FROM i386/ubuntu:latest
1+
FROM ubuntu:latest
22

3-
RUN apt-get update -qq &&\
4-
apt-get install -yqq vsftpd
3+
RUN apt update && apt install -y vsftpd
54

6-
RUN mkdir -p /var/run/vsftpd/empty &&\
7-
useradd -s /bin/bash -d /home/ftp -m -c "Doe ftp user" -g ftp Doe &&\
8-
echo "Doe:mumble"| chpasswd &&\
9-
echo "listen=yes\n\
10-
anon_root=/home/ftp\n\
11-
local_enable=yes\n\
12-
local_umask=022\n\
13-
pasv_enable=YES\n\
14-
pasv_min_port=65000\n\
15-
pasv_max_port=65010\n\
16-
write_enable=yes\n\
17-
log_ftp_protocol=yes" > /etc/vsftpd.conf &&\
18-
echo "/etc/init.d/vsftpd start" | tee -a /etc/bash.bashrc
5+
RUN useradd --home-dir /home/ftp --create-home --groups ftp Doe
6+
RUN echo "Doe:mumble" | chpasswd
7+
8+
RUN cp /etc/vsftpd.conf /etc/vsftpd.conf.orig
9+
RUN echo "write_enable=yes\nlog_ftp_protocol=yes" > /etc/vsftpd.conf
10+
RUN cat /etc/vsftpd.conf.orig >> /etc/vsftpd.conf
11+
12+
RUN echo "/etc/init.d/vsftpd start" | tee -a /etc/bash.bashrc
1913

2014
CMD ["/bin/bash"]

tests/ftp-server.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3-
# run the ftp server instance in detached mode (in the background)
4-
# but also with TTY and interactive mode, so we can attach to it if we want to
5-
docker run -dti --privileged -p 21:21 -p 65000-65010:65000-65010 ftp-server
3+
# Build the docker image
4+
docker build -t ftp-server .
5+
6+
# run the ftp server instance
7+
docker run --rm --name ftp-server -ti --net=host ftp-server

tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::Cursor;
55
#[test]
66
fn test_ftp() {
77
let future = async {
8-
let mut ftp_stream = FtpStream::connect("172.25.82.139:21").await?;
8+
let mut ftp_stream = FtpStream::connect("192.168.1.60:21").await?;
99
let _ = ftp_stream.login("Doe", "mumble").await?;
1010

1111
ftp_stream.mkdir("test_dir").await?;

0 commit comments

Comments
 (0)