summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/framework6
-rwxr-xr-xtest/integration/test-apt-helper24
-rwxr-xr-xtest/integration/test-partial-file-support62
3 files changed, 72 insertions, 20 deletions
diff --git a/test/integration/framework b/test/integration/framework
index df1942ff9..ac482a7a0 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -1064,8 +1064,8 @@ acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom
}
downloadfile() {
- local PROTO="$(echo "$1" | cut -d':' -f 1 )"
- apthelper -o Debug::Acquire::${PROTO}=1 \
+ local PROTO="${1%%:*}"
+ apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \
download-file "$1" "$2" 2>&1 || true
# only if the file exists the download was successful
if [ -e "$2" ]; then
@@ -1221,7 +1221,7 @@ testsuccess() {
msgtest 'Test for successful execution of' "$*"
fi
local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
- if $@ >${OUTPUT} 2>&1; then
+ if "$@" >${OUTPUT} 2>&1; then
msgpass
else
echo >&2
diff --git a/test/integration/test-apt-helper b/test/integration/test-apt-helper
index c749224ca..31e471677 100755
--- a/test/integration/test-apt-helper
+++ b/test/integration/test-apt-helper
@@ -10,34 +10,36 @@ configarchitecture "i386"
changetohttpswebserver
test_apt_helper_download() {
- echo "foo" > aptarchive/foo
+ echo 'foo' > aptarchive/foo
+ echo 'bar' > aptarchive/foo2
msgtest 'apt-file download-file md5sum'
- apthelper -qq download-file http://localhost:8080/foo foo2 MD5Sum:d3b07384d113edec49eaa6238ad5ff00 && msgpass || msgfail
+ testsuccess --nomsg apthelper download-file http://localhost:8080/foo foo2 MD5Sum:d3b07384d113edec49eaa6238ad5ff00
testfileequal foo2 'foo'
msgtest 'apt-file download-file sha1'
- apthelper -qq download-file http://localhost:8080/foo foo1 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 && msgpass || msgfail
+ testsuccess --nomsg apthelper download-file http://localhost:8080/foo foo1 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
testfileequal foo1 'foo'
msgtest 'apt-file download-file sha256'
- apthelper -qq download-file http://localhost:8080/foo foo3 SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c && msgpass || msgfail
+ testsuccess --nomsg apthelper download-file http://localhost:8080/foo foo3 SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
testfileequal foo3 'foo'
msgtest 'apt-file download-file no-hash'
- apthelper -qq download-file http://localhost:8080/foo foo4 && msgpass || msgfail
+ testsuccess --nomsg apthelper download-file http://localhost:8080/foo foo4
testfileequal foo4 'foo'
msgtest 'apt-file download-file wrong hash'
- if ! apthelper -qq download-file http://localhost:8080/foo foo5 MD5Sum:aabbcc 2>&1 2> download.stderr; then
- msgpass
- else
- msgfail
- fi
- testfileequal download.stderr 'E: Failed to fetch http://localhost:8080/foo Hash Sum mismatch
+ testfailure --nomsg apthelper -qq download-file http://localhost:8080/foo foo5 MD5Sum:aabbcc
+ testfileequal rootdir/tmp/testfailure.output 'E: Failed to fetch http://localhost:8080/foo Hash Sum mismatch
E: Download Failed'
testfileequal foo5.FAILED 'foo'
+
+ msgtest 'apt-file download-file md5sum sha1'
+ testsuccess --nomsg apthelper download-file http://localhost:8080/foo foo6 MD5Sum:d3b07384d113edec49eaa6238ad5ff00 http://localhost:8080/foo2 foo7 SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f
+ testfileequal foo6 'foo'
+ testfileequal foo7 'bar'
}
test_apt_helper_detect_proxy() {
diff --git a/test/integration/test-partial-file-support b/test/integration/test-partial-file-support
index 5ab326def..160d451b6 100755
--- a/test/integration/test-partial-file-support
+++ b/test/integration/test-partial-file-support
@@ -24,13 +24,25 @@ testdownloadfile() {
else
msgpass
fi
- cat "$DOWNLOADLOG" | while read field hash; do
+ sed -e '/^ <- / s#%20# #g' -e '/^ <- / s#%0a#\n#g' "$DOWNLOADLOG" | grep '^.*-Hash: ' > receivedhashes.log
+ testsuccess test -s receivedhashes.log
+ local HASHES_OK=0
+ local HASHES_BAD=0
+ while read field hash; do
local EXPECTED
case "$field" in
'MD5Sum-Hash:') EXPECTED="$(md5sum "$TESTFILE" | cut -d' ' -f 1)";;
'SHA1-Hash:') EXPECTED="$(sha1sum "$TESTFILE" | cut -d' ' -f 1)";;
'SHA256-Hash:') EXPECTED="$(sha256sum "$TESTFILE" | cut -d' ' -f 1)";;
'SHA512-Hash:') EXPECTED="$(sha512sum "$TESTFILE" | cut -d' ' -f 1)";;
+ 'Checksum-FileSize-Hash:')
+ #filesize is too weak to check for !=
+ if [ "$4" = '=' ]; then
+ EXPECTED="$(stat -c '%s' "$TESTFILE")"
+ else
+ continue
+ fi
+ ;;
*) continue;;
esac
if [ "$4" = '=' ]; then
@@ -40,15 +52,41 @@ testdownloadfile() {
fi
if [ "$EXPECTED" "$4" "$hash" ]; then
msgpass
+ HASHES_OK=$((HASHES_OK+1));
else
- cat >&2 "$DOWNLOADLOG"
msgfail "expected: $EXPECTED ; got: $hash"
+ HASHES_BAD=$((HASHES_BAD+1));
fi
- done
+ done < receivedhashes.log
+ msgtest 'At least one good hash and no bad ones'
+ if [ $HASHES_OK -eq 0 ] || [ $HASHES_BAD -ne 0 ]; then
+ cat >&2 "$DOWNLOADLOG"
+ msgfail
+ else
+ msgpass
+ fi
}
TESTFILE='aptarchive/testfile'
cp -a ${TESTDIR}/framework $TESTFILE
+cp -a ${TESTDIR}/framework "${TESTFILE}2"
+
+followuprequest() {
+ local DOWN='./testfile'
+
+ copysource $TESTFILE 1M $DOWN
+ testdownloadfile 'completely downloaded file' "${1}/testfile" "$DOWN" '='
+ testwebserverlaststatuscode '416' "$DOWNLOADLOG"
+
+ copysource $TESTFILE 1M $DOWN
+ copysource "${TESTFILE}2" 20 "${DOWN}2"
+ msgtest 'Testing download of files with' 'completely downloaded file + partial file'
+ testsuccess --nomsg apthelper -o Debug::Acquire::${1%%:*}=1 -o Debug::pkgAcquire::Worker=1 \
+ download-file "$1/testfile" "$DOWN" '' "$1/testfile2" "${DOWN}2"
+ testwebserverlaststatuscode '206' 'rootdir/tmp/testsuccess.output'
+ testsuccess diff -u "$TESTFILE" "${DOWN}"
+ testsuccess diff -u "${DOWN}" "${DOWN}2"
+}
testrun() {
webserverconfig 'aptwebserver::support::range' 'true'
@@ -65,9 +103,11 @@ testrun() {
testdownloadfile 'invalid partial data' "${1}/testfile" './testfile' '!='
testwebserverlaststatuscode '206' "$DOWNLOADLOG"
- copysource $TESTFILE 1M ./testfile
- testdownloadfile 'completely downloaded file' "${1}/testfile" './testfile' '='
- testwebserverlaststatuscode '416' "$DOWNLOADLOG"
+ webserverconfig 'aptwebserver::closeOnError' 'false'
+ followuprequest "$1"
+ webserverconfig 'aptwebserver::closeOnError' 'true'
+ followuprequest "$1"
+ webserverconfig 'aptwebserver::closeOnError' 'false'
copysource /dev/zero 1M ./testfile
testdownloadfile 'too-big partial file' "${1}/testfile" './testfile' '='
@@ -85,8 +125,18 @@ testrun() {
testwebserverlaststatuscode '200' "$DOWNLOADLOG"
}
+msgmsg 'http: Test with Content-Length'
+webserverconfig 'aptwebserver::chunked-transfer-encoding' 'false'
+testrun 'http://localhost:8080'
+msgmsg 'http: Test with Transfer-Encoding: chunked'
+webserverconfig 'aptwebserver::chunked-transfer-encoding' 'true'
testrun 'http://localhost:8080'
changetohttpswebserver
+msgmsg 'https: Test with Content-Length'
+webserverconfig 'aptwebserver::chunked-transfer-encoding' 'false'
+testrun 'https://localhost:4433'
+msgmsg 'https: Test with Transfer-Encoding: chunked'
+webserverconfig 'aptwebserver::chunked-transfer-encoding' 'true'
testrun 'https://localhost:4433'