Blame sanity/runtest.sh

8de75c8
#!/bin/bash
8de75c8
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
8de75c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8de75c8
#
8de75c8
#   runtest.sh of /CoreOS/lftp/sanity
8de75c8
#   Description: Basic lftp sanity test
8de75c8
#   Author: Jakub Hrozek <jhrozek@redhat.com>
8de75c8
#   Modified by: David Kutalek <dkutalek@redhat.com>
8de75c8
#
8de75c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8de75c8
#
8de75c8
#   Copyright (c) 2006, 2012 Red Hat, Inc. All rights reserved.
8de75c8
#
8de75c8
#   This copyrighted material is made available to anyone wishing
8de75c8
#   to use, modify, copy, or redistribute it subject to the terms
8de75c8
#   and conditions of the GNU General Public License version 2.
8de75c8
#
8de75c8
#   This program is distributed in the hope that it will be
8de75c8
#   useful, but WITHOUT ANY WARRANTY; without even the implied
8de75c8
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8de75c8
#   PURPOSE. See the GNU General Public License for more details.
8de75c8
#
8de75c8
#   You should have received a copy of the GNU General Public
8de75c8
#   License along with this program; if not, write to the Free
8de75c8
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
8de75c8
#   Boston, MA 02110-1301, USA.
8de75c8
#
8de75c8
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8de75c8
8de75c8
# Include Beaker environment
8de75c8
. /usr/share/beakerlib/beakerlib.sh
8de75c8
8de75c8
PACKAGE="lftp"
8de75c8
8de75c8
rlJournalStart
8de75c8
    rlPhaseStartSetup
8de75c8
        rlRun "rlImport selinux-policy/common" 0 "Importing SELinux library"
8de75c8
        rlAssertRpm $PACKAGE
8de75c8
        rlAssertRpm "expect"
8de75c8
        rlAssertRpm "vsftpd"
8de75c8
        rlFileBackup "/etc/vsftpd/vsftpd.conf"
8de75c8
        if ! rlIsRHEL '<8'; then
8de75c8
            # On rhel8 tcp_wrappers are not compiled in.
8de75c8
            rlRun "sed -i 's/tcp_wrappers=YES/tcp_wrappers=NO/' vsftpd.conf" 0 "Disable tcp_wrappers" 
8de75c8
        fi
8de75c8
        # User is created in the pyhon script
8de75c8
        rlRun "cp -f ./vsftpd.conf /etc/vsftpd/vsftpd.conf"
8de75c8
        rlServiceStart "vsftpd"
8de75c8
        rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
8de75c8
        rlRun "cp ./sanity.py $TmpDir/"
8de75c8
        rlRun "pushd $TmpDir"
8de75c8
        if rlIsRHEL '<=6'; then
8de75c8
            rlRun "rlSEBooleanBackup allow_ftpd_anon_write"
8de75c8
            rlRun "rlSEBooleanBackup allow_ftpd_full_access"
8de75c8
            rlRun "rlSEBooleanOn allow_ftpd_anon_write"
8de75c8
            rlRun "rlSEBooleanOn allow_ftpd_full_access"
8de75c8
        else
8de75c8
            rlRun "rlSEBooleanBackup ftpd_anon_write"
8de75c8
            rlRun "rlSEBooleanBackup ftpd_full_access"
8de75c8
            rlRun "rlSEBooleanOn ftpd_anon_write"
8de75c8
            rlRun "rlSEBooleanOn ftpd_full_access"
8de75c8
        fi
8de75c8
    rlPhaseEnd
8de75c8
8de75c8
    rlPhaseStartTest
8de75c8
        rlRun "python2 sanity.py -v"
8de75c8
    rlPhaseEnd
8de75c8
8de75c8
    rlPhaseStartCleanup
8de75c8
        rlFileRestore
8de75c8
        rlServiceRestore "vsftpd"
8de75c8
        rlRun "popd"
8de75c8
        rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
8de75c8
        rlRun "rlSEBooleanRestore" 0 "Restoring SELinux booleans"
8de75c8
        # If the python script does not finish this deletes the user from the system
8de75c8
        rlRun "userdel -rf lftp-tester" 0,6 "Delete lftp-tester user"
8de75c8
    rlPhaseEnd
8de75c8
rlJournalPrintText
8de75c8
rlJournalEnd