test-bug-738785-switch-protocol 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
  8. # setup http redirecting to https
  9. getlabelfromsuite() { echo 'Testcases'; }
  10. setupaptarchive --no-update
  11. changetohttpswebserver -o 'aptwebserver::support::http=false'
  12. webserverconfig 'aptwebserver::redirect::replace::/downgrademe/' "http://localhost:${APTHTTPPORT}/"
  13. webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "https://localhost:${APTHTTPSPORT}/"
  14. sed -i -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/redirectme#" -e 's# https:# http:#' rootdir/etc/apt/sources.list.d/*
  15. testsuccess aptget update -o Debug::Acquire::http=1 -o Debug::Acquire::https=1 -o Debug::pkgAcquire::Worker=1
  16. msgtest 'Test that the webserver does not answer' 'http requests'
  17. downloadfile "http://localhost:${APTHTTPPORT}/pool/main/a/apt/apt_1.0/changelog" changelog >/dev/null 2>&1 && msgfail || msgpass
  18. echo "Acquire::Changelogs::URI::Label::Testcases \"http://localhost:${APTHTTPPORT}/redirectme/pool/@CHANGEPATH@/changelog\";" > rootdir/etc/apt/apt.conf.d/changelog.conf
  19. testsuccessequal "'http://localhost:${APTHTTPPORT}/redirectme/pool/main/a/apt/apt_1.0/changelog' apt.changelog" aptget changelog apt --print-uris
  20. cd downloaded
  21. testsuccess aptget changelog apt -d
  22. testsuccess test -s apt.changelog
  23. rm -f apt.changelog
  24. testsuccess aptget download apt
  25. testsuccess test -s apt_1.0_all.deb
  26. rm apt_1.0_all.deb
  27. cd - >/dev/null
  28. testsuccess aptget install apt -y
  29. testdpkginstalled 'apt'
  30. # install a slowed down file: otherwise its to fast to reproduce combining
  31. NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
  32. OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
  33. rm "$NEWMETHODS"
  34. mkdir "$NEWMETHODS"
  35. backupIFS="$IFS"
  36. IFS="$(printf "\n\b")"
  37. for METH in $(find "$OLDMETHODS" ! -type d); do
  38. ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
  39. done
  40. IFS="$backupIFS"
  41. rm "$NEWMETHODS/https"
  42. cd downloaded
  43. testfailureequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found.
  44. N: Is the package apt-transport-https installed?" aptget download apt
  45. testfailure test -e apt_1.0_all.deb
  46. cd - >/dev/null
  47. # revert to all methods
  48. ln -s "$OLDMETHODS/https" "$NEWMETHODS"
  49. # check that downgrades from https to http are not allowed
  50. webserverconfig 'aptwebserver::support::http' 'true'
  51. sed -i -e "s#:${APTHTTPPORT}/redirectme#:${APTHTTPSPORT}/downgrademe#" -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
  52. testfailure aptget update --allow-insecure-repositories