test-apt-update-unauth 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. insertpackage 'unstable' 'foo' 'all' '1.0'
  13. insertsource 'unstable' 'foo' 'all' '1.0'
  14. setupaptarchive
  15. changetowebserver
  16. # FIXME:
  17. # - also check the unauth -> auth success case, i.e. that all files are
  18. # reverified
  19. runtest() {
  20. # start unauthenticated
  21. find rootdir/var/lib/apt/lists/ -type f | xargs rm -f
  22. rm -f aptarchive/dists/unstable/*Release*
  23. aptget update -qq --allow-insecure-repositories
  24. # FIXME: this really shouldn't be needed
  25. rm -f rootdir/var/lib/apt/lists/partial/*
  26. # become authenticated
  27. generatereleasefiles
  28. signreleasefiles
  29. # move uncompressed away
  30. mv aptarchive/dists/unstable/main/binary-i386/Packages \
  31. aptarchive/dists/unstable/main/binary-i386/Packages.uncompressed
  32. # and ensure we re-check the downloaded data
  33. msgtest "Check rollback on going from unauth -> auth"
  34. # change the local packages file
  35. PKGS=$(ls rootdir/var/lib/apt/lists/*Packages*)
  36. echo "meep" > $PKGS
  37. ls rootdir/var/lib/apt/lists/ > lists.before
  38. # update and ensure all is reverted on the hashsum failure
  39. aptget update -o Debug::Acquire::Transaction=0 -o Debug::pkgAcquire::Auth=1 -o Debug::pkgAcquire::worker=0 -o Debug::acquire::http=0 > output.log 2>&1 || true
  40. # ensure we have before what we have after
  41. ls rootdir/var/lib/apt/lists/ > lists.after
  42. if diff -u lists.before lists.after; then
  43. msgpass
  44. else
  45. cat output.log
  46. msgfail
  47. fi
  48. # move uncompressed back for release file
  49. mv aptarchive/dists/unstable/main/binary-i386/Packages.uncompressed \
  50. aptarchive/dists/unstable/main/binary-i386/Packages
  51. }
  52. for COMPRESSEDINDEXES in 'false' 'true'; do
  53. echo "Acquire::GzipIndexes \"$COMPRESSEDINDEXES\";" > rootdir/etc/apt/apt.conf.d/compressindexes
  54. if $COMPRESSEDINDEXES; then
  55. msgmsg 'Run tests with GzipIndexes enabled'
  56. else
  57. msgmsg 'Run tests with GzipIndexes disabled'
  58. fi
  59. runtest
  60. done