test-bug-738785-switch-protocol 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # install a slowed down file: otherwise its to fast to reproduce combining
  32. NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
  33. OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
  34. rm "$NEWMETHODS"
  35. mkdir "$NEWMETHODS"
  36. backupIFS="$IFS"
  37. IFS="$(printf "\n\b")"
  38. for METH in $(find "$OLDMETHODS" ! -type d); do
  39. ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
  40. done
  41. IFS="$backupIFS"
  42. rm "$NEWMETHODS/https"
  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. ln -s "$OLDMETHODS/https" "$NEWMETHODS"
  50. # check that downgrades from https to http are not allowed
  51. webserverconfig 'aptwebserver::support::http' 'true'
  52. sed -i -e 's#:8080/redirectme#:4433/downgrademe#' -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
  53. testfailure aptget update --allow-insecure-repositories