test-apt-https-no-redirect 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture "i386"
  7. insertpackage 'stable' 'apt' 'all' '1'
  8. setupaptarchive --no-update
  9. echo 'alright' > aptarchive/working
  10. changetohttpswebserver
  11. webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "http://localhost:${APTHTTPPORT}/"
  12. webserverconfig 'aptwebserver::redirect::replace::/redirectme2/' "https://localhost:${APTHTTPSPORT}/"
  13. echo 'Dir::Bin::Methods::https+http "https";' > rootdir/etc/apt/apt.conf.d/99add-https-http-method
  14. msgtest 'download of a file works via' 'http'
  15. testsuccess --nomsg downloadfile "http://localhost:${APTHTTPPORT}/working" httpfile
  16. testfileequal httpfile 'alright'
  17. msgtest 'download of a file works via' 'https'
  18. testsuccess --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/working" httpsfile
  19. testfileequal httpsfile 'alright'
  20. rm -f httpfile httpsfile
  21. msgtest 'download of http file works via' 'https+http'
  22. testsuccess --nomsg downloadfile "http://localhost:${APTHTTPPORT}/working" httpfile
  23. testfileequal httpfile 'alright'
  24. msgtest 'download of https file works via' 'https+http'
  25. testsuccess --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/working" httpsfile
  26. testfileequal httpsfile 'alright'
  27. rm -f httpfile httpsfile
  28. msgtest 'download of a file does not work if' 'https redirected to http'
  29. testfailure --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/redirectme/working" redirectfile
  30. msgtest 'libcurl has forbidden access in last request to' 'http resource'
  31. testsuccess --nomsg grep -q -E -- "Redirection from https to 'http://.*' is forbidden" rootdir/tmp/testfailure.output
  32. msgtest 'download of a file does work if' 'https+http redirected to https'
  33. testsuccess --nomsg downloadfile "https+http://localhost:${APTHTTPPORT}/redirectme2/working" redirectfile
  34. testfileequal redirectfile 'alright'