test-apt-update-hashsum-mismatch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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); 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. TEST='testfailure'
  29. if expr match "$get" '^.*Translation-.*$' >/dev/null; then
  30. TEST='testsuccess'
  31. unset get
  32. fi
  33. $TEST aptget update
  34. cp rootdir/tmp/${TEST}.output rootdir/tmp/update.output
  35. testsuccess grep -E "$(basename -s '.gz' "$get").*Hash Sum mismatch" rootdir/tmp/update.output
  36. $TEST aptcache show foo
  37. $TEST aptget install foo -s
  38. testfailure aptcache show bar
  39. testfailure aptget install bar -s
  40. done