From 8f0ec5a5bd426f060d4260840432da3369077d1d Mon Sep 17 00:00:00 2001 From: FanDjango <51046875+FanDjango@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:08:32 +0100 Subject: [PATCH 1/2] Add an Integration Test for Apache FTP Server --- .../Integration/IntegrationTests.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/FluentFTP.Tests/Integration/IntegrationTests.cs b/FluentFTP.Tests/Integration/IntegrationTests.cs index 83c1d1850..01a4c7f62 100644 --- a/FluentFTP.Tests/Integration/IntegrationTests.cs +++ b/FluentFTP.Tests/Integration/IntegrationTests.cs @@ -13,14 +13,6 @@ public class IntegrationTests { // These can do both FTP and FTPS [Fact] - public async Task VsFtpd() { - await IntegrationTestRunner.Run(FtpServer.VsFTPd); - } - [Fact] - public async Task VsFtpdSsl() { - await IntegrationTestRunner.Run(FtpServer.VsFTPd, UseSsl); - } - [Fact] public async Task ProFtpd() { await IntegrationTestRunner.Run(FtpServer.ProFTPD); } @@ -36,20 +28,31 @@ public async Task PureFtpd() { public async Task PureFtpdSsl() { await IntegrationTestRunner.Run(FtpServer.PureFTPd, UseSsl); } - - // These can only do FTPS [Fact] - public async Task Glftpd() { - await IntegrationTestRunner.Run(FtpServer.glFTPd); + public async Task VsFtpd() { + await IntegrationTestRunner.Run(FtpServer.VsFTPd); + } + [Fact] + public async Task VsFtpdSsl() { + await IntegrationTestRunner.Run(FtpServer.VsFTPd, UseSsl); } + // These can only do FTPS [Fact] public async Task FileZilla() { await IntegrationTestRunner.Run(FtpServer.FileZilla); } + [Fact] + public async Task Glftpd() { + await IntegrationTestRunner.Run(FtpServer.glFTPd); + } // These can only do FTP [Fact] + public async Task Apache() { + await IntegrationTestRunner.Run(FtpServer.Apache); + } + [Fact] public async Task Bftpd() { await IntegrationTestRunner.Run(FtpServer.BFTPd); } From d77b2210a16522b3b7183f636b0d7795dbeac5ef Mon Sep 17 00:00:00 2001 From: FanDjango <51046875+FanDjango@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:22:51 +0100 Subject: [PATCH 2/2] Add docker container for Apache FTP Server --- FluentFTP.Dockers/Build.bat | 15 ++--- FluentFTP.Dockers/Build.sh | 15 ++--- FluentFTP.Dockers/apache/Dockerfile | 69 +++++++++++++++++++++ FluentFTP.Dockers/apache/config.xml | 30 +++++++++ FluentFTP.Dockers/apache/docker-compose.yml | 15 +++++ FluentFTP.Dockers/apache/run-apache.sh | 19 ++++++ FluentFTP.Dockers/apache/users.properties | 27 ++++++++ 7 files changed, 176 insertions(+), 14 deletions(-) create mode 100644 FluentFTP.Dockers/apache/Dockerfile create mode 100644 FluentFTP.Dockers/apache/config.xml create mode 100644 FluentFTP.Dockers/apache/docker-compose.yml create mode 100644 FluentFTP.Dockers/apache/run-apache.sh create mode 100644 FluentFTP.Dockers/apache/users.properties diff --git a/FluentFTP.Dockers/Build.bat b/FluentFTP.Dockers/Build.bat index 286504e47..62bb55b91 100644 --- a/FluentFTP.Dockers/Build.bat +++ b/FluentFTP.Dockers/Build.bat @@ -1,16 +1,17 @@ +docker build apache -t apache:fluentftp -docker build proftpd -t proftpd:fluentftp +docker build bftpd -t bftpd:fluentftp -docker build pureftpd -t pureftpd:fluentftp +docker build filezilla -t filezilla:fluentftp -docker build vsftpd -t vsftpd:fluentftp +docker build glftpd -t glftpd:fluentftp -docker build pyftpdlib -t pyftpdlib:fluentftp +docker build proftpd -t proftpd:fluentftp -docker build bftpd -t bftpd:fluentftp +docker build pureftpd -t pureftpd:fluentftp -docker build glftpd -t glftpd:fluentftp +docker build pyftpdlib -t pyftpdlib:fluentftp -docker build filezilla -t filezilla:fluentftp +docker build vsftpd -t vsftpd:fluentftp pause \ No newline at end of file diff --git a/FluentFTP.Dockers/Build.sh b/FluentFTP.Dockers/Build.sh index bc76aa796..212604bf8 100644 --- a/FluentFTP.Dockers/Build.sh +++ b/FluentFTP.Dockers/Build.sh @@ -1,14 +1,15 @@ +sudo docker build apache -t bftpd:apache -sudo docker build proftpd -t proftpd:fluentftp +sudo docker build bftpd -t bftpd:fluentftp -sudo docker build pureftpd -t pureftpd:fluentftp +sudo docker build filezilla -t filezilla:fluentftp -sudo docker build vsftpd -t vsftpd:fluentftp +sudo docker build glftpd -t glftpd:fluentftp -sudo docker build pyftpdlib -t pyftpdlib:fluentftp +sudo docker build proftpd -t proftpd:fluentftp -sudo docker build bftpd -t bftpd:fluentftp +sudo docker build pureftpd -t pureftpd:fluentftp -sudo docker build glftpd -t glftpd:fluentftp +sudo docker build pyftpdlib -t pyftpdlib:fluentftp -sudo docker build filezilla -t filezilla:fluentftp +sudo docker build vsftpd -t vsftpd:fluentftp diff --git a/FluentFTP.Dockers/apache/Dockerfile b/FluentFTP.Dockers/apache/Dockerfile new file mode 100644 index 000000000..e9f930e8e --- /dev/null +++ b/FluentFTP.Dockers/apache/Dockerfile @@ -0,0 +1,69 @@ +# +# FluentFTP Integration Test Server: apache +# + +# +# Stage 1: build +# + +FROM debian:bullseye-slim AS build + +SHELL ["/bin/bash", "-c"] + +ARG APACHE_VERSION=1.2.0 + +ARG APACHE_URL=https://dlcdn.apache.org/mina/ftpserver/${APACHE_VERSION}/apache-ftpserver-${APACHE_VERSION}-bin.tar.gz + +ARG DEBIAN_FRONTEND=noninteractive +ARG APT_CMD='apt install -y --no-install-recommends' + +RUN apt update && apt upgrade -y && apt install -y apt-utils && \ + \ + $APT_CMD \ + ca-certificates \ + wget + +WORKDIR /root +RUN wget -O apache.tar.gz ${APACHE_URL} && \ + tar xzf apache.tar.gz && \ + mv apache-ftpserver-${APACHE_VERSION} apache + +# +# Stage 2: production +# + +FROM debian:bullseye-slim AS production + +LABEL Description="FluentFTP apache-ftp-server docker image based on Debian Bullseye." + +SHELL ["/bin/bash", "-c"] + +ARG DEBIAN_FRONTEND=noninteractive +ARG APT_CMD='apt install -y --no-install-recommends' + +RUN apt update && apt upgrade -y && apt install -y apt-utils && \ + \ + $APT_CMD \ + default-jre + +COPY run-apache.sh /usr/bin/ + +COPY --from=build /root/apache /root/apache + +COPY config.xml /root/apache/res/conf/config.xml +COPY users.properties /root/apache/res/conf/users.properties + +WORKDIR / +RUN sed -i -e "s/\r//" /root/apache/res/conf/config.xml && \ + sed -i -e "s/\r//" /root/apache/res/conf/users.properties && \ + sed -i -e "s/\r//" /usr/bin/run-apache.sh && \ + chmod +x /usr/bin/run-apache.sh && \ + \ + useradd -m -p savatlcb.1m26 fluentuser && \ + \ + mkdir -p /home/fluentuser/ && \ + chown -R fluentuser:users /home/fluentuser + +EXPOSE 20 21 + +CMD ["/usr/bin/run-apache.sh"] diff --git a/FluentFTP.Dockers/apache/config.xml b/FluentFTP.Dockers/apache/config.xml new file mode 100644 index 000000000..01634098e --- /dev/null +++ b/FluentFTP.Dockers/apache/config.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/FluentFTP.Dockers/apache/docker-compose.yml b/FluentFTP.Dockers/apache/docker-compose.yml new file mode 100644 index 000000000..822080402 --- /dev/null +++ b/FluentFTP.Dockers/apache/docker-compose.yml @@ -0,0 +1,15 @@ +services: + apache: + build: + context: . + network: host + restart: unless-stopped + restart: always + network_mode: "host" + ports: + - 0.0.0.0:20:20 + - 0.0.0.0:21:21 + - 21100-21199:21100-21199 + volumes: + - ./home:/home/apache + - ./logs:/var/log/apache diff --git a/FluentFTP.Dockers/apache/run-apache.sh b/FluentFTP.Dockers/apache/run-apache.sh new file mode 100644 index 000000000..87e384e8c --- /dev/null +++ b/FluentFTP.Dockers/apache/run-apache.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# stdout server info: +cat << EOB + ************************************************* + * * + * Docker image: fluentftp apache * + * * + ************************************************* + + SERVER SETTINGS + --------------- + · FTP User: fluentuser + · FTP Password: fluentpass +EOB + +# Run apache: +cd /root/apache +bin/ftpd.sh res/conf/config.xml diff --git a/FluentFTP.Dockers/apache/users.properties b/FluentFTP.Dockers/apache/users.properties new file mode 100644 index 000000000..c9a908618 --- /dev/null +++ b/FluentFTP.Dockers/apache/users.properties @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# user password is "fluentpass" code in md5 +ftpserver.user.fluentuser.userpassword=9AB870DD41C07E40C6C96307DB575E56 +ftpserver.user.fluentuser.homedirectory=./res/home +ftpserver.user.fluentuser.enableflag=true +ftpserver.user.fluentuser.writepermission=true +ftpserver.user.fluentuser.maxloginnumber=0 +ftpserver.user.fluentuser.maxloginperip=0 +ftpserver.user.fluentuser.idletime=0 +ftpserver.user.fluentuser.uploadrate=0 +ftpserver.user.fluentuser.downloadrate=0