4 TESTDIR
=$(readlink -f $(dirname $0))
7 configarchitecture
'amd64'
12 dd if="$1" bs
=1 count
="$2" of
="$3" 2>/dev
/null
13 touch -d "$(stat --format '%y' "${TESTFILE}")" "$3"
16 DOWNLOADLOG
='rootdir/tmp/testdownloadfile.log'
20 msgtest
"Testing download of file $2 with" "$1"
21 if ! downloadfile
"$2" "$3" > "$DOWNLOADLOG"; then
22 cat >&2 "$DOWNLOADLOG"
27 cat "$DOWNLOADLOG" | while read field
hash; do
30 'MD5Sum-Hash:') EXPECTED
="$(md5sum "$TESTFILE" | cut -d' ' -f 1)";;
31 'SHA1-Hash:') EXPECTED
="$(sha1sum "$TESTFILE" | cut -d' ' -f 1)";;
32 'SHA256-Hash:') EXPECTED
="$(sha256sum "$TESTFILE" | cut -d' ' -f 1)";;
33 'SHA512-Hash:') EXPECTED
="$(sha512sum "$TESTFILE" | cut -d' ' -f 1)";;
36 if [ "$4" = '=' ]; then
37 msgtest
'Test downloaded file for correct' "$field"
39 msgtest
'Test downloaded file does not match in' "$field"
41 if [ "$EXPECTED" "$4" "$hash" ]; then
44 cat >&2 "$DOWNLOADLOG"
45 msgfail
"expected: $EXPECTED ; got: $hash"
50 TESTFILE
='aptarchive/testfile'
51 cp -a ${TESTDIR}/framework
$TESTFILE
54 webserverconfig
'aptwebserver::support::range' 'true'
55 local DOWN
='./downloaded/testfile'
57 copysource
$TESTFILE 0 $DOWN
58 testdownloadfile
'no data' "${1}/testfile" "$DOWN" '='
59 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
61 copysource
$TESTFILE 20 $DOWN
62 testdownloadfile
'valid partial data' "${1}/testfile" "$DOWN" '='
63 testwebserverlaststatuscode
'206' "$DOWNLOADLOG"
65 copysource
/dev
/zero
20 $DOWN
66 testdownloadfile
'invalid partial data' "${1}/testfile" "$DOWN" '!='
67 testwebserverlaststatuscode
'206' "$DOWNLOADLOG"
69 copysource
$TESTFILE 1M
$DOWN
70 testdownloadfile
'completely downloaded file' "${1}/testfile" "$DOWN" '='
71 testwebserverlaststatuscode
'416' "$DOWNLOADLOG"
73 copysource
/dev
/zero
1M
$DOWN
74 testdownloadfile
'too-big partial file' "${1}/testfile" "$DOWN" '='
75 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
77 copysource
/dev
/zero
20 $DOWN
79 testdownloadfile
'old data' "${1}/testfile" "$DOWN" '='
80 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
82 webserverconfig
'aptwebserver::support::range' 'false'
84 copysource
$TESTFILE 20 $DOWN
85 testdownloadfile
'no server support' "${1}/testfile" "$DOWN" '='
86 testwebserverlaststatuscode
'200' "$DOWNLOADLOG"
89 testrun
'http://localhost:8080'
91 changetohttpswebserver
93 testrun
'https://localhost:4433'