#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/cups/Sanity/bz2015182-RFE-Implement-IdleExitTimeout-configuration
# Description: Test for BZ#2015182 (RFE Implement IdleExitTimeout configuration during)
# Author: Zdenek Dohnal <zdohnal@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2021 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# 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, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="cups"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlFileBackup /etc/cups/cupsd.conf
rlRun "sed -i 's,Browsing On,Browsing Off,' /etc/cups/cupsd.conf" 0 "Turn off sharing of queues"
rlRun "sed -i 's,WebInterface Yes,WebInterface No,' /etc/cups/cupsd.conf" 0 "Turn off web interface"
rlPhaseEnd
rlPhaseStartTest
rlServiceStart cups
rlRun "sleep 65" 0 "Wait till we are sure the default IdleExitTimeout would kick in if set"
if rlIsRHEL ">7"
then
rlRun "systemctl status cups" 0 "If cups was compiled to use unlimited IdleExitTimeout, cupsd should be running"
else
rlLog "The OS is RHEL < 8 or Fedora - the feature is not implemented for RHEL < 7, CUPS in Fedora \
is not compiled with the option, because its default use is a desktop."
rlRun "systemctl status cups" 3 "CUPS is inactive after IdleExitTimeout on older RHELs and Fedora"
fi
rlPhaseEnd
rlPhaseStartCleanup
rlServiceRestore
rlFileRestore
rlPhaseEnd
rlJournalPrintText
rlJournalEnd