test-apt-update-unauth 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. testsuccess 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. # change the local packages file
  34. PKGS=$(ls rootdir/var/lib/apt/lists/*Packages*)
  35. echo "meep" > $PKGS
  36. ls rootdir/var/lib/apt/lists/ > lists.before
  37. # update and ensure all is reverted on the hashsum failure
  38. testfailure aptget update -o Debug::Acquire::Transaction=0 -o Debug::pkgAcquire::Auth=1 -o Debug::pkgAcquire::worker=0 -o Debug::acquire::http=0
  39. # ensure we have before what we have after
  40. msgtest 'Check rollback on going from' 'unauth -> auth'
  41. ls rootdir/var/lib/apt/lists/ > lists.after
  42. if cmp lists.before lists.after; then
  43. msgpass
  44. else
  45. echo >&2 '### Output of previous apt-get update ###'
  46. cat >&2 rootdir/tmp/testfailure.output
  47. echo >&2 '### Changes in the lists-directory: ###'
  48. diff -u >&2 lists.before lists.after
  49. msgfail
  50. fi
  51. # move uncompressed back for release file
  52. mv aptarchive/dists/unstable/main/binary-i386/Packages.uncompressed \
  53. aptarchive/dists/unstable/main/binary-i386/Packages
  54. }
  55. for COMPRESSEDINDEXES in 'false' 'true'; do
  56. echo "Acquire::GzipIndexes \"$COMPRESSEDINDEXES\";" > rootdir/etc/apt/apt.conf.d/compressindexes
  57. if $COMPRESSEDINDEXES; then
  58. msgmsg 'Run tests with GzipIndexes enabled'
  59. else
  60. msgmsg 'Run tests with GzipIndexes disabled'
  61. fi
  62. runtest
  63. done