]> git.saurik.com Git - apt.git/blobdiff - test/integration/test-partial-file-support
keep Release.gpg on untrusted to trusted IMS-Hit
[apt.git] / test / integration / test-partial-file-support
index 85046b3eb92616369d45ace64cf5c671ebda0988..9b5eed1e540fa50dd01b6d18579e16370b11da09 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/sh
 set -e
 
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
 setupenvironment
 configarchitecture 'amd64'
 
@@ -17,8 +17,8 @@ DOWNLOADLOG='rootdir/tmp/testdownloadfile.log'
 
 testdownloadfile() {
        rm -f "$DOWNLOADLOG"
-       msgtest "Testing download of file $2 with" "$1"
-       if ! downloadfile "$2" "$3" > "$DOWNLOADLOG"; then
+       msgtest "Testing download of file $2 with" "$1 $5"
+       if ! downloadfile "$2" "$3" "$5" > "$DOWNLOADLOG"; then
                cat >&2 "$DOWNLOADLOG"
                msgfail
        else
@@ -68,8 +68,8 @@ testdownloadfile() {
 }
 
 TESTFILE='aptarchive/testfile'
-cp -a ${TESTDIR}/framework $TESTFILE
-cp -a ${TESTDIR}/framework "${TESTFILE}2"
+cp -a "${TESTDIR}/framework" "$TESTFILE"
+cp -a "${TESTDIR}/framework" "${TESTFILE}2"
 
 followuprequest() {
        local DOWN='./downloaded/testfile'
@@ -78,6 +78,12 @@ followuprequest() {
        testdownloadfile 'completely downloaded file' "${1}/testfile" "$DOWN" '='
        testwebserverlaststatuscode '416' "$DOWNLOADLOG"
 
+       webserverconfig 'aptwebserver::support::content-range' 'false'
+       copysource $TESTFILE 1M $DOWN
+       testdownloadfile 'completely downloaded file' "${1}/testfile" "$DOWN" '=' "SHA256:$(sha256sum "$TESTFILE" | cut -d' ' -f 1)"
+       testwebserverlaststatuscode '416' "$DOWNLOADLOG"
+       webserverconfig 'aptwebserver::support::content-range' 'true'
+
        copysource $TESTFILE 1M $DOWN
        copysource "${TESTFILE}2" 20 "${DOWN}2"
        msgtest 'Testing download of files with' 'completely downloaded file + partial file'
@@ -90,6 +96,7 @@ followuprequest() {
 
 testrun() {
        webserverconfig 'aptwebserver::support::range' 'true'
+       webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'bytes'
        local DOWN='./downloaded/testfile'
 
        copysource $TESTFILE 0 $DOWN
@@ -119,7 +126,11 @@ testrun() {
        testdownloadfile 'old data' "${1}/testfile" "$DOWN" '='
        testwebserverlaststatuscode '200' "$DOWNLOADLOG"
 
-       webserverconfig 'aptwebserver::support::range' 'false'
+       if [ "${1%%:*}" = 'https' ] && expr match "$1" "^.*/redirectme$" >/dev/null; then
+               webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'none'
+       else
+               webserverconfig 'aptwebserver::support::range' 'false'
+       fi
 
        copysource $TESTFILE 20 $DOWN
        testdownloadfile 'no server support' "${1}/testfile" "$DOWN" '='
@@ -135,8 +146,12 @@ serverconfigs() {
        testrun "$1"
 }
 
-serverconfigs 'http://localhost:8080'
+serverconfigs "http://localhost:${APTHTTPPORT}"
 
 changetohttpswebserver
 
-serverconfigs 'https://localhost:4433'
+serverconfigs "https://localhost:${APTHTTPSPORT}"
+
+webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "https://localhost:${APTHTTPSPORT}/"
+serverconfigs "https://localhost:${APTHTTPSPORT}/redirectme"
+serverconfigs "http://localhost:${APTHTTPPORT}/redirectme"