From e2356aebf9c80458a3b020ccb593a07242b03413 Mon Sep 17 00:00:00 2001 From: Ondrej Mejzlik Date: Oct 12 2020 12:56:20 +0000 Subject: Adding upstream test 302 redirect --- diff --git a/Regression/bz928307-follow-302-redirect/PURPOSE b/Regression/bz928307-follow-302-redirect/PURPOSE new file mode 100644 index 0000000..4a567e0 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/lftp/Regression/bz928307-follow-302-redirect +Description: Tests if lftp follows 302 redirects in mirror mode. +Author: Martin Frodl +Bug summary: lftp does not follow http redirect (302) in mirror mode +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=928307 diff --git a/Regression/bz928307-follow-302-redirect/main.fmf b/Regression/bz928307-follow-302-redirect/main.fmf new file mode 100644 index 0000000..1cca227 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/main.fmf @@ -0,0 +1,33 @@ +summary: Tests if lftp follows 302 redirects in mirror mode +description: | + Bug summary: lftp does not follow http redirect (302) in mirror mode + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=928307 +component: +- lftp +test: ./runtest.sh +framework: beakerlib +require: +- library(httpd/http) +recommend: +- lftp +- httpd +- mod_wsgi +- curl +- python2 +- python3-mod_wsgi +duration: 5m +enabled: true +tag: +- NoRHEL4 +- NoRHEL5 +- TIPfail_infra +- TIPpass_Apps +- TIPpass_FIPS +- Tier3 +- tip_destructive_el8 +tier: '3' +relevancy: | + distro = rhel-4, rhel-5: False +extra-nitrate: TC#0472729 +extra-summary: /CoreOS/lftp/Regression/bz928307-follow-302-redirect +extra-task: /CoreOS/lftp/Regression/bz928307-follow-302-redirect diff --git a/Regression/bz928307-follow-302-redirect/redir-absolute.py b/Regression/bz928307-follow-302-redirect/redir-absolute.py new file mode 100644 index 0000000..eb72a17 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/redir-absolute.py @@ -0,0 +1,12 @@ +#!/usr/bin/python + +import sys + +def application(environ, start_response): + status = '302 Moved Temporarily' + + response_headers = [('Content-type', 'text/plain'), + ('Content-Length', '0'), + ('Location', 'http://localhost/target/index.html')] + start_response(status, response_headers) + return [''] diff --git a/Regression/bz928307-follow-302-redirect/redir-absolute3.py b/Regression/bz928307-follow-302-redirect/redir-absolute3.py new file mode 100644 index 0000000..0465e6a --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/redir-absolute3.py @@ -0,0 +1,12 @@ +#!/usr/bin/python3 + +import sys + +def application(environ, start_response): + status = '302 Moved Temporarily' + + response_headers = [('Content-type', 'text/plain'), + ('Content-Length', '0'), + ('Location', 'http://localhost/target/index.html')] + start_response(status, response_headers) + return bytearray() diff --git a/Regression/bz928307-follow-302-redirect/redir-relative.py b/Regression/bz928307-follow-302-redirect/redir-relative.py new file mode 100644 index 0000000..1941d71 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/redir-relative.py @@ -0,0 +1,12 @@ +#!/usr/bin/python + +import sys + +def application(environ, start_response): + status = '302 Moved Temporarily' + + response_headers = [('Content-type', 'text/plain'), + ('Content-Length', '0'), + ('Location', '/target/index.html')] + start_response(status, response_headers) + return [''] diff --git a/Regression/bz928307-follow-302-redirect/redir-relative3.py b/Regression/bz928307-follow-302-redirect/redir-relative3.py new file mode 100644 index 0000000..a020168 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/redir-relative3.py @@ -0,0 +1,12 @@ +#!/usr/bin/python3 + +import sys + +def application(environ, start_response): + status = '302 Moved Temporarily' + + response_headers = [('Content-type', 'text/plain'), + ('Content-Length', '0'), + ('Location', '/target/index.html')] + start_response(status, response_headers) + return bytearray() diff --git a/Regression/bz928307-follow-302-redirect/runtest.sh b/Regression/bz928307-follow-302-redirect/runtest.sh new file mode 100755 index 0000000..8a0d6f6 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/runtest.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/lftp/Regression/bz928307-follow-302-redirect +# Description: Basic smoke test for mod_wsgi +# Author: Petr Splichal +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2010 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 rhts environment +. /usr/lib/beakerlib/beakerlib.sh + +PACKAGES=${PACKAGES:-lftp} +REQUIRES=${REQUIRES:-httpd mod_wsgi} + +rlJournalStart + rlPhaseStartSetup + rlRun "rlImport httpd/http" 0 "Importing httpd library" || rlDie + rlAssertRpm 'lftp' || rlDie "lftp not installed" + rlAssertRpm 'httpd' || rlDie "httpd not installed" + if rlIsRHEL '<=7'; then + rlAssertRpm 'mod_wsgi' || rlDie "mod_wsgi not installed" + else + rlAssertRpm 'python3-mod_wsgi' || rlDie "python3-mod_wsgi not installed" + fi + + if rlIsRHEL '<7'; then + WSGI_CONF="${httpCONFDIR}/conf.d/wsgi.conf" + else + CONF=$(ls ${httpCONFDIR}/conf.modules.d | grep 10-wsgi.*conf$) + if ! rlIsRHEL '<=7'; then + sed -i s/mod_wsgi.so/mod_wsgi_python3.so/ wsgi.conf + fi + WSGI_CONF="${httpCONFDIR}/conf.modules.d/$CONF" + fi + + rlRun "rlFileBackup --clean ${WSGI_CONF}" + rlRun "cp wsgi.conf ${WSGI_CONF}" 0 "Applying mod_wsgi configuration" + + rlRun "rlFileBackup --clean ${httpROOTDIR}" + rlRun "mkdir ${httpROOTDIR}/target" 0 "Creating test directory" + rlRun "touch ${httpROOTDIR}/target/{one,two,three,four,five}" + + WSGI_DIR="${httpROOTDIR}/wsgi-scripts" + rlRun "mkdir ${WSGI_DIR}" 0 "Creating WSGI script directory" + if rlIsRHEL '<=7'; then + rlRun "cp redir-absolute.py redir-relative.py ${WSGI_DIR}" 0 "Creating WSGI handlers" + else + rlRun "cp redir-absolute3.py ${WSGI_DIR}/redir-absolute.py" 0 "Creating WSGI handler redir-absolute.py" + rlRun "cp redir-relative3.py ${WSGI_DIR}/redir-relative.py" 0 "Creating WSGI handler redir-relative.py" + fi + rlRun "httpStart" 0 "Starting httpd" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + + # This test needs the `target' directory listing generated by + # mod_autoindex to be available in `index.html'. To accomplish this + # goal, we need to download http://localhost/target/ when index.html + # does not exist. Only after the directory listing has been downloaded + # can we store the result to `index.html' in the `target' directory. + rlRun "curl http://localhost/target/ > index.html" 0 "Generating directory index with mod_autoindex" + rlRun "cp index.html ${httpROOTDIR}/target" 0 "Copying it to server" + rlPhaseEnd + + # Try to use lftp's mirror functionality to download the contents of + # http://localhost/target/. There are two URLs which are redirected to this + # address (http://localhost/target/index.html, to be precise): + # + # http://localhost/absolute/ + # < HTTP 302 Moved Temporarily + # < Location: http://localhost/target/index.html + # + # http://localhost/relative/ + # < HTTP 302 Moved Temporarily + # < Location: /target/index.html + # + # Mirroring either of these two URLs should produce identical results, i.e. + # download the files mentioned in the directory listing. + for REDIR_TYPE in absolute relative; do + rlPhaseStartTest "Testing lftp mirror with $REDIR_TYPE redirect" + URL="http://localhost/${REDIR_TYPE}/" + rlRun -s "curl -vL ${URL}" 0 "Checking if requested URL is present" + rlAssertGrep '200 OK' $rlRun_LOG + rlRun "lftp -c 'mirror -c -I t* -I f* -X th* ${URL} .'" + rlAssertNotExists 'one' + rlAssertExists 'two' + rlAssertNotExists 'three' + rlAssertExists 'four' + rlAssertExists 'five' + rlRun "rm -f one two three four five" + rlPhaseEnd + done + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "httpStop" 0 "Stopping httpd" + rlRun "rlFileRestore" 0 "Restoring original configuration" + rlRun "rlServiceRestore $httpHTTPD" 0 "Restoring httpd service" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText diff --git a/Regression/bz928307-follow-302-redirect/wsgi.conf b/Regression/bz928307-follow-302-redirect/wsgi.conf new file mode 100644 index 0000000..502c8b1 --- /dev/null +++ b/Regression/bz928307-follow-302-redirect/wsgi.conf @@ -0,0 +1,4 @@ +LoadModule wsgi_module modules/mod_wsgi.so + +WSGIScriptAlias /relative/ /var/www/html/wsgi-scripts/redir-relative.py +WSGIScriptAlias /absolute/ /var/www/html/wsgi-scripts/redir-absolute.py