From ba80602fc0ffbf7b20afcd4f6137d6b0237da3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branislav=20N=C3=A1ter?= Date: Mon, 6 Dec 2021 18:02:38 +0100 Subject: [PATCH] server-tokens test added --- core/server-tokens/main.fmf | 33 ++++++++++++++ core/server-tokens/runtest.sh | 83 +++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 core/server-tokens/main.fmf create mode 100755 core/server-tokens/runtest.sh diff --git a/core/server-tokens/main.fmf b/core/server-tokens/main.fmf new file mode 100644 index 0000000..4e876ed --- /dev/null +++ b/core/server-tokens/main.fmf @@ -0,0 +1,33 @@ +summary: httpd ServerTokens Full-Release +description: | + Bug summary: [RFE] Apache does not report patch level when scanned + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=240857 + + Test for BZ#240857 (httpd ServerTokens Full-Release) +contact: Branislav NĂ¡ter +component: + - httpd +test: ./runtest.sh +path: /misc/bug240857 +framework: beakerlib +require: + - library(httpd/http) +recommend: + - httpd + - curl + - grep + - pyOpenSSL +duration: 5m +enabled: true +tag: + - HttpdSclDone + - Tier1 +tier: '1' +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=240857 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=811714 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1932442 + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2029071 +extra-nitrate: TC#0078363 +extra-summary: /CoreOS/httpd/misc/bug240857 +extra-task: /CoreOS/httpd/misc/bug240857 diff --git a/core/server-tokens/runtest.sh b/core/server-tokens/runtest.sh new file mode 100755 index 0000000..7c5e130 --- /dev/null +++ b/core/server-tokens/runtest.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/httpd/misc/bug240857 +# Description: Test for BZ#240857 (httpd ServerTokens Full-Release) +# Author: Joe Orton +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2007 Red Hat, Inc. All rights reserved. +# +# 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="${PACKAGES:-httpd}" +REQUIRES="${REQUIRES:-curl}" + +rlJournalStart + rlPhaseStartSetup "Setup #1" + rlRun "rlImport httpd/http" 0 "Import httpd library" + rlAssertRpm --all + CONF="${httpCONFDIR}/conf/httpd.conf" + VERSION=`rpm -q --qf '%{VERSION}' $httpHTTPD` + RELEASE=`rpm -q --qf '%{RELEASE}' $httpHTTPD` + rlIsFedora && OS="Fedora" + rlIsCentOS && OS="CentOS" + rlIsRHEL && OS="Red Hat Enterprise Linux" + rlRun "rlFileBackup $CONF" + # Full-Release not present in Fedora + if ! rlIsFedora; then + grep ServerTokens $CONF || rlRun "echo 'ServerTokens Full-Release' >> $CONF" + else + rlRun "sed -i 's/^ServerTokens.*/ServerTokens Full-Release/' $CONF" + fi + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "httpStart" 0 "Start httpd" + rlPhaseEnd + + rlPhaseStartTest "Test #1" + rlRun "curl -s -D output http://localhost/" 0 "Getting Full Release Tokens" + cat output + + rlAssertGrep "^Server: Apache/$VERSION ($OS) (Release $RELEASE)" output + rlRun "httpStop" 0 "Stop httpd" + rlPhaseEnd + + rlPhaseStartSetup "Setup #2" + rlRun "sed -i 's/^ServerTokens.*/ServerTokens OS/' $CONF" + rlRun "httpStart" 0 "Start httpd" + rlPhaseEnd + + rlPhaseStartTest "Test #2" + rlRun "curl -s -D output http://localhost/" 0 "Getting default headers" + cat output + rlRun "tr -d '\r' < output | grep \"^Server: Apache/$VERSION ($OS)\$\"" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "httpStop" 0 "Stop httpd" + rlRun "rlFileRestore" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd