#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lftp/Regression/bz810217-lftp-hangs-using-a-ascii-mode
# Description: Test for BZ#810217 (lftp hangs using -a ascii mode)
# Author: David Kutalek <dkutalek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="lftp"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "echo 'Ascii lftp upload test file' > ./test.txt"
rlRun "grep '^Subsystem[[:space:]]*sftp[[:space:]]*/usr/libexec/openssh/sftp-server\$' /etc/ssh/sshd_config"
rlRun "useradd -m lftptester"
rlRun "echo testerpwd | passwd --stdin lftptester"
rlRun "netstat -lnp | grep sshd | grep ':22'"
rlPhaseEnd
rlPhaseStartTest
if [ -e ~/.ssh/known_hosts ]; then
rlRun "rlFileBackup ~/.ssh/known_hosts" 0 "Back up ~/.ssh/known_hosts"
RESTORE=1
fi
rlRun "ssh-keyscan 127.0.0.1 >> ~/.ssh/known_hosts" 0 "Add ssh fingerprint for localhost to known_hosts"
rlRun "rlWatchdog \"lftp -d -u lftptester,testerpwd sftp://127.0.0.1:22 -e 'put -a test.txt; exit'\" 30"
rlRun "ls -l /home/lftptester/test.txt"
rlRun "cat /home/lftptester/test.txt"
rlPhaseEnd
rlPhaseStartCleanup
if [ $RESTORE -eq 1 ]; then
rlRun "rlFileRestore" 0 "Restore ~/.ssh/known_hosts"
fi
rlRun "userdel -f -r lftptester"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd