You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.4 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'i386'
  7. changetohttpswebserver
  8. test_apt_helper_download() {
  9. echo 'foo' > aptarchive/foo
  10. msgtest 'apt-file download-file' 'md5sum'
  11. apthelper -qq download-file http://localhost:8080/foo foo2 MD5Sum:d3b07384d113edec49eaa6238ad5ff00 && msgpass || msgfail
  12. testfileequal foo2 'foo'
  13. msgtest 'apt-file download-file' 'sha1'
  14. apthelper -qq download-file http://localhost:8080/foo foo1 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 && msgpass || msgfail
  15. testfileequal foo1 'foo'
  16. msgtest 'apt-file download-file' 'sha256'
  17. apthelper -qq download-file http://localhost:8080/foo foo3 SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c && msgpass || msgfail
  18. testfileequal foo3 'foo'
  19. msgtest 'apt-file download-file' 'no-hash'
  20. apthelper -qq download-file http://localhost:8080/foo foo4 && msgpass || msgfail
  21. testfileequal foo4 'foo'
  22. msgtest 'apt-file download-file' 'wrong hash'
  23. if ! apthelper -qq download-file http://localhost:8080/foo foo5 MD5Sum:aabbcc 2>&1 2> download.stderr; then
  24. msgpass
  25. else
  26. msgfail
  27. fi
  28. testfileequal download.stderr 'E: Failed to fetch http://localhost:8080/foo Hash Sum mismatch
  29. E: Download Failed'
  30. testfileequal foo5.FAILED 'foo'
  31. }
  32. test_apt_helper_detect_proxy() {
  33. # no proxy
  34. testequal "Using proxy '' for URL 'http://example.com/'" apthelper auto-detect-proxy http://example.com/
  35. # http auto detect proxy script
  36. cat > apt-proxy-detect <<'EOF'
  37. #!/bin/sh -e
  38. echo "http://some-proxy"
  39. EOF
  40. chmod 755 apt-proxy-detect
  41. echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
  42. testequal "Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto-detect-proxy http://www.example.com
  43. # https auto detect proxy script
  44. cat > apt-proxy-detect <<'EOF'
  45. #!/bin/sh -e
  46. echo "https://https-proxy"
  47. EOF
  48. chmod 755 apt-proxy-detect
  49. echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
  50. testequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
  51. }
  52. test_apt_helper_download
  53. test_apt_helper_detect_proxy