]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
test: Get rid of debhelper rules.tiny example dep
[apt.git] / test / integration / test-ubuntu-bug-1098738-apt-get-source-md5sum
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8configarchitecture 'native'
9
10cat > aptarchive/Sources <<EOF
11Package: pkg-md5-ok
12Binary: pkg-md5-ok
13Version: 1.0
14Maintainer: Joe Sixpack <joe@example.org>
15Architecture: all
16Files:
17 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc
18 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz
19
20Package: pkg-sha1-ok
21Binary: pkg-sha1-ok
22Version: 1.0
23Maintainer: Joe Sixpack <joe@example.org>
24Architecture: all
25Files:
26 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha1-ok_1.0.dsc
27 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha1-ok_1.0.tar.gz
28
29Package: pkg-sha256-ok
30Binary: pkg-sha256-ok
31Version: 1.0
32Maintainer: Joe Sixpack <joe@example.org>
33Architecture: all
34Files:
35 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc
36 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz
37Checksums-Sha1:
38 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc
39 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz
40Checksums-Sha256:
41 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc
42 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz
43
44Package: pkg-size-bad
45Binary: pkg-size-bad
46Version: 1.0
47Maintainer: Joe Sixpack <joe@example.org>
48Architecture: all
49Checksums-Sha256:
50 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 2 pkg-size-bad_1.0.dsc
51 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 4 pkg-size-bad_1.0.tar.gz
52
53Package: pkg-sha256-bad
54Binary: pkg-sha256-bad
55Version: 1.0
56Maintainer: Joe Sixpack <joe@example.org>
57Architecture: all
58Files:
59 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc
60 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz
61Checksums-Sha1:
62 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc
63 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz
64Checksums-Sha256:
65 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc
66 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz
67
68Package: pkg-md5-bad
69Binary: pkg-md5-bad
70Version: 1.0
71Maintainer: Joe Sixpack <joe@example.org>
72Architecture: all
73Files:
74 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc
75 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz
76
77Package: pkg-no-md5
78Binary: pkg-no-md5
79Version: 1.0
80Maintainer: Joe Sixpack <joe@example.org>
81Architecture: all
82Checksums-Sha1:
83 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
84 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
85Checksums-Sha256:
86 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
87 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
88
89Package: pkg-mixed-ok
90Binary: pkg-mixed-ok
91Version: 1.0
92Maintainer: Joe Sixpack <joe@example.org>
93Architecture: all
94Checksums-Sha1:
95 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
96Checksums-Sha256:
97 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
98
99Package: pkg-mixed-sha1-bad
100Binary: pkg-mixed-sha1-bad
101Version: 1.0
102Maintainer: Joe Sixpack <joe@example.org>
103Architecture: all
104Checksums-Sha1:
105 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
106Checksums-Sha256:
107 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
108
109Package: pkg-mixed-sha2-bad
110Binary: pkg-mixed-sha2-bad
111Version: 1.0
112Maintainer: Joe Sixpack <joe@example.org>
113Architecture: all
114Checksums-Sha1:
115 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
116Checksums-Sha256:
117 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
118
119Package: pkg-md5-disagree
120Binary: pkg-md5-disagree
121Version: 1.0
122Maintainer: Joe Sixpack <joe@example.org>
123Architecture: all
124Files:
125 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc
126 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz
127 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc
128 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz
129
130Package: pkg-md5-agree
131Binary: pkg-md5-agree
132Version: 1.0
133Maintainer: Joe Sixpack <joe@example.org>
134Architecture: all
135Files:
136 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
137 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
138 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
139 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
140
141Package: pkg-sha256-disagree
142Binary: pkg-sha256-disagree
143Version: 1.0
144Maintainer: Joe Sixpack <joe@example.org>
145Architecture: all
146Files:
147 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
148 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
149Checksums-Sha1:
150 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
151 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
152Checksums-Sha256:
153 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc
154 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz
155 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc
156 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz
157EOF
158
159# create fetchable files
160for x in 'pkg-md5-ok' 'pkg-sha1-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
161 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
162 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree' \
163 'pkg-md5-bad' 'pkg-size-bad'; do
164 echo -n 'dsc' > aptarchive/${x}_1.0.dsc
165 echo -n 'tar' > aptarchive/${x}_1.0.tar.gz
166done
167
168setupaptarchive --no-update
169changetowebserver
170testsuccess aptget update
171
172cd downloaded
173
174testok() {
175 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
176 testsuccessequal "Reading package lists...
177Need to get 6 B of source archives.
178Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
179Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
180Download complete and in download only mode" aptget source -d "$@"
181 msgtest 'Files were successfully downloaded for' "$1"
182 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
183 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
184}
185
186testkeep() {
187 echo -n 'dsc' > ${1}_1.0.dsc
188 echo -n 'tar' > ${1}_1.0.tar.gz
189 testsuccessequal "Reading package lists...
190Skipping already downloaded file '${1}_1.0.dsc'
191Skipping already downloaded file '${1}_1.0.tar.gz'
192Need to get 0 B of source archives.
193Download complete and in download only mode" aptget source -d "$@"
194 msgtest 'Files already downloaded are kept for' "$1"
195 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
196 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
197}
198
199testnohash() {
200 #FIXME: Maybe we should fail in this case instead of skipping
201 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
202 testsuccessequal "Reading package lists...
203Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
204Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
205Need to get 0 B of source archives.
206Download complete and in download only mode" aptget source -d "$@"
207 msgtest 'Files are not downloaded for' "$1"
208 testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz
209}
210
211testmismatch() {
212 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
213 local FAILURE
214 if [ "$1" = 'pkg-size-bad' ]; then
215 FAILURE="Reading package lists...
216Need to get 6 B of source archives.
217Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [2 B]
218Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
219 Writing more data than expected (3 > 2)
220 Hashes of expected file:
221 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
222 - Checksum-FileSize:2 [weak]
223Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [4 B]
224Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
225 Hash Sum mismatch
226 Hashes of expected file:
227 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
228 - Checksum-FileSize:4 [weak]
229 Hashes of received file:
230 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
231 - Checksum-FileSize:3 [weak]
232 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
233E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Writing more data than expected (3 > 2)
234 Hashes of expected file:
235 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
236 - Checksum-FileSize:2 [weak]
237E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
238 Hashes of expected file:
239 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
240 - Checksum-FileSize:4 [weak]
241 Hashes of received file:
242 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
243 - Checksum-FileSize:3 [weak]
244 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
245E: Failed to fetch some archives."
246 elif [ "$1" = 'pkg-md5-bad' ]; then
247 FAILURE="Reading package lists...
248Need to get 6 B of source archives.
249Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
250Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
251 Hash Sum mismatch
252 Hashes of expected file:
253 - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
254 - Checksum-FileSize:3 [weak]
255 Hashes of received file:
256 - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
257 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
258 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
259 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
260 - Checksum-FileSize:3 [weak]
261 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
262Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
263Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
264 Hash Sum mismatch
265 Hashes of expected file:
266 - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
267 - Checksum-FileSize:3 [weak]
268 Hashes of received file:
269 - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
270 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
271 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
272 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
273 - Checksum-FileSize:3 [weak]
274 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
275E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
276 Hashes of expected file:
277 - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
278 - Checksum-FileSize:3 [weak]
279 Hashes of received file:
280 - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
281 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
282 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
283 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
284 - Checksum-FileSize:3 [weak]
285 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
286E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
287 Hashes of expected file:
288 - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
289 - Checksum-FileSize:3 [weak]
290 Hashes of received file:
291 - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
292 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
293 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
294 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
295 - Checksum-FileSize:3 [weak]
296 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
297E: Failed to fetch some archives."
298 else
299 FAILURE="Reading package lists...
300Need to get 6 B of source archives.
301Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
302Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
303 Hash Sum mismatch
304 Hashes of expected file:
305 - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
306 - Checksum-FileSize:3 [weak]
307 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
308 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
309 Hashes of received file:
310 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
311 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
312 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
313 - Checksum-FileSize:3 [weak]
314 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
315Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
316Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
317 Hash Sum mismatch
318 Hashes of expected file:
319 - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
320 - Checksum-FileSize:3 [weak]
321 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
322 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
323 Hashes of received file:
324 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
325 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
326 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
327 - Checksum-FileSize:3 [weak]
328 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
329E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
330 Hashes of expected file:
331 - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
332 - Checksum-FileSize:3 [weak]
333 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
334 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
335 Hashes of received file:
336 - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
337 - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
338 - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
339 - Checksum-FileSize:3 [weak]
340 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
341E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
342 Hashes of expected file:
343 - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
344 - Checksum-FileSize:3 [weak]
345 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
346 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
347 Hashes of received file:
348 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
349 - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
350 - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
351 - Checksum-FileSize:3 [weak]
352 Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
353E: Failed to fetch some archives."
354 fi
355 testfailureequal "$FAILURE" aptget source -d "$@"
356 msgtest 'Files were not download as they have hashsum mismatches for' "$1"
357 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
358
359 if [ "$2" != '--allow-unauthenticated' ]; then
360 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
361 testsuccessequal "Reading package lists...
362Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
363Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
364Need to get 0 B of source archives.
365Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26
366 msgtest 'Files were not download as hash is unavailable for' "$1"
367 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
368 fi
369
370 if [ "$1" != 'pkg-size-bad' ]; then
371 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
372 testsuccessequal "Reading package lists...
373Need to get 6 B of source archives.
374Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
375Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
376Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26
377 msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
378 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
379 fi
380}
381
382testnohash pkg-md5-ok
383testnohash pkg-sha1-ok
384testok pkg-sha256-ok
385testkeep pkg-sha256-ok
386
387# pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
388# checking the best available hash (as it should), this will trigger
389# a hash mismatch.
390testmismatch pkg-sha256-bad
391testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum
392
393testnohash pkg-md5-bad
394testmismatch pkg-md5-bad --allow-unauthenticated
395
396testmismatch pkg-size-bad
397
398# not having MD5 sum doesn't mean the file doesn't exist at all …
399testok pkg-no-md5
400testok pkg-no-md5 -o Acquire::ForceHash=SHA256
401testsuccessequal "Reading package lists...
402Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
403Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
404Need to get 0 B of source archives.
405Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum
406msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
407testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
408
409# deal with cases in which we haven't for all files the same checksum type
410# mostly pathologic as this shouldn't happen, but just to be sure
411testsuccessequal "Reading package lists...
412Skipping download of file 'pkg-mixed-ok_1.0.tar.gz' as requested hashsum is not available for authentication
413Need to get 3 B of source archives.
414Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-ok 1.0 (dsc) [3 B]
415Download complete and in download only mode" aptget source -d pkg-mixed-ok
416
417testsuccessequal "Reading package lists...
418Skipping download of file 'pkg-mixed-sha1-bad_1.0.dsc' as requested hashsum is not available for authentication
419Need to get 3 B of source archives.
420Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B]
421Download complete and in download only mode" aptget source -d pkg-mixed-sha1-bad
422msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
423testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
424testfailureequal "Reading package lists...
425Skipping download of file 'pkg-mixed-sha2-bad_1.0.dsc' as requested hashsum is not available for authentication
426Need to get 3 B of source archives.
427Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B]
428Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar)
429 Hash Sum mismatch
430 Hashes of expected file:
431 - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
432 - Checksum-FileSize:3 [weak]
433 Hashes of received file:
434 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
435 - Checksum-FileSize:3 [weak]
436 Last modification reported: $(lastmodification 'aptarchive/pkg-mixed-sha2-bad_1.0.tar.gz')
437E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
438 Hashes of expected file:
439 - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
440 - Checksum-FileSize:3 [weak]
441 Hashes of received file:
442 - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
443 - Checksum-FileSize:3 [weak]
444 Last modification reported: $(lastmodification 'aptarchive/pkg-mixed-sha2-bad_1.0.tar.gz')
445E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad
446
447# it gets even more pathologic: multiple entries for one file, some even disagreeing!
448testnohash pkg-md5-agree
449testfailureequal 'Reading package lists...
450E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree
451testfailureequal 'Reading package lists...
452E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree