]>
Commit | Line | Data |
---|---|---|
1262d358 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
1262d358 DK |
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... |
895417ef | 159 | Need to get 6 B of source archives. |
6c0765c0 DK |
160 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
161 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] | |
1262d358 DK |
162 | Download complete and in download only mode" aptget source -d "$@" |
163 | msgtest 'Files were successfully downloaded for' "$1" | |
164 | testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
165 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
166 | } | |
167 | ||
168 | testkeep() { | |
895417ef DK |
169 | echo -n 'dsc' > ${1}_1.0.dsc |
170 | echo -n 'tar' > ${1}_1.0.tar.gz | |
25b86db1 | 171 | testsuccessequal "Reading package lists... |
1262d358 DK |
172 | Skipping already downloaded file '${1}_1.0.dsc' |
173 | Skipping already downloaded file '${1}_1.0.tar.gz' | |
174 | Need to get 0 B of source archives. | |
175 | Download complete and in download only mode" aptget source -d "$@" | |
176 | msgtest 'Files already downloaded are kept for' "$1" | |
177 | testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
178 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
179 | } | |
180 | ||
63d60998 DK |
181 | testnohash() { |
182 | #FIXME: Maybe we should fail in this case instead of skipping | |
183 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
184 | testsuccessequal "Reading package lists... | |
63d60998 DK |
185 | Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication |
186 | Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication | |
187 | Need to get 0 B of source archives. | |
188 | Download complete and in download only mode" aptget source -d "$@" | |
189 | msgtest 'Files are not downloaded for' "$1" | |
190 | testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz | |
191 | } | |
192 | ||
1262d358 DK |
193 | testmismatch() { |
194 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
25b86db1 | 195 | testfailureequal "Reading package lists... |
895417ef | 196 | Need to get 6 B of source archives. |
6c0765c0 DK |
197 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
198 | Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) | |
448c38bd | 199 | Hash Sum mismatch |
6c0765c0 DK |
200 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] |
201 | Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) | |
448c38bd | 202 | Hash Sum mismatch |
6c0765c0 | 203 | E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch |
1262d358 | 204 | |
6c0765c0 | 205 | E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch |
1262d358 DK |
206 | |
207 | E: Failed to fetch some archives." aptget source -d "$@" | |
208 | msgtest 'Files were not download as they have hashsum mismatches for' "$1" | |
209 | testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
210 | ||
63d60998 DK |
211 | if [ "$2" != '--allow-unauthenticated' ]; then |
212 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
213 | testsuccessequal "Reading package lists... | |
63d60998 DK |
214 | Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication |
215 | Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication | |
1262d358 DK |
216 | Need to get 0 B of source archives. |
217 | Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26 | |
63d60998 DK |
218 | msgtest 'Files were not download as hash is unavailable for' "$1" |
219 | testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
220 | fi | |
1262d358 DK |
221 | |
222 | rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz | |
25b86db1 | 223 | testsuccessequal "Reading package lists... |
895417ef | 224 | Need to get 6 B of source archives. |
6c0765c0 DK |
225 | Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B] |
226 | Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B] | |
1262d358 DK |
227 | Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26 |
228 | msgtest 'Files were downloaded unauthenticated as user allowed it' "$1" | |
229 | testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz | |
230 | } | |
231 | ||
63d60998 | 232 | testnohash pkg-md5-ok |
1262d358 DK |
233 | testok pkg-sha256-ok |
234 | testkeep pkg-sha256-ok | |
235 | ||
236 | # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is | |
237 | # checking the best available hash (as it should), this will trigger | |
238 | # a hash mismatch. | |
239 | testmismatch pkg-sha256-bad | |
1262d358 DK |
240 | testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum |
241 | ||
63d60998 DK |
242 | testnohash pkg-md5-bad |
243 | testmismatch pkg-md5-bad --allow-unauthenticated | |
244 | ||
1262d358 | 245 | # not having MD5 sum doesn't mean the file doesn't exist at all … |
63d60998 | 246 | testok pkg-no-md5 |
1262d358 | 247 | testok pkg-no-md5 -o Acquire::ForceHash=SHA256 |
25b86db1 | 248 | testsuccessequal "Reading package lists... |
1262d358 DK |
249 | Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication |
250 | Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication | |
251 | Need to get 0 B of source archives. | |
252 | Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum | |
253 | msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5' | |
254 | testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz | |
255 | ||
256 | # deal with cases in which we haven't for all files the same checksum type | |
257 | # mostly pathologic as this shouldn't happen, but just to be sure | |
258 | testok pkg-mixed-ok | |
6c0765c0 | 259 | testfailureequal "Reading package lists... |
895417ef | 260 | Need to get 6 B of source archives. |
6c0765c0 DK |
261 | Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B] |
262 | Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) [3 B] | |
263 | Err:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) | |
448c38bd | 264 | Hash Sum mismatch |
6c0765c0 | 265 | E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch |
1262d358 | 266 | |
6c0765c0 | 267 | E: Failed to fetch some archives." aptget source -d pkg-mixed-sha1-bad |
1262d358 DK |
268 | msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad' |
269 | testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz | |
6c0765c0 | 270 | testfailureequal "Reading package lists... |
895417ef | 271 | Need to get 6 B of source archives. |
6c0765c0 DK |
272 | Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B] |
273 | Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) | |
448c38bd | 274 | Hash Sum mismatch |
6c0765c0 DK |
275 | Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (dsc) [3 B] |
276 | E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch | |
1262d358 | 277 | |
6c0765c0 | 278 | E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad |
1262d358 DK |
279 | msgtest 'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad' |
280 | testsuccess --nomsg test -e pkg-mixed-sha2-bad_1.0.dsc -a ! -e pkg-mixed-sha2-bad_1.0.tar.gz | |
281 | ||
282 | # it gets even more pathologic: multiple entries for one file, some even disagreeing! | |
63d60998 | 283 | testnohash pkg-md5-agree |
25b86db1 | 284 | testfailureequal 'Reading package lists... |
1262d358 | 285 | E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree |
25b86db1 | 286 | testfailureequal 'Reading package lists... |
1262d358 | 287 | E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree |