test-apt-update-unauth 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. #
  3. # Ensure that when going from unauthenticated to authenticated all
  4. # files are checked again
  5. #
  6. set -e
  7. TESTDIR="$(readlink -f "$(dirname "$0")")"
  8. . "$TESTDIR/framework"
  9. umask 022
  10. setupenvironment
  11. configarchitecture "i386"
  12. configcompression '.' 'xz'
  13. insertpackage 'unstable' 'foo' 'i386' '1.0'
  14. insertsource 'unstable' 'foo' 'any' '1.0'
  15. setupaptarchive --no-update
  16. changetowebserver
  17. # FIXME:
  18. # - also check the unauth -> auth success case, i.e. that all files are
  19. # reverified
  20. runtest() {
  21. # start unauthenticated
  22. rm -rf rootdir/var/lib/apt/lists/
  23. find aptarchive/ -name '*Release*' -delete
  24. testwarning aptget update --allow-insecure-repositories
  25. # become authenticated
  26. generatereleasefiles
  27. signreleasefiles
  28. # move uncompressed away
  29. mv aptarchive/dists/unstable/main/binary-i386/Packages \
  30. aptarchive/dists/unstable/main/binary-i386/Packages.uncompressed
  31. # and ensure we re-check the downloaded data
  32. # change the local packages file
  33. PKGS=$(ls rootdir/var/lib/apt/lists/*Packages*)
  34. echo "meep" > $PKGS
  35. listcurrentlistsdirectory > lists.before
  36. # update and ensure all is reverted on the hashsum failure
  37. testfailure aptget update -o Debug::Acquire::Transaction=1 -o Debug::pkgAcquire::Auth=1 -o Debug::pkgAcquire::worker=0 -o Debug::acquire::http=0
  38. # ensure we have before what we have after
  39. msgtest 'Check rollback on going from' 'unauth -> auth'
  40. listcurrentlistsdirectory > lists.after
  41. if cmp lists.before lists.after; then
  42. msgpass
  43. else
  44. echo >&2
  45. echo >&2 '### Output of previous apt-get update ###'
  46. cat >&2 rootdir/tmp/testfailure.output || true
  47. echo >&2 '### Changes in the lists-directory: ###'
  48. diff -u >&2 lists.before lists.after || true
  49. echo >&2 '### Contents of the lists-directory: ###'
  50. ls -l rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists/partial || true
  51. msgfail
  52. fi
  53. # move uncompressed back for release file
  54. mv aptarchive/dists/unstable/main/binary-i386/Packages.uncompressed \
  55. aptarchive/dists/unstable/main/binary-i386/Packages
  56. }
  57. for COMPRESSEDINDEXES in 'false' 'true'; do
  58. echo "Acquire::GzipIndexes \"$COMPRESSEDINDEXES\";" > rootdir/etc/apt/apt.conf.d/compressindexes
  59. if $COMPRESSEDINDEXES; then
  60. msgmsg 'Run tests with GzipIndexes enabled'
  61. else
  62. msgmsg 'Run tests with GzipIndexes disabled'
  63. fi
  64. runtest
  65. done