]>
Commit | Line | Data |
---|---|---|
3a2b39ee 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: | |
17 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.dsc | |
18 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-md5-ok_1.0.tar.gz | |
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: | |
26 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.dsc | |
27 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-ok_1.0.tar.gz | |
28 | Checksums-Sha1: | |
29 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.dsc | |
30 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-ok_1.0.tar.gz | |
31 | Checksums-Sha256: | |
32 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.dsc | |
33 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-sha256-ok_1.0.tar.gz | |
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: | |
41 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.dsc | |
42 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-bad_1.0.tar.gz | |
43 | Checksums-Sha1: | |
44 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.dsc | |
45 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-bad_1.0.tar.gz | |
46 | Checksums-Sha256: | |
47 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-sha256-bad_1.0.dsc | |
48 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-sha256-bad_1.0.tar.gz | |
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: | |
56 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-no-md5_1.0.dsc | |
57 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-no-md5_1.0.tar.gz | |
58 | Checksums-Sha256: | |
59 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-no-md5_1.0.dsc | |
60 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-no-md5_1.0.tar.gz | |
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: | |
68 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-mixed-ok_1.0.tar.gz | |
69 | Checksums-Sha256: | |
70 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-mixed-ok_1.0.dsc | |
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: | |
78 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 0 pkg-mixed-sha1-bad_1.0.dsc | |
79 | Checksums-Sha256: | |
80 | e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 pkg-mixed-sha1-bad_1.0.tar.gz | |
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: | |
88 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-mixed-sha2-bad_1.0.dsc | |
89 | Checksums-Sha256: | |
90 | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 pkg-mixed-sha2-bad_1.0.tar.gz | |
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: | |
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 | |
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: | |
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 | |
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: | |
120 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-disagree_1.0.dsc | |
121 | d41d8cd98f00b204e9800998ecf8427e 0 pkg-sha256-disagree_1.0.tar.gz | |
122 | Checksums-Sha1: | |
123 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-disagree_1.0.dsc | |
124 | da39a3ee5e6b4b0d3255bfef95601890afd80709 0 pkg-sha256-disagree_1.0.tar.gz | |
125 | Checksums-Sha256: | |
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 | |
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 | |
136 | touch aptarchive/${x}_1.0.dsc aptarchive/${x}_1.0.tar.gz | |
137 | done | |
138 | ||
139 | setupaptarchive | |
140 | changetowebserver | |
141 | testsuccess aptget update | |
142 | ||
143 | testok() { | |
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 | |
154 | } | |
155 | ||
156 | testkeep() { | |
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 | |
167 | } | |
168 | ||
169 | testmismatch() { | |
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 | |
177 | ||
178 | E: Failed to fetch http://localhost:8080/${1}_1.0.tar.gz Hash Sum mismatch | |
179 | ||
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 | |
183 | ||
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 | |
193 | ||
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 | |
203 | } | |
204 | ||
205 | testok pkg-md5-ok | |
206 | testkeep pkg-md5-ok | |
207 | testok pkg-sha256-ok | |
208 | testkeep pkg-sha256-ok | |
209 | ||
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 | |
212 | # a hash mismatch. | |
213 | testmismatch pkg-sha256-bad | |
214 | testmismatch pkg-sha256-bad | |
215 | testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum | |
216 | ||
217 | # not having MD5 sum doesn't mean the file doesn't exist at all … | |
218 | testok pkg-no-md5 | |
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 | |
228 | ||
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 | |
231 | testok pkg-mixed-ok | |
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 | |
238 | ||
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 | |
248 | ||
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 | |
252 | ||
253 | # it gets even more pathologic: multiple entries for one file, some even disagreeing! | |
254 | testok pkg-md5-agree | |
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 |