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