From 2602b87ed0ea3b94156bbf850fbc33b82ae55e3a Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Fri, 3 Jan 2020 15:50:17 +0100 Subject: [PATCH] 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 --- .../Makefile | 65 +++++++++++++++++++ .../runtest.sh | 57 ++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/Regression/no-plugin-exception-during-analyses/Makefile create mode 100755 tests/Regression/no-plugin-exception-during-analyses/runtest.sh diff --git a/tests/Regression/no-plugin-exception-during-analyses/Makefile b/tests/Regression/no-plugin-exception-during-analyses/Makefile new file mode 100644 index 0000000..bf6f78e --- /dev/null +++ b/tests/Regression/no-plugin-exception-during-analyses/Makefile @@ -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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 " > $(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) + diff --git a/tests/Regression/no-plugin-exception-during-analyses/runtest.sh b/tests/Regression/no-plugin-exception-during-analyses/runtest.sh new file mode 100755 index 0000000..484c019 --- /dev/null +++ b/tests/Regression/no-plugin-exception-during-analyses/runtest.sh @@ -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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 +