You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
2.3 KiB

  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. for METH in $(find $OLDMETHODS ! -type d); do
  37. ln -s $OLDMETHODS/$(basename $METH) $NEWMETHODS
  38. done
  39. rm $NEWMETHODS/https
  40. cd downloaded
  41. testfailureequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found.
  42. N: Is the package apt-transport-https installed?" aptget download apt -q=0
  43. testfailure test -e apt_1.0_all.deb
  44. cd - >/dev/null
  45. # revert to all methods
  46. ln -s $OLDMETHODS/https $NEWMETHODS
  47. # check that downgrades from https to http are not allowed
  48. webserverconfig 'aptwebserver::support::http' 'true'
  49. sed -i -e 's#:8080/redirectme#:4433/downgrademe#' -e 's# http:# https:#' rootdir/etc/apt/sources.list.d/*
  50. testfailure aptget update --allow-insecure-repositories