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.
 
 
 
 
 
 

86 lines
2.3 KiB

  1. #!/bin/sh
  2. set -e
  3. # ensure that an update will only succeed entirely or not at all
  4. TESTDIR="$(readlink -f "$(dirname "$0")")"
  5. . "$TESTDIR/framework"
  6. setupenvironment
  7. configarchitecture 'i386'
  8. configcompression '.' 'gz'
  9. insertpackage 'unstable' 'foo' 'i386' '1.0'
  10. insertsource 'unstable' 'foo' 'i386' '1.0'
  11. setupaptarchive --no-update
  12. breakfile() {
  13. breakfiles "$1" "${1}.gz"
  14. }
  15. restorefile() {
  16. unbreakfiles "$1" "${1}.gz"
  17. }
  18. testrun() {
  19. rm -rf aptarchive/dists.good
  20. cp -a aptarchive/dists aptarchive/dists.good
  21. insertpackage 'unstable' 'bar' 'i386' '1.0'
  22. insertsource 'unstable' 'bar' 'i386' '1.0'
  23. buildaptarchivefromfiles '+1 hour'
  24. # produce an unsigned repository
  25. find aptarchive \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
  26. testfailure aptget update --no-allow-insecure-repositories
  27. testfileequal "$1" "$(listcurrentlistsdirectory)"
  28. # signed but broken
  29. signreleasefiles
  30. onehashbroken() {
  31. rm -rf rootdir/var/lib/apt/lists/partial
  32. testfailure aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
  33. # each file generates two messages with this string
  34. testequal '2' grep --count 'Hash Sum mismatch' rootdir/tmp/testfailure.output
  35. testfileequal "$1" "$(listcurrentlistsdirectory)"
  36. }
  37. breakfile aptarchive/dists/unstable/main/binary-i386/Packages
  38. onehashbroken "$1"
  39. restorefile aptarchive/dists/unstable/main/binary-i386/Packages
  40. breakfile aptarchive/dists/unstable/main/source/Sources
  41. onehashbroken "$1"
  42. restorefile aptarchive/dists/unstable/main/source/Sources
  43. rm -rf aptarchive/dists
  44. cp -a aptarchive/dists.good aptarchive/dists
  45. }
  46. testsetup() {
  47. msgmsg 'Test with no initial data over' "$1"
  48. rm -rf rootdir/var/lib/apt/lists
  49. mkdir -p rootdir/var/lib/apt/lists/partial
  50. listcurrentlistsdirectory > listsdir.lst
  51. testrun 'listsdir.lst'
  52. msgmsg 'Test with initial data over' "$1"
  53. rm -rf rootdir/var/lib/apt/lists
  54. testsuccess aptget update -o Debug::pkgAcquire::Worker=1
  55. listcurrentlistsdirectory > listsdir.lst
  56. testrun 'listsdir.lst'
  57. }
  58. testsetup 'file'
  59. changetowebserver
  60. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  61. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  62. webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'none' "$1"
  63. testsetup 'http'
  64. changetohttpswebserver
  65. testsetup 'https'