test-apt-update-hashsum-mismatch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. configcompression 'gz'
  8. insertpackage 'testing' 'foo' 'all' '1'
  9. insertpackage 'testing' 'foo2' 'all' '1'
  10. insertsource 'testing' 'foo' 'all' '1'
  11. insertsource 'testing' 'foo2' 'all' '1'
  12. setupaptarchive --no-update
  13. changetowebserver
  14. echo 'Package: bar
  15. Maintainer: Doctor Evil <evil@example.com>
  16. Description: come to the dark side
  17. ' > aptarchive/DoctorEvil
  18. compressfile aptarchive/DoctorEvil
  19. find aptarchive \( -name 'Packages' -o -name 'Sources' -o -name 'Translation-en' \) -delete
  20. testsuccess aptget update
  21. testsuccess aptcache show foo
  22. testsuccess aptget install foo -s
  23. for get in $(sed -n 's#^GET /\([^ ]\+\.gz\) HTTP.\+$#\1#p' aptarchive/webserver.log.client*.log); do
  24. msgmsg 'Test hashsum mismatch with file' "$get"
  25. rm -rf rootdir/var/lib/apt/lists
  26. webserverconfig 'aptwebserver::overwrite' ''
  27. webserverconfig "aptwebserver::overwrite::$(printf '%s' "${get}" | sed 's#/#%2F#g' )::filename" '%2FDoctorEvil.gz'
  28. testfailure aptget update
  29. cp rootdir/tmp/testfailure.output rootdir/tmp/update.output
  30. testsuccess grep -E "$(basename "$get" '.gz').*Hash Sum mismatch" rootdir/tmp/update.output
  31. testfailure aptcache show foo
  32. testfailure aptget install foo -s
  33. testfailure aptcache show bar
  34. testfailure aptget install bar -s
  35. done