summaryrefslogtreecommitdiff
path: root/test/integration/framework
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2013-09-30 16:41:16 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2013-10-01 11:17:02 +0200
commitfd46d30571eb240ec3aae792e7a56061ede50524 (patch)
treea22dd7c94bea0be6b97a92285669d75af156df80 /test/integration/framework
parent85050e764482197aad5daeeafd95ff6bf680afcb (diff)
handle complete responses to https range requests
Servers might respond with a complete file either because they don't support Ranges at all or the If-Range condition isn't statisfied, so we have to parse the headers curl gets ourself to seek or truncate the file we have so far. This also finially adds the testcase testing a bunch of partial situations for both, http and https - which is now all green. Closes: 617643, 667699 LP: 1157943
Diffstat (limited to 'test/integration/framework')
-rw-r--r--test/integration/framework92
1 files changed, 70 insertions, 22 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 4003d932c..a2bb871cc 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -795,6 +795,13 @@ signreleasefiles() {
msgdone "info"
}
+rewritesourceslist() {
+ local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
+ for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
+ sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
+ done
+}
+
changetowebserver() {
local LOG='/dev/null'
if test -x ${BUILDDIRECTORY}/aptwebserver; then
@@ -806,31 +813,32 @@ changetowebserver() {
fi
addtrap "kill $PID;"
cd - > /dev/null
- elif [ $# -gt 0 ]; then
- msgdie 'Need the aptwebserver when passing arguments for the webserver'
- elif which weborf > /dev/null; then
- weborf -xb aptarchive/ >$LOG 2>&1 &
- addtrap "kill $!;"
- elif which gatling > /dev/null; then
- cd aptarchive
- gatling -p 8080 -F -S >$LOG 2>&1 &
- addtrap "kill $!;"
- cd - > /dev/null
- elif which lighttpd > /dev/null; then
- echo "server.document-root = \"$(readlink -f ./aptarchive)\"
-server.port = 8080
-server.stat-cache-engine = \"disable\"" > lighttpd.conf
- lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid'
- lighttpd -D -f lighttpd.conf >$LOG 2>&1 &
- addtrap "kill $!;"
else
msgdie 'You have to build aptwerbserver or install a webserver'
fi
- local APTARCHIVE="file://$(readlink -f ./aptarchive)"
- for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
- sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
- done
- return 0
+ if [ "$1" != '--no-rewrite' ]; then
+ rewritesourceslist 'http://localhost:8080/'
+ fi
+}
+
+changetohttpswebserver() {
+ if ! which stunnel4 >/dev/null; then
+ msgdie 'You need to install stunnel4 for https testcases'
+ fi
+ if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
+ changetowebserver --no-rewrite
+ fi
+ echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
+cert = ${TESTDIRECTORY}/apt.pem
+
+[https]
+accept = 4433
+connect = 8080
+" > ${TMPWORKINGDIRECTORY}/stunnel.conf
+ stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
+ local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
+ addtrap 'prefix' "kill ${PID};"
+ rewritesourceslist 'https://localhost:4433/'
}
changetocdrom() {
@@ -848,6 +856,46 @@ changetocdrom() {
find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
}
+downloadfile() {
+ PROTO="$(echo "$1" | cut -d':' -f 1)"
+ local DOWNLOG="${TMPWORKINGDIRECTORY}/download.log"
+ rm -f "$DOWNLOG"
+ touch "$DOWNLOG"
+ {
+ echo "601 Configuration
+Config-Item: Acquire::https::CaInfo=${TESTDIR}/apt.pem
+Config-Item: Debug::Acquire::${PROTO}=1
+
+600 Acquire URI
+URI: $1
+Filename: ${2}
+"
+ # simple worker keeping stdin open until we are done (201) or error (400)
+ # and requesting new URIs on try-agains/redirects inbetween
+ { tail -n 999 -f "$DOWNLOG" & echo "TAILPID: $!"; } | while read f1 f2; do
+ if [ "$f1" = 'TAILPID:' ]; then
+ TAILPID="$f2"
+ elif [ "$f1" = 'New-URI:' ]; then
+ echo "600 Acquire URI
+URI: $f2
+Filename: ${2}
+"
+ elif [ "$f1" = '201' ] || [ "$f1" = '400' ]; then
+ # tail would only die on next read – which never happens
+ test -z "$TAILPID" || kill -s HUP "$TAILPID"
+ break
+ fi
+ done
+ } | LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods/${PROTO} 2>&1 | tee "$DOWNLOG"
+ rm "$DOWNLOG"
+ # only if the file exists the download was successful
+ if [ -e "$2" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
checkdiff() {
local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
if [ -n "$DIFFTEXT" ]; then