test-bug-738785-switch-protocol 2.4 KB

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