test-ubuntu-bug-1098738-apt-get-source-md5sum 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'native'
  7. cat > aptarchive/Sources <<EOF
  8. Package: pkg-md5-ok
  9. Binary: pkg-md5-ok
  10. Version: 1.0
  11. Maintainer: Joe Sixpack <joe@example.org>
  12. Architecture: all
  13. Files:
  14. 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc
  15. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz
  16. Package: pkg-sha1-ok
  17. Binary: pkg-sha1-ok
  18. Version: 1.0
  19. Maintainer: Joe Sixpack <joe@example.org>
  20. Architecture: all
  21. Files:
  22. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha1-ok_1.0.dsc
  23. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha1-ok_1.0.tar.gz
  24. Package: pkg-sha256-ok
  25. Binary: pkg-sha256-ok
  26. Version: 1.0
  27. Maintainer: Joe Sixpack <joe@example.org>
  28. Architecture: all
  29. Files:
  30. 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc
  31. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz
  32. Checksums-Sha1:
  33. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc
  34. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz
  35. Checksums-Sha256:
  36. 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc
  37. 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz
  38. Package: pkg-size-bad
  39. Binary: pkg-size-bad
  40. Version: 1.0
  41. Maintainer: Joe Sixpack <joe@example.org>
  42. Architecture: all
  43. Checksums-Sha256:
  44. 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 2 pkg-size-bad_1.0.dsc
  45. 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 4 pkg-size-bad_1.0.tar.gz
  46. Package: pkg-sha256-bad
  47. Binary: pkg-sha256-bad
  48. Version: 1.0
  49. Maintainer: Joe Sixpack <joe@example.org>
  50. Architecture: all
  51. Files:
  52. 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc
  53. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz
  54. Checksums-Sha1:
  55. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc
  56. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz
  57. Checksums-Sha256:
  58. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc
  59. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz
  60. Package: pkg-md5-bad
  61. Binary: pkg-md5-bad
  62. Version: 1.0
  63. Maintainer: Joe Sixpack <joe@example.org>
  64. Architecture: all
  65. Files:
  66. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc
  67. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz
  68. Package: pkg-no-md5
  69. Binary: pkg-no-md5
  70. Version: 1.0
  71. Maintainer: Joe Sixpack <joe@example.org>
  72. Architecture: all
  73. Checksums-Sha1:
  74. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
  75. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
  76. Checksums-Sha256:
  77. 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
  78. 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
  79. Package: pkg-mixed-ok
  80. Binary: pkg-mixed-ok
  81. Version: 1.0
  82. Maintainer: Joe Sixpack <joe@example.org>
  83. Architecture: all
  84. Checksums-Sha1:
  85. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
  86. Checksums-Sha256:
  87. 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
  88. Package: pkg-mixed-sha1-bad
  89. Binary: pkg-mixed-sha1-bad
  90. Version: 1.0
  91. Maintainer: Joe Sixpack <joe@example.org>
  92. Architecture: all
  93. Checksums-Sha1:
  94. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
  95. Checksums-Sha256:
  96. 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
  97. Package: pkg-mixed-sha2-bad
  98. Binary: pkg-mixed-sha2-bad
  99. Version: 1.0
  100. Maintainer: Joe Sixpack <joe@example.org>
  101. Architecture: all
  102. Checksums-Sha1:
  103. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
  104. Checksums-Sha256:
  105. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
  106. Package: pkg-md5-disagree
  107. Binary: pkg-md5-disagree
  108. Version: 1.0
  109. Maintainer: Joe Sixpack <joe@example.org>
  110. Architecture: all
  111. Files:
  112. 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc
  113. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz
  114. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc
  115. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz
  116. Package: pkg-md5-agree
  117. Binary: pkg-md5-agree
  118. Version: 1.0
  119. Maintainer: Joe Sixpack <joe@example.org>
  120. Architecture: all
  121. Files:
  122. 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
  123. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
  124. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
  125. 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
  126. Package: pkg-sha256-disagree
  127. Binary: pkg-sha256-disagree
  128. Version: 1.0
  129. Maintainer: Joe Sixpack <joe@example.org>
  130. Architecture: all
  131. Files:
  132. 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
  133. db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
  134. Checksums-Sha1:
  135. 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
  136. 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
  137. Checksums-Sha256:
  138. 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc
  139. 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz
  140. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc
  141. bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz
  142. EOF
  143. # create fetchable files
  144. for x in 'pkg-md5-ok' 'pkg-sha1-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
  145. 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
  146. 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree' \
  147. 'pkg-md5-bad' 'pkg-size-bad'; do
  148. echo -n 'dsc' > aptarchive/${x}_1.0.dsc
  149. echo -n 'tar' > aptarchive/${x}_1.0.tar.gz
  150. done
  151. setupaptarchive --no-update
  152. changetowebserver
  153. testsuccess aptget update
  154. cd downloaded
  155. testok() {
  156. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  157. testsuccessequal "Reading package lists...
  158. Need to get 6 B of source archives.
  159. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  160. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  161. Download complete and in download only mode" aptget source -d "$@"
  162. msgtest 'Files were successfully downloaded for' "$1"
  163. testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  164. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  165. }
  166. testkeep() {
  167. echo -n 'dsc' > ${1}_1.0.dsc
  168. echo -n 'tar' > ${1}_1.0.tar.gz
  169. testsuccessequal "Reading package lists...
  170. Skipping already downloaded file '${1}_1.0.dsc'
  171. Skipping already downloaded file '${1}_1.0.tar.gz'
  172. Need to get 0 B of source archives.
  173. Download complete and in download only mode" aptget source -d "$@"
  174. msgtest 'Files already downloaded are kept for' "$1"
  175. testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  176. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  177. }
  178. testnohash() {
  179. #FIXME: Maybe we should fail in this case instead of skipping
  180. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  181. testsuccessequal "Reading package lists...
  182. Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
  183. Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
  184. Need to get 0 B of source archives.
  185. Download complete and in download only mode" aptget source -d "$@"
  186. msgtest 'Files are not downloaded for' "$1"
  187. testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz
  188. }
  189. testmismatch() {
  190. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  191. local FAILURE
  192. if [ "$1" = 'pkg-size-bad' ]; then
  193. FAILURE="Reading package lists...
  194. Need to get 6 B of source archives.
  195. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [2 B]
  196. Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
  197. Writing more data than expected (3 > 2)
  198. Hashes of expected file:
  199. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  200. - Filesize:2 [weak]
  201. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [4 B]
  202. Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
  203. Hash Sum mismatch
  204. Hashes of expected file:
  205. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  206. - Filesize:4 [weak]
  207. Hashes of received file:
  208. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  209. - Filesize:3 [weak]
  210. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  211. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Writing more data than expected (3 > 2)
  212. Hashes of expected file:
  213. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  214. - Filesize:2 [weak]
  215. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
  216. Hashes of expected file:
  217. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  218. - Filesize:4 [weak]
  219. Hashes of received file:
  220. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  221. - Filesize:3 [weak]
  222. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  223. E: Failed to fetch some archives."
  224. elif [ "$1" = 'pkg-md5-bad' ]; then
  225. FAILURE="Reading package lists...
  226. Need to get 6 B of source archives.
  227. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  228. Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
  229. Hash Sum mismatch
  230. Hashes of expected file:
  231. - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
  232. - Filesize:3 [weak]
  233. Hashes of received file:
  234. - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
  235. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  236. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  237. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  238. - Filesize:3 [weak]
  239. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  240. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  241. Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
  242. Hash Sum mismatch
  243. Hashes of expected file:
  244. - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
  245. - Filesize:3 [weak]
  246. Hashes of received file:
  247. - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
  248. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  249. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  250. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  251. - Filesize:3 [weak]
  252. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  253. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
  254. Hashes of expected file:
  255. - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
  256. - Filesize:3 [weak]
  257. Hashes of received file:
  258. - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
  259. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  260. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  261. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  262. - Filesize:3 [weak]
  263. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  264. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
  265. Hashes of expected file:
  266. - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
  267. - Filesize:3 [weak]
  268. Hashes of received file:
  269. - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
  270. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  271. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  272. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  273. - Filesize:3 [weak]
  274. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  275. E: Failed to fetch some archives."
  276. else
  277. FAILURE="Reading package lists...
  278. Need to get 6 B of source archives.
  279. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  280. Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
  281. Hash Sum mismatch
  282. Hashes of expected file:
  283. - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  284. - Filesize:3 [weak]
  285. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  286. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  287. Hashes of received file:
  288. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  289. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  290. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  291. - Filesize:3 [weak]
  292. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  293. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  294. Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
  295. Hash Sum mismatch
  296. Hashes of expected file:
  297. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  298. - Filesize:3 [weak]
  299. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  300. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  301. Hashes of received file:
  302. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  303. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  304. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  305. - Filesize:3 [weak]
  306. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  307. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
  308. Hashes of expected file:
  309. - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  310. - Filesize:3 [weak]
  311. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  312. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  313. Hashes of received file:
  314. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  315. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  316. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  317. - Filesize:3 [weak]
  318. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  319. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
  320. Hashes of expected file:
  321. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  322. - Filesize:3 [weak]
  323. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  324. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  325. Hashes of received file:
  326. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  327. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  328. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  329. - Filesize:3 [weak]
  330. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  331. E: Failed to fetch some archives."
  332. fi
  333. testfailureequal "$FAILURE" aptget source -d "$@"
  334. msgtest 'Files were not download as they have hashsum mismatches for' "$1"
  335. testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  336. if [ "$2" != '--allow-unauthenticated' ]; then
  337. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  338. testsuccessequal "Reading package lists...
  339. Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
  340. Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
  341. Need to get 0 B of source archives.
  342. Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26
  343. msgtest 'Files were not download as hash is unavailable for' "$1"
  344. testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  345. fi
  346. if [ "$1" != 'pkg-size-bad' ]; then
  347. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  348. testsuccessequal "Reading package lists...
  349. Need to get 6 B of source archives.
  350. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  351. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  352. Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26
  353. msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
  354. testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  355. fi
  356. }
  357. testnohash pkg-md5-ok
  358. testnohash pkg-sha1-ok
  359. testok pkg-sha256-ok
  360. testkeep pkg-sha256-ok
  361. # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
  362. # checking the best available hash (as it should), this will trigger
  363. # a hash mismatch.
  364. testmismatch pkg-sha256-bad
  365. testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum
  366. testnohash pkg-md5-bad
  367. testmismatch pkg-md5-bad --allow-unauthenticated
  368. testmismatch pkg-size-bad
  369. # not having MD5 sum doesn't mean the file doesn't exist at all …
  370. testok pkg-no-md5
  371. testok pkg-no-md5 -o Acquire::ForceHash=SHA256
  372. testsuccessequal "Reading package lists...
  373. Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
  374. Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
  375. Need to get 0 B of source archives.
  376. Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum
  377. msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
  378. testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
  379. # deal with cases in which we haven't for all files the same checksum type
  380. # mostly pathologic as this shouldn't happen, but just to be sure
  381. testsuccessequal "Reading package lists...
  382. Skipping download of file 'pkg-mixed-ok_1.0.tar.gz' as requested hashsum is not available for authentication
  383. Need to get 3 B of source archives.
  384. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-ok 1.0 (dsc) [3 B]
  385. Download complete and in download only mode" aptget source -d pkg-mixed-ok
  386. testsuccessequal "Reading package lists...
  387. Skipping download of file 'pkg-mixed-sha1-bad_1.0.dsc' as requested hashsum is not available for authentication
  388. Need to get 3 B of source archives.
  389. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B]
  390. Download complete and in download only mode" aptget source -d pkg-mixed-sha1-bad
  391. msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
  392. testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
  393. testfailureequal "Reading package lists...
  394. Skipping download of file 'pkg-mixed-sha2-bad_1.0.dsc' as requested hashsum is not available for authentication
  395. Need to get 3 B of source archives.
  396. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B]
  397. Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar)
  398. Hash Sum mismatch
  399. Hashes of expected file:
  400. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  401. - Filesize:3 [weak]
  402. Hashes of received file:
  403. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  404. - Filesize:3 [weak]
  405. Last modification reported: $(lastmodification 'aptarchive/pkg-mixed-sha2-bad_1.0.tar.gz')
  406. E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
  407. Hashes of expected file:
  408. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  409. - Filesize:3 [weak]
  410. Hashes of received file:
  411. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  412. - Filesize:3 [weak]
  413. Last modification reported: $(lastmodification 'aptarchive/pkg-mixed-sha2-bad_1.0.tar.gz')
  414. E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad
  415. # it gets even more pathologic: multiple entries for one file, some even disagreeing!
  416. testnohash pkg-md5-agree
  417. testfailureequal 'Reading package lists...
  418. E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree
  419. testfailureequal 'Reading package lists...
  420. E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree