You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

445 lines
19 KiB

  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. File has unexpected size (3 != 2). Mirror sync in progress?
  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. File has unexpected size (3 != 4). Mirror sync in progress?
  204. Hashes of expected file:
  205. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  206. - Filesize:4 [weak]
  207. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc File has unexpected size (3 != 2). Mirror sync in progress?
  208. Hashes of expected file:
  209. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  210. - Filesize:2 [weak]
  211. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz File has unexpected size (3 != 4). Mirror sync in progress?
  212. Hashes of expected file:
  213. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  214. - Filesize:4 [weak]
  215. E: Failed to fetch some archives."
  216. elif [ "$1" = 'pkg-md5-bad' ]; then
  217. FAILURE="Reading package lists...
  218. Need to get 6 B of source archives.
  219. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  220. Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
  221. Hash Sum mismatch
  222. Hashes of expected file:
  223. - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
  224. - Filesize:3 [weak]
  225. Hashes of received file:
  226. - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
  227. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  228. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  229. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  230. - Filesize:3 [weak]
  231. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  232. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  233. Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
  234. Hash Sum mismatch
  235. Hashes of expected file:
  236. - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
  237. - Filesize:3 [weak]
  238. Hashes of received file:
  239. - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
  240. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  241. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  242. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  243. - Filesize:3 [weak]
  244. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  245. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
  246. Hashes of expected file:
  247. - MD5Sum:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [weak]
  248. - Filesize:3 [weak]
  249. Hashes of received file:
  250. - SHA512:e52b7bb395ea3f46974f1f65b7c5975839aad32d4e2ec0f458f735d5aa24d2bf36d7816ed1e01dc3c493e11879e9a8f66dfca42821608cfe993996929a6be18a
  251. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  252. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  253. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  254. - Filesize:3 [weak]
  255. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  256. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
  257. Hashes of expected file:
  258. - MD5Sum:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb [weak]
  259. - Filesize:3 [weak]
  260. Hashes of received file:
  261. - SHA512:5aa4cad81553320574eb72ee92bd45a1f0575528e257749dff298b2a33df9e7fc7f5c1c87fc1c8fde230f1234cca3a99bf8625a0ff7bb3238eb7e5473f9b43c0
  262. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  263. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  264. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  265. - Filesize:3 [weak]
  266. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  267. E: Failed to fetch some archives."
  268. else
  269. FAILURE="Reading package lists...
  270. Need to get 6 B of source archives.
  271. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  272. Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
  273. Hash Sum mismatch
  274. Hashes of expected file:
  275. - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  276. - Filesize:3 [weak]
  277. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  278. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  279. Hashes of received file:
  280. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  281. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  282. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  283. - Filesize:3 [weak]
  284. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  285. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  286. Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
  287. Hash Sum mismatch
  288. Hashes of expected file:
  289. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  290. - Filesize:3 [weak]
  291. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  292. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  293. Hashes of received file:
  294. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  295. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  296. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  297. - Filesize:3 [weak]
  298. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  299. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
  300. Hashes of expected file:
  301. - SHA256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  302. - Filesize:3 [weak]
  303. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  304. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  305. Hashes of received file:
  306. - SHA256:943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a
  307. - SHA1:324f464e6151a92cf57b26ef95dcfcf2059a8c44 [weak]
  308. - MD5Sum:9604ba9427a280db542279d9ed78400b [weak]
  309. - Filesize:3 [weak]
  310. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.dsc")
  311. E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
  312. Hashes of expected file:
  313. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  314. - Filesize:3 [weak]
  315. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  316. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  317. Hashes of received file:
  318. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  319. - SHA1:680254bad1d7ca0d65ec46aaa315d363abf6a50a [weak]
  320. - MD5Sum:db5570bf61464b46e2bde31ed61a7dc6 [weak]
  321. - Filesize:3 [weak]
  322. Last modification reported: $(lastmodification "aptarchive/${1}_1.0.tar.gz")
  323. E: Failed to fetch some archives."
  324. fi
  325. testfailureequal "$FAILURE" aptget source -d "$@"
  326. msgtest 'Files were not download as they have hashsum mismatches for' "$1"
  327. testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  328. if [ "$2" != '--allow-unauthenticated' ]; then
  329. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  330. testsuccessequal "Reading package lists...
  331. Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
  332. Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
  333. Need to get 0 B of source archives.
  334. Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26
  335. msgtest 'Files were not download as hash is unavailable for' "$1"
  336. testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  337. fi
  338. if [ "$1" != 'pkg-size-bad' ]; then
  339. rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
  340. testsuccessequal "Reading package lists...
  341. Need to get 6 B of source archives.
  342. Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
  343. Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
  344. Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26
  345. msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
  346. testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
  347. fi
  348. }
  349. testnohash pkg-md5-ok
  350. testnohash pkg-sha1-ok
  351. testok pkg-sha256-ok
  352. testkeep pkg-sha256-ok
  353. # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
  354. # checking the best available hash (as it should), this will trigger
  355. # a hash mismatch.
  356. testmismatch pkg-sha256-bad
  357. testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum
  358. testnohash pkg-md5-bad
  359. testmismatch pkg-md5-bad --allow-unauthenticated
  360. testmismatch pkg-size-bad
  361. # not having MD5 sum doesn't mean the file doesn't exist at all …
  362. testok pkg-no-md5
  363. testok pkg-no-md5 -o Acquire::ForceHash=SHA256
  364. testsuccessequal "Reading package lists...
  365. Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
  366. Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
  367. Need to get 0 B of source archives.
  368. Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum
  369. msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
  370. testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
  371. # deal with cases in which we haven't for all files the same checksum type
  372. # mostly pathologic as this shouldn't happen, but just to be sure
  373. testsuccessequal "Reading package lists...
  374. Skipping download of file 'pkg-mixed-ok_1.0.tar.gz' as requested hashsum is not available for authentication
  375. Need to get 3 B of source archives.
  376. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-ok 1.0 (dsc) [3 B]
  377. Download complete and in download only mode" aptget source -d pkg-mixed-ok
  378. testsuccessequal "Reading package lists...
  379. Skipping download of file 'pkg-mixed-sha1-bad_1.0.dsc' as requested hashsum is not available for authentication
  380. Need to get 3 B of source archives.
  381. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B]
  382. Download complete and in download only mode" aptget source -d pkg-mixed-sha1-bad
  383. msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
  384. testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
  385. testfailureequal "Reading package lists...
  386. Skipping download of file 'pkg-mixed-sha2-bad_1.0.dsc' as requested hashsum is not available for authentication
  387. Need to get 3 B of source archives.
  388. Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B]
  389. Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar)
  390. Hash Sum mismatch
  391. Hashes of expected file:
  392. - SHA256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  393. - Filesize:3 [weak]
  394. Hashes of received file:
  395. - SHA256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
  396. - Filesize:3 [weak]
  397. Last modification reported: $(lastmodification 'aptarchive/pkg-mixed-sha2-bad_1.0.tar.gz')
  398. E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz 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 some archives." aptget source -d pkg-mixed-sha2-bad
  407. # it gets even more pathologic: multiple entries for one file, some even disagreeing!
  408. testnohash pkg-md5-agree
  409. testfailureequal 'Reading package lists...
  410. E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree
  411. testfailureequal 'Reading package lists...
  412. E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree