]>
Commit | Line | Data |
---|---|---|
1262d358 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture 'native' | |
9 | ||
10 | cat > aptarchive/Sources <<EOF | |
11 | Package: pkg-md5-ok | |
12 | Binary: pkg-md5-ok | |
13 | Version: 1.0 | |
14 | Maintainer: Joe Sixpack <joe@example.org> | |
15 | Architecture: all | |
16 | Files: | |
895417ef DK |
17 | 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc |
18 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz | |
1262d358 DK |
19 | |
20 | Package: pkg-sha256-ok | |
21 | Binary: pkg-sha256-ok | |
22 | Version: 1.0 | |
23 | Maintainer: Joe Sixpack <joe@example.org> | |
24 | Architecture: all | |
25 | Files: | |
895417ef DK |
26 | 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc |
27 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz | |
1262d358 | 28 | Checksums-Sha1: |
895417ef DK |
29 | 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc |
30 | 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz | |
1262d358 | 31 | Checksums-Sha256: |
895417ef DK |
32 | 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc |
33 | 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz | |
1262d358 DK |
34 | |
35 | Package: pkg-sha256-bad | |
36 | Binary: pkg-sha256-bad | |
37 | Version: 1.0 | |
38 | Maintainer: Joe Sixpack <joe@example.org> | |
39 | Architecture: all | |
40 | Files: | |
895417ef DK |
41 | 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc |
42 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz | |
1262d358 | 43 | Checksums-Sha1: |
895417ef DK |
44 | 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc |
45 | 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz | |
1262d358 | 46 | Checksums-Sha256: |
895417ef DK |
47 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc |
48 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz | |
1262d358 | 49 | |
63d60998 DK |
50 | Package: pkg-md5-bad |
51 | Binary: pkg-md5-bad | |
52 | Version: 1.0 | |
53 | Maintainer: Joe Sixpack <joe@example.org> | |
54 | Architecture: all | |
55 | Files: | |
56 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc | |
57 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz | |
58 | ||
1262d358 DK |
59 | Package: pkg-no-md5 |
60 | Binary: pkg-no-md5 | |
61 | Version: 1.0 | |
62 | Maintainer: Joe Sixpack <joe@example.org> | |
63 | Architecture: all | |
64 | Checksums-Sha1: | |
895417ef DK |
65 | 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc |
66 | 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz | |
1262d358 | 67 | Checksums-Sha256: |
895417ef DK |
68 | 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc |
69 | 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz | |
1262d358 DK |
70 | |
71 | Package: pkg-mixed-ok | |
72 | Binary: pkg-mixed-ok | |
73 | Version: 1.0 | |
74 | Maintainer: Joe Sixpack <joe@example.org> | |
75 | Architecture: all | |
76 | Checksums-Sha1: | |
895417ef | 77 | 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz |
1262d358 | 78 | Checksums-Sha256: |
895417ef | 79 | 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc |
1262d358 DK |
80 | |
81 | Package: pkg-mixed-sha1-bad | |
82 | Binary: pkg-mixed-sha1-bad | |
83 | Version: 1.0 | |
84 | Maintainer: Joe Sixpack <joe@example.org> | |
85 | Architecture: all | |
86 | Checksums-Sha1: | |
895417ef | 87 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc |
1262d358 | 88 | Checksums-Sha256: |
895417ef | 89 | 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz |
1262d358 DK |
90 | |
91 | Package: pkg-mixed-sha2-bad | |
92 | Binary: pkg-mixed-sha2-bad | |
93 | Version: 1.0 | |
94 | Maintainer: Joe Sixpack <joe@example.org> | |
95 | Architecture: all | |
96 | Checksums-Sha1: | |
895417ef | 97 | 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc |
1262d358 | 98 | Checksums-Sha256: |
895417ef | 99 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz |
1262d358 DK |
100 | |
101 | Package: pkg-md5-disagree | |
102 | Binary: pkg-md5-disagree | |
103 | Version: 1.0 | |
104 | Maintainer: Joe Sixpack <joe@example.org> | |
105 | Architecture: all | |
106 | Files: | |
895417ef DK |
107 | 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc |
108 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz | |
109 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc | |
110 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz | |
1262d358 DK |
111 | |
112 | Package: pkg-md5-agree | |
113 | Binary: pkg-md5-agree | |
114 | Version: 1.0 | |
115 | Maintainer: Joe Sixpack <joe@example.org> | |
116 | Architecture: all | |
117 | Files: | |
895417ef DK |
118 | 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc |
119 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz | |
120 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz | |
121 | 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc | |
1262d358 DK |
122 | |
123 | Package: pkg-sha256-disagree | |
124 | Binary: pkg-sha256-disagree | |
125 | Version: 1.0 | |
126 | Maintainer: Joe Sixpack <joe@example.org> | |
127 | Architecture: all | |
128 | Files: | |
895417ef DK |
129 | 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc |
130 | db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz | |
1262d358 | 131 | Checksums-Sha1: |
895417ef DK |
132 | 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc |
133 | 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz | |
1262d358 | 134 | Checksums-Sha256: |
895417ef DK |
135 | 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc |
136 | 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz | |
137 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc | |
138 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz | |
1262d358 DK |
139 | EOF |
140 | ||
141 | # create fetchable files | |
142 | for x in 'pkg-md5-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \ | |
143 | 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \ | |
63d60998 DK |
144 | 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree' \ |
145 | 'pkg-md5-bad'; do | |
895417ef DK |
146 | echo -n 'dsc' > aptarchive/${x}_1.0.dsc |
147 | echo -n 'tar' > aptarchive/${x}_1.0.tar.gz | |
1262d358 DK |
148 | done |
149 | ||
63d60998 | 150 | setupaptarchive --no-update |
1262d358 DK |
151 | changetowebserver |
152 | testsuccess aptget update | |
153 | ||
03aa0847 DK |
154 | cd downloaded |
155 | ||
1262d358 DK |
156 | testok() { |
157 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
25b86db1 | 158 | testsuccessequal "Reading package lists... |
1262d358 | 159 | Building dependency tree... |
895417ef | 160 | Need to get 6 B of source archives. |
6c0765c0 DK |
161 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
162 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] | |
1262d358 DK |
163 | Download complete and in download only mode" aptget source -d "$@" |
164 | msgtest 'Files were successfully downloaded 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 | |
167 | } | |
168 | ||
169 | testkeep() { | |
895417ef DK |
170 | echo -n 'dsc' > ${1}_1.0.dsc |
171 | echo -n 'tar' > ${1}_1.0.tar.gz | |
25b86db1 | 172 | testsuccessequal "Reading package lists... |
1262d358 DK |
173 | Building dependency tree... |
174 | Skipping already downloaded file '${1}_1.0.dsc' | |
175 | Skipping already downloaded file '${1}_1.0.tar.gz' | |
176 | Need to get 0 B of source archives. | |
177 | Download complete and in download only mode" aptget source -d "$@" | |
178 | msgtest 'Files already downloaded are kept for' "$1" | |
179 | testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
180 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
181 | } | |
182 | ||
63d60998 DK |
183 | testnohash() { |
184 | #FIXME: Maybe we should fail in this case instead of skipping | |
185 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
186 | testsuccessequal "Reading package lists... | |
187 | Building dependency tree... | |
188 | Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication | |
189 | Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication | |
190 | Need to get 0 B of source archives. | |
191 | Download complete and in download only mode" aptget source -d "$@" | |
192 | msgtest 'Files are not downloaded for' "$1" | |
193 | testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz | |
194 | } | |
195 | ||
1262d358 DK |
196 | testmismatch() { |
197 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
25b86db1 | 198 | testfailureequal "Reading package lists... |
1262d358 | 199 | Building dependency tree... |
895417ef | 200 | Need to get 6 B of source archives. |
6c0765c0 DK |
201 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
202 | Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) | |
448c38bd | 203 | Hash Sum mismatch |
6c0765c0 DK |
204 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] |
205 | Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) | |
448c38bd | 206 | Hash Sum mismatch |
6c0765c0 | 207 | E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch |
1262d358 | 208 | |
6c0765c0 | 209 | E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch |
1262d358 DK |
210 | |
211 | E: Failed to fetch some archives." aptget source -d "$@" | |
212 | msgtest 'Files were not download as they have hashsum mismatches for' "$1" | |
213 | testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
214 | ||
63d60998 DK |
215 | if [ "$2" != '--allow-unauthenticated' ]; then |
216 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
217 | testsuccessequal "Reading package lists... | |
1262d358 | 218 | Building dependency tree... |
63d60998 DK |
219 | Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication |
220 | Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication | |
1262d358 DK |
221 | Need to get 0 B of source archives. |
222 | Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26 | |
63d60998 DK |
223 | msgtest 'Files were not download as hash is unavailable for' "$1" |
224 | testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
225 | fi | |
1262d358 DK |
226 | |
227 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
25b86db1 | 228 | testsuccessequal "Reading package lists... |
1262d358 | 229 | Building dependency tree... |
895417ef | 230 | Need to get 6 B of source archives. |
6c0765c0 DK |
231 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
232 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] | |
1262d358 DK |
233 | Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26 |
234 | msgtest 'Files were downloaded unauthenticated as user allowed it' "$1" | |
235 | testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
236 | } | |
237 | ||
63d60998 | 238 | testnohash pkg-md5-ok |
1262d358 DK |
239 | testok pkg-sha256-ok |
240 | testkeep pkg-sha256-ok | |
241 | ||
242 | # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is | |
243 | # checking the best available hash (as it should), this will trigger | |
244 | # a hash mismatch. | |
245 | testmismatch pkg-sha256-bad | |
1262d358 DK |
246 | testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum |
247 | ||
63d60998 DK |
248 | testnohash pkg-md5-bad |
249 | testmismatch pkg-md5-bad --allow-unauthenticated | |
250 | ||
1262d358 | 251 | # not having MD5 sum doesn't mean the file doesn't exist at all … |
63d60998 | 252 | testok pkg-no-md5 |
1262d358 | 253 | testok pkg-no-md5 -o Acquire::ForceHash=SHA256 |
25b86db1 | 254 | testsuccessequal "Reading package lists... |
1262d358 DK |
255 | Building dependency tree... |
256 | Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication | |
257 | Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication | |
258 | Need to get 0 B of source archives. | |
259 | Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum | |
260 | msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5' | |
261 | testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz | |
262 | ||
263 | # deal with cases in which we haven't for all files the same checksum type | |
264 | # mostly pathologic as this shouldn't happen, but just to be sure | |
265 | testok pkg-mixed-ok | |
6c0765c0 | 266 | testfailureequal "Reading package lists... |
1262d358 | 267 | Building dependency tree... |
895417ef | 268 | Need to get 6 B of source archives. |
6c0765c0 DK |
269 | Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B] |
270 | Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) [3 B] | |
271 | Err:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) | |
448c38bd | 272 | Hash Sum mismatch |
6c0765c0 | 273 | E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch |
1262d358 | 274 | |
6c0765c0 | 275 | E: Failed to fetch some archives." aptget source -d pkg-mixed-sha1-bad |
1262d358 DK |
276 | msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad' |
277 | testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz | |
6c0765c0 | 278 | testfailureequal "Reading package lists... |
1262d358 | 279 | Building dependency tree... |
895417ef | 280 | Need to get 6 B of source archives. |
6c0765c0 DK |
281 | Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B] |
282 | Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) | |
448c38bd | 283 | Hash Sum mismatch |
6c0765c0 DK |
284 | Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (dsc) [3 B] |
285 | E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch | |
1262d358 | 286 | |
6c0765c0 | 287 | E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad |
1262d358 DK |
288 | msgtest 'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad' |
289 | testsuccess --nomsg test -e pkg-mixed-sha2-bad_1.0.dsc -a ! -e pkg-mixed-sha2-bad_1.0.tar.gz | |
290 | ||
291 | # it gets even more pathologic: multiple entries for one file, some even disagreeing! | |
63d60998 | 292 | testnohash pkg-md5-agree |
25b86db1 | 293 | testfailureequal 'Reading package lists... |
1262d358 DK |
294 | Building dependency tree... |
295 | E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree | |
25b86db1 | 296 | testfailureequal 'Reading package lists... |
1262d358 DK |
297 | Building dependency tree... |
298 | E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree |