diff --git a/tests/Sanity/SASL-authentication-check/Makefile b/tests/Sanity/SASL-authentication-check/Makefile new file mode 100644 index 0000000..ee4b210 --- /dev/null +++ b/tests/Sanity/SASL-authentication-check/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/pcp/Sanity/SASL-authentication-check +# Description: A basic test of SASL authentication +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/pcp/Sanity/SASL-authentication-check +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.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: Jan Kuřík " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: A basic test of SASL authentication" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: pcp" >> $(METADATA) + @echo "Requires: pcp cyrus-sasl-md5 cyrus-sasl-scram" >> $(METADATA) + @echo "Requires: cyrus-sasl-lib" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL6 -RHELClient5 -RHELServer5 -RHEL7" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/SASL-authentication-check/PURPOSE b/tests/Sanity/SASL-authentication-check/PURPOSE new file mode 100644 index 0000000..3631b2e --- /dev/null +++ b/tests/Sanity/SASL-authentication-check/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/pcp/Sanity/SASL-authentication-check +Description: A basic test of SASL authentication +Author: Jan Kuřík diff --git a/tests/Sanity/SASL-authentication-check/main.fmf b/tests/Sanity/SASL-authentication-check/main.fmf new file mode 100644 index 0000000..e7fc118 --- /dev/null +++ b/tests/Sanity/SASL-authentication-check/main.fmf @@ -0,0 +1,15 @@ +summary: A basic test of SASL authentication +description: '' +contact: Jan Kuřík +component: +- pcp +test: ./runtest.sh +framework: beakerlib +recommend: +- pcp +- cyrus-sasl-md5 +- cyrus-sasl-scram +- cyrus-sasl-lib +duration: 15m +extra-summary: /tools/pcp/Sanity/SASL-authentication-check +extra-task: /tools/pcp/Sanity/SASL-authentication-check diff --git a/tests/Sanity/SASL-authentication-check/runtest.sh b/tests/Sanity/SASL-authentication-check/runtest.sh new file mode 100755 index 0000000..0bc8680 --- /dev/null +++ b/tests/Sanity/SASL-authentication-check/runtest.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/pcp/Sanity/SASL-authentication-check +# Description: A basic test of SASL authentication +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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="pcp" +METRICUSER="pcpmetricuser" +METRICUSERPW="pcpmetricuserpw" + +HASHES="scram-sha-256 digest-md5" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + + rlServiceStart "pmcd" + + rlFileBackup --clean --missing-ok \ + /etc/pcp.env \ + /etc/sasl2/pmcd.conf \ + /etc/pcp/passwd.db + rlRun "useradd -r ${METRICUSER}" + rlPhaseEnd + +for HASH in ${HASHES}; do + + rlPhaseStartTest "Test for ${HASH}" + rlRun "rm -f /etc/pcp/passwd.db" + rlRun "echo -e 'mech_list: ${HASH}\nsasldb_path: /etc/pcp/passwd.db\n' \ + > /etc/sasl2/pmcd.conf" + + rlRun "echo ${METRICUSERPW} | saslpasswd2 -p -a pmcd ${METRICUSER}" + rlRun "chown root:pcp /etc/pcp/passwd.db" + rlRun "chmod 640 /etc/pcp/passwd.db" + + rlServiceStart "pmcd" + rlRun "sleep 3" 0 "Give pmcd some time to start" + + rlRun -s "pminfo -f -h 'pcp://127.0.0.1?username=${METRICUSER}&password=${METRICUSERPW}' disk.dev.read" + rlFileSubmit "${rlRun_LOG}" "pminfo.output" + rlAssertNotGrep "user not found" "${rlRun_LOG}" + rlAssertGrep ".*inst .*value .*" "${rlRun_LOG}" -E + rlFileSubmit "/var/log/pcp/pmcd/pmcd.log" + rlPhaseEnd + +done + + rlPhaseStartCleanup + rlRun "userdel -fr ${METRICUSER}" + rlFileRestore + rlServiceRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd