test-bug-738785-switch-protocol 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. setupaptarchive --no-update
  10. changetowebserver -o 'aptwebserver::redirect::replace::/redirectme/=https://localhost:4433/' \
  11. -o 'aptwebserver::redirect::replace::/downgrademe/=http://localhost:8080/' \
  12. -o 'aptwebserver::support::http=false'
  13. changetohttpswebserver
  14. sed -i -e 's#:4433/#:8080/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:8080/pool/apt_1.0/changelog' changelog >/dev/null 2>&1 && msgfail || msgpass
  18. echo 'Apt::Changelogs::Server "http://localhost:8080/redirectme";' > rootdir/etc/apt/apt.conf.d/changelog.conf
  19. testequal "'http://localhost:8080/redirectme/pool/apt_1.0/changelog'" aptget changelog apt --print-uris
  20. testsuccess aptget changelog apt -d
  21. testsuccess test -s apt.changelog
  22. rm -f apt.changelog
  23. testsuccess aptget download apt
  24. testsuccess test -s apt_1.0_all.deb
  25. rm apt_1.0_all.deb
  26. testsuccess aptget install apt -y
  27. testdpkginstalled 'apt'
  28. # create a copy of all methods, expect https
  29. eval `aptconfig shell METHODS Dir::Bin::Methods/d`
  30. COPYMETHODS='usr/lib/apt/methods'
  31. mv rootdir/${COPYMETHODS} rootdir/${COPYMETHODS}.bak
  32. mkdir -p rootdir/$COPYMETHODS
  33. cd rootdir/$COPYMETHODS
  34. find $METHODS \! -type d | while read meth; do
  35. ln -s $meth
  36. done
  37. rm https
  38. cd - >/dev/null
  39. echo "Dir::Bin::Methods \"${COPYMETHODS}\";" >> aptconfig.conf
  40. testequal "E: The method driver $(pwd)/rootdir/usr/lib/apt/methods/https could not be found.
  41. N: Is the package apt-transport-https installed?" aptget download apt -q=0
  42. testsuccess test ! -e apt_1.0_all.deb
  43. # revert to all methods
  44. rm -rf rootdir/$COPYMETHODS
  45. mv rootdir/${COPYMETHODS}.bak rootdir/${COPYMETHODS}
  46. # check that downgrades from https to http are not allowed
  47. webserverconfig 'aptwebserver::support::http' 'true'
  48. sed -i -e 's#:8080/redirectme#:4433/downgrademe#' -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
  49. testfailure aptget update