4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'native'
10 cat > aptarchive/Sources <<EOF
14 Maintainer: Joe Sixpack <joe@example.org>
17 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc
18 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz
23 Maintainer: Joe Sixpack <joe@example.org>
26 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha1-ok_1.0.dsc
27 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha1-ok_1.0.tar.gz
29 Package: pkg-sha256-ok
32 Maintainer: Joe Sixpack <joe@example.org>
35 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc
36 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz
38 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc
39 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz
41 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc
42 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz
44 Package: pkg-sha256-bad
45 Binary: pkg-sha256-bad
47 Maintainer: Joe Sixpack <joe@example.org>
50 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc
51 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz
53 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc
54 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz
56 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc
57 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz
62 Maintainer: Joe Sixpack <joe@example.org>
65 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc
66 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz
71 Maintainer: Joe Sixpack <joe@example.org>
74 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
75 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
77 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
78 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
83 Maintainer: Joe Sixpack <joe@example.org>
86 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
88 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
90 Package: pkg-mixed-sha1-bad
91 Binary: pkg-mixed-sha1-bad
93 Maintainer: Joe Sixpack <joe@example.org>
96 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
98 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
100 Package: pkg-mixed-sha2-bad
101 Binary: pkg-mixed-sha2-bad
103 Maintainer: Joe Sixpack <joe@example.org>
106 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
108 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
110 Package: pkg-md5-disagree
111 Binary: pkg-md5-disagree
113 Maintainer: Joe Sixpack <joe@example.org>
116 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc
117 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz
118 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc
119 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz
121 Package: pkg-md5-agree
122 Binary: pkg-md5-agree
124 Maintainer: Joe Sixpack <joe@example.org>
127 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
128 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
129 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
130 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
132 Package: pkg-sha256-disagree
133 Binary: pkg-sha256-disagree
135 Maintainer: Joe Sixpack <joe@example.org>
138 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
139 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
141 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
142 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
144 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc
145 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz
146 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc
147 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz
150 # create fetchable files
151 for x in 'pkg-md5-ok' 'pkg-sha1-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
152 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
153 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree' \
155 echo -n 'dsc' > aptarchive/${x}_1.0.dsc
156 echo -n 'tar' > aptarchive/${x}_1.0.tar.gz
159 setupaptarchive --no-update
161 testsuccess aptget update
166 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
167 testsuccessequal "Reading package lists...
168 Need to get
6 B of
source archives.
169 Get
:1 http
://localhost
:${APTHTTPPORT} $1 1.0 (dsc
) [3 B
]
170 Get
:2 http
://localhost
:${APTHTTPPORT} $1 1.0 (tar) [3 B
]
171 Download complete and
in download only mode
" aptget source -d "$@
"
172 msgtest 'Files were successfully downloaded for' "$1"
173 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
174 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
178 echo -n 'dsc' > ${1}_1.0.dsc
179 echo -n 'tar' > ${1}_1.0.tar.gz
180 testsuccessequal "Reading package lists...
181 Skipping already downloaded
file '${1}_1.0.dsc'
182 Skipping already downloaded
file '${1}_1.0.tar.gz'
183 Need to get
0 B of
source archives.
184 Download complete and
in download only mode
" aptget source -d "$@
"
185 msgtest 'Files already downloaded are kept for' "$1"
186 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
187 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
191 #FIXME: Maybe we should fail in this case instead of skipping
192 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
193 testsuccessequal "Reading package lists...
194 Skipping download of
file '${1}_1.0.dsc' as requested hashsum is not available
for authentication
195 Skipping download of
file '${1}_1.0.tar.gz' as requested hashsum is not available
for authentication
196 Need to get
0 B of
source archives.
197 Download complete and
in download only mode
" aptget source -d "$@
"
198 msgtest 'Files are not downloaded for' "$1"
199 testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz
203 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
204 testfailureequal "Reading package lists...
205 Need to get
6 B of
source archives.
206 Get
:1 http
://localhost
:${APTHTTPPORT} $1 1.0 (dsc
) [3 B
]
207 Err
:1 http
://localhost
:${APTHTTPPORT} $1 1.0 (dsc
)
209 Get
:2 http
://localhost
:${APTHTTPPORT} $1 1.0 (tar) [3 B
]
210 Err
:2 http
://localhost
:${APTHTTPPORT} $1 1.0 (tar)
212 E
: Failed to fetch http
://localhost
:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
214 E
: Failed to fetch http
://localhost
:${APTHTTPPORT}/${1}_1.0.
tar.gz Hash Sum mismatch
216 E
: Failed to fetch some archives.
" aptget source -d "$@
"
217 msgtest 'Files were not download as they have hashsum mismatches for' "$1"
218 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
220 if [ "$2" != '--allow-unauthenticated' ]; then
221 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
222 testsuccessequal "Reading package lists...
223 Skipping download of
file '${1}_1.0.dsc' as requested hashsum is not available
for authentication
224 Skipping download of
file '${1}_1.0.tar.gz' as requested hashsum is not available
for authentication
225 Need to get
0 B of
source archives.
226 Download complete and
in download only mode
" aptget source -d "$@
" -o Acquire::ForceHash=ROT26
227 msgtest 'Files were not download as hash is unavailable for' "$1"
228 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
231 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
232 testsuccessequal "Reading package lists...
233 Need to get
6 B of
source archives.
234 Get
:1 http
://localhost
:${APTHTTPPORT} $1 1.0 (dsc
) [3 B
]
235 Get
:2 http
://localhost
:${APTHTTPPORT} $1 1.0 (tar) [3 B
]
236 Download complete and
in download only mode
" aptget source --allow-unauthenticated -d "$@
" -o Acquire::ForceHash=ROT26
237 msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
238 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
241 testnohash pkg-md5-ok
242 testnohash pkg-sha1-ok
244 testkeep pkg-sha256-ok
246 # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
247 # checking the best available hash (as it should), this will trigger
249 testmismatch pkg-sha256-bad
250 testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum
252 testnohash pkg-md5-bad
253 testmismatch pkg-md5-bad --allow-unauthenticated
255 # not having MD5 sum doesn't mean the file doesn't exist at all …
257 testok pkg-no-md5 -o Acquire::ForceHash=SHA256
258 testsuccessequal "Reading package lists...
259 Skipping download of
file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available
for authentication
260 Skipping download of
file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available
for authentication
261 Need to get
0 B of
source archives.
262 Download complete and
in download only mode
" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum
263 msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
264 testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
266 # deal with cases in which we haven't for all files the same checksum type
267 # mostly pathologic as this shouldn't happen, but just to be sure
268 testsuccessequal "Reading package lists...
269 Skipping download of
file 'pkg-mixed-ok_1.0.tar.gz' as requested hashsum is not available
for authentication
270 Need to get
3 B of
source archives.
271 Get
:1 http
://localhost
:${APTHTTPPORT} pkg
-mixed-ok 1.0 (dsc
) [3 B
]
272 Download complete and
in download only mode
" aptget source -d pkg-mixed-ok
274 testsuccessequal "Reading package lists...
275 Skipping download of
file 'pkg-mixed-sha1-bad_1.0.dsc' as requested hashsum is not available
for authentication
276 Need to get
3 B of
source archives.
277 Get
:1 http
://localhost
:${APTHTTPPORT} pkg
-mixed-sha1-bad 1.0 (tar) [3 B
]
278 Download complete and
in download only mode
" aptget source -d pkg-mixed-sha1-bad
279 msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
280 testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
281 testfailureequal "Reading package lists...
282 Skipping download of
file 'pkg-mixed-sha2-bad_1.0.dsc' as requested hashsum is not available
for authentication
283 Need to get
3 B of
source archives.
284 Get
:1 http
://localhost
:${APTHTTPPORT} pkg
-mixed-sha2-bad 1.0 (tar) [3 B
]
285 Err
:1 http
://localhost
:${APTHTTPPORT} pkg
-mixed-sha2-bad 1.0 (tar)
287 E
: Failed to fetch http
://localhost
:${APTHTTPPORT}/pkg
-mixed-sha2-bad_1.0.
tar.gz Hash Sum mismatch
289 E
: Failed to fetch some archives.
" aptget source -d pkg-mixed-sha2-bad
291 # it gets even more pathologic: multiple entries for one file, some even disagreeing!
292 testnohash pkg-md5-agree
293 testfailureequal 'Reading package lists...
294 E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree
295 testfailureequal 'Reading package lists...
296 E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree