Blame tests/p_lftp/20_lftp_ftp.sh

root 6daf8d
#!/bin/sh
root d9b376
# Author: Piyush Kumar <piykumar@gmail.com>
root d9b376
# Author: Munish Kumar <munishktotech@gmail.com>
root d9b376
# Author: Ayush Gupta <ayush.001@gmail.com>
root d9b376
# Author: Konark Modi <modi.konark@gmail.com>
Christoph Galuschka 4380e7
#	  Christoph Galuschka <christoph.galuschka@chello.at>
root 6daf8d
Christoph Galuschka 4380e7
t_Log "Running $0 - installing vsFTPd for local lftp test."
Pablo Greco bf88bf
t_InstallPackage vsftpd
40b4c8
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
40b4c8
Pablo Greco bf88bf
if [ "$centos_ver" -ge 8 ] ; then
Pablo Greco bf88bf
cp -fp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.tf_p_lftp
Pablo Greco bf88bf
sed -i 's/anonymous_enable=NO/anonymous_enable=YES/g' /etc/vsftpd/vsftpd.conf
Pablo Greco bf88bf
fi
Christoph Galuschka 4380e7
t_ServiceControl vsftpd restart
Pablo Greco bf88bf
if [ "$centos_ver" -ge 8 ] ; then
Pablo Greco bf88bf
mv -f /etc/vsftpd/vsftpd.conf.tf_p_lftp /etc/vsftpd/vsftpd.conf
Pablo Greco bf88bf
fi
Christoph Galuschka 4380e7
Christoph Galuschka 4380e7
# Destination File
Christoph Galuschka 4380e7
TESTFILE=/tmp/t_functional-lftp-test.txt
Christoph Galuschka 4380e7
Christoph Galuschka 4380e7
# Source File on FTP server
Christoph Galuschka 4380e7
SOURCE=/var/ftp/
Christoph Galuschka 4380e7
FILE=lftp-test.txt
Christoph Galuschka 4380e7
cat > $SOURCE$FILE << EOF
Christoph Galuschka 4380e7
t_functional
Christoph Galuschka 4380e7
EOF
Christoph Galuschka 4380e7
URL="ftp://127.0.0.1/"
root 6daf8d
Christoph Galuschka 4380e7
t_Log "Running $0 - lftp test with local FTP server."
root 6daf8d
Christoph Galuschka 4380e7
lftp -e 'set net:timeout 10; get '${FILE}' -o '$TESTFILE' ; bye' $URL > /dev/null 2>&1
Christoph Galuschka 4380e7
if [ -f $TESTFILE ]
root 6daf8d
  then
Christoph Galuschka 4380e7
  grep -q 't_functional' $TESTFILE
root 6daf8d
  ret_val=$?
root 6daf8d
  else
root 6daf8d
  t_Log "FTP test for lftp failed"
root 6daf8d
  ret_val=$?
root 6daf8d
fi
Christoph Galuschka 4380e7
Christoph Galuschka 4380e7
# clean up
Christoph Galuschka 4380e7
rm -f $TESTFILE
Christoph Galuschka 4380e7
rm -f $SOURCE$FILE
Christoph Galuschka 4380e7
t_ServiceControl vsftpd stop
Christoph Galuschka 4380e7
root 6daf8d
t_CheckExitStatus $ret_val