4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'native'
10 cat > aptarchive
/Sources
<<EOF
14 Maintainer: Joe Sixpack <joe@example.org>
17 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.dsc
18 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.tar.gz
20 Package: pkg-sha256-ok
23 Maintainer: Joe Sixpack <joe@example.org>
26 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.dsc
27 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.tar.gz
29 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.dsc
30 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.tar.gz
32 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.dsc
33 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.tar.gz
35 Package: pkg-sha256-bad
36 Binary: pkg-sha256-bad
38 Maintainer: Joe Sixpack <joe@example.org>
41 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.dsc
42 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.tar.gz
44 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.dsc
45 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.tar.gz
47 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-sha256-bad_1.0.dsc
48 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-sha256-bad_1.0.tar.gz
53 Maintainer: Joe Sixpack <joe@example.org>
56 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-no-md5_1.0.dsc
57 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-no-md5_1.0.tar.gz
59 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-no-md5_1.0.dsc
60 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-no-md5_1.0.tar.gz
65 Maintainer: Joe Sixpack <joe@example.org>
68 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-mixed-ok_1.0.tar.gz
70 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-mixed-ok_1.0.dsc
72 Package: pkg-mixed-sha1-bad
73 Binary: pkg-mixed-sha1-bad
75 Maintainer: Joe Sixpack <joe@example.org>
78 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-mixed-sha1-bad_1.0.dsc
80 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-mixed-sha1-bad_1.0.tar.gz
82 Package: pkg-mixed-sha2-bad
83 Binary: pkg-mixed-sha2-bad
85 Maintainer: Joe Sixpack <joe@example.org>
88 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-mixed-sha2-bad_1.0.dsc
90 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-mixed-sha2-bad_1.0.tar.gz
92 Package: pkg-md5-disagree
93 Binary: pkg-md5-disagree
95 Maintainer: Joe Sixpack <joe@example.org>
98 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-disagree_1.0.dsc
99 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-disagree_1.0.tar.gz
100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-md5-disagree_1.0.dsc
101 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-md5-disagree_1.0.tar.gz
103 Package: pkg-md5-agree
104 Binary: pkg-md5-agree
106 Maintainer: Joe Sixpack <joe@example.org>
109 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-agree_1.0.dsc
110 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-agree_1.0.tar.gz
111 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-agree_1.0.tar.gz
112 d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-agree_1.0.dsc
114 Package: pkg-sha256-disagree
115 Binary: pkg-sha256-disagree
117 Maintainer: Joe Sixpack <joe@example.org>
120 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-disagree_1.0.dsc
121 d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-disagree_1.0.tar.gz
123 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-disagree_1.0.dsc
124 da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-disagree_1.0.tar.gz
126 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-disagree_1.0.dsc
127 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-disagree_1.0.tar.gz
128 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-sha256-disagree_1.0.dsc
129 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-sha256-disagree_1.0.tar.gz
132 # create fetchable files
133 for x
in 'pkg-md5-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
134 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
135 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree'; do
136 touch aptarchive
/${x}_1.0.dsc aptarchive
/${x}_1.0.
tar.gz
141 testsuccess aptget update
144 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
145 testequal
"Reading package lists...
146 Building dependency tree...
147 Need to get 0 B of source archives.
148 Get:1 http://localhost:8080/ $1 1.0 (dsc)
149 Get:2 http://localhost:8080/ $1 1.0 (tar)
150 Download complete and in download only mode" aptget
source -d "$@"
151 msgtest
'Files were successfully downloaded for' "$1"
152 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
153 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
157 touch ${1}_1.0.dsc
${1}_1.0.
tar.gz
158 testequal
"Reading package lists...
159 Building dependency tree...
160 Skipping already downloaded file '${1}_1.0.dsc'
161 Skipping already downloaded file '${1}_1.0.tar.gz'
162 Need to get 0 B of source archives.
163 Download complete and in download only mode" aptget
source -d "$@"
164 msgtest
'Files already downloaded are kept for' "$1"
165 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
166 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
170 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
171 testequal
"Reading package lists...
172 Building dependency tree...
173 Need to get 0 B of source archives.
174 Get:1 http://localhost:8080/ $1 1.0 (dsc)
175 Get:2 http://localhost:8080/ $1 1.0 (tar)
176 E: Failed to fetch http://localhost:8080/${1}_1.0.dsc Hash Sum mismatch
178 E: Failed to fetch http://localhost:8080/${1}_1.0.tar.gz Hash Sum mismatch
180 E: Failed to fetch some archives." aptget
source -d "$@"
181 msgtest
'Files were not download as they have hashsum mismatches for' "$1"
182 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
184 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
185 testequal
"Reading package lists...
186 Building dependency tree...
187 Skipping download of file 'pkg-sha256-bad_1.0.dsc' as requested hashsum is not available for authentication
188 Skipping download of file 'pkg-sha256-bad_1.0.tar.gz' as requested hashsum is not available for authentication
189 Need to get 0 B of source archives.
190 Download complete and in download only mode" aptget
source -d "$@" -o Acquire
::ForceHash
=ROT26
191 msgtest
'Files were not download as hash is unavailable for' "$1"
192 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
194 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
195 testequal
"Reading package lists...
196 Building dependency tree...
197 Need to get 0 B of source archives.
198 Get:1 http://localhost:8080/ $1 1.0 (dsc)
199 Get:2 http://localhost:8080/ $1 1.0 (tar)
200 Download complete and in download only mode" aptget
source --allow-unauthenticated -d "$@" -o Acquire
::ForceHash
=ROT26
201 msgtest
'Files were downloaded unauthenticated as user allowed it' "$1"
202 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
208 testkeep pkg
-sha256-ok
210 # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
211 # checking the best available hash (as it should), this will trigger
213 testmismatch pkg
-sha256-bad
214 testmismatch pkg
-sha256-bad
215 testok pkg
-sha256-bad -o Acquire
::ForceHash
=MD5Sum
217 # not having MD5 sum doesn't mean the file doesn't exist at all …
219 testok pkg
-no-md5 -o Acquire
::ForceHash
=SHA256
220 testequal
"Reading package lists...
221 Building dependency tree...
222 Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
223 Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
224 Need to get 0 B of source archives.
225 Download complete and in download only mode" aptget
source -d pkg
-no-md5 -o Acquire
::ForceHash
=MD5Sum
226 msgtest
'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
227 testfailure
--nomsg test -e pkg
-no-md5_1.0.dsc
-a -e pkg
-no-md5_1.0.
tar.gz
229 # deal with cases in which we haven't for all files the same checksum type
230 # mostly pathologic as this shouldn't happen, but just to be sure
232 testequal
'Reading package lists...
233 Building dependency tree...
234 Need to get 0 B of source archives.
235 Get:1 http://localhost:8080/ pkg-mixed-sha1-bad 1.0 (tar)
236 Get:2 http://localhost:8080/ pkg-mixed-sha1-bad 1.0 (dsc)
237 E: Failed to fetch http://localhost:8080/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
239 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha1-bad
240 msgtest
'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
241 testsuccess
--nomsg test ! -e pkg
-mixed-sha1-bad_1.0.dsc
-a -e pkg
-mixed-sha1-bad_1.0.
tar.gz
242 testequal
'Reading package lists...
243 Building dependency tree...
244 Need to get 0 B of source archives.
245 Get:1 http://localhost:8080/ pkg-mixed-sha2-bad 1.0 (tar)
246 Get:2 http://localhost:8080/ pkg-mixed-sha2-bad 1.0 (dsc)
247 E: Failed to fetch http://localhost:8080/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
249 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha2-bad
250 msgtest
'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad'
251 testsuccess
--nomsg test -e pkg
-mixed-sha2-bad_1.0.dsc
-a ! -e pkg
-mixed-sha2-bad_1.0.
tar.gz
253 # it gets even more pathologic: multiple entries for one file, some even disagreeing!
255 testequal
'Reading package lists...
256 Building dependency tree...
257 E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget
source -d pkg
-md5-disagree
258 testequal
'Reading package lists...
259 Building dependency tree...
260 E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget
source -d pkg
-sha256-disagree