tests: Does setroubleshoot report any 'Plugin Exception' during analyses?

This test should cover cases when setroubleshoot reports "Plugin Exception"
during analyses, see https://bugzilla.redhat.com/show_bug.cgi?id=1784564

Example log with the reported problem:
    setroubleshoot[834]: Plugin Exception catchall_labels
    setroubleshoot[834]: Plugin Exception file
    setroubleshoot[834]: Plugin Exception openvpn
This commit is contained in:
Petr Lautrbach 2020-01-03 15:50:17 +01:00
parent 1bbd702684
commit 2602b87ed0
2 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,65 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/setroubleshoot/Regression/no-plugin-exception-during-analyses
# Description: Does setroubleshoot report any 'Plugin Exception' during analyses?
# Author: Petr Lautrbach <plautrba@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 Red Hat, Inc.
#
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/setroubleshoot/Regression/no-plugin-exception-during-analyses
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Petr Lautrbach <plautrba@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Does setroubleshoot report any 'Plugin Exception' during analyses?" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: setroubleshoot" >> $(METADATA)
@echo "Requires: setroubleshoot-server" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Environment: AVC_ERROR=+no_avc_check" >> $(METADATA)
@echo "Bug: 1784564" >> $(METADATA) # RHEL-7
rhts-lint $(METADATA)

View File

@ -0,0 +1,57 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/setroubleshoot/Regression/no-plugin-exception-during-analyses
# Description: Does setroubleshoot report any 'Plugin Exception' during analyses?
# Author: Petr Lautrbach <plautrba@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2020 Red Hat, Inc.
#
# 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/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="setroubleshoot"
rlJournalStart
rlPhaseStartSetup
rlPhaseEnd
rlPhaseStartTest "no 'Plugin Exception'"
SINCE=$(date '+%Y-%m-%d %H:%M:%S')
RANDOM_NUMBER=${RANDOM}
rlRun "passwd --help >& /root/output-${RANDOM_NUMBER}.txt"
rlRun "rm -f /root/output-${RANDOM_NUMBER}.txt"
sleep 10
rlRun "journalctl --since=\"$SINCE\" > journal-after.txt"
rlAssertGrep "setroubleshoot.*: SELinux is preventing passwd" journal-after.txt
rlAssertNotGrep "setroubleshoot.*: Plugin Exception " journal-after.txt
rlRun "[[ $? -eq 0 ]] || cat journal-after.txt"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm -f journal-after.txt"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd