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.
 
 
 
 
 
 

91 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. mv "${1}" "${1}.bak"
  14. mv "${1}.gz" "${1}.gz.bak"
  15. cat > "$1" <<EOF
  16. Package: bar
  17. EOF
  18. compressfile "$1"
  19. }
  20. restorefile() {
  21. mv "${1}.bak" "$1"
  22. mv "${1}.gz.bak" "${1}.gz"
  23. }
  24. testrun() {
  25. rm -rf aptarchive/dists.good
  26. cp -a aptarchive/dists aptarchive/dists.good
  27. insertpackage 'unstable' 'bar' 'i386' '1.0'
  28. insertsource 'unstable' 'bar' 'i386' '1.0'
  29. buildaptarchivefromfiles '+1 hour'
  30. # produce an unsigned repository
  31. find aptarchive \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
  32. testfailure aptget update --no-allow-insecure-repositories
  33. testfileequal "$1" "$(listcurrentlistsdirectory)"
  34. # signed but broken
  35. signreleasefiles
  36. onehashbroken() {
  37. testfailure aptget update
  38. # each file generates two messages with this string
  39. testequal '2' grep --count 'Hash Sum mismatch' rootdir/tmp/testfailure.output
  40. testfileequal "$1" "$(listcurrentlistsdirectory)"
  41. }
  42. breakfile aptarchive/dists/unstable/main/binary-i386/Packages
  43. onehashbroken "$1"
  44. restorefile aptarchive/dists/unstable/main/binary-i386/Packages
  45. breakfile aptarchive/dists/unstable/main/source/Sources
  46. onehashbroken "$1"
  47. restorefile aptarchive/dists/unstable/main/source/Sources
  48. rm -rf aptarchive/dists
  49. cp -a aptarchive/dists.good aptarchive/dists
  50. }
  51. testsetup() {
  52. msgmsg 'Test with no initial data over' "$1"
  53. rm -rf rootdir/var/lib/apt/lists
  54. mkdir -p rootdir/var/lib/apt/lists/partial
  55. listcurrentlistsdirectory > listsdir.lst
  56. testrun 'listsdir.lst'
  57. msgmsg 'Test with initial data over' "$1"
  58. rm -rf rootdir/var/lib/apt/lists
  59. testsuccess aptget update -o Debug::pkgAcquire::Worker=1
  60. listcurrentlistsdirectory > listsdir.lst
  61. testrun 'listsdir.lst'
  62. }
  63. testsetup 'file'
  64. changetowebserver
  65. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  66. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  67. webserverconfig 'aptwebserver::support::range' 'false' "$1"
  68. testsetup 'http'
  69. changetohttpswebserver
  70. testsetup 'https'