test-apt-update-failure-propagation 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. buildsimplenativepackage 'foo' 'all' '1' 'stable'
  8. buildsimplenativepackage 'foo' 'all' '2' 'sid'
  9. setupaptarchive --no-update
  10. NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
  11. OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
  12. rm "$NEWMETHODS"
  13. mkdir "$NEWMETHODS"
  14. backupIFS="$IFS"
  15. IFS="$(printf "\n\b")"
  16. for METH in $(find "$OLDMETHODS" -maxdepth 1 ! -type d); do
  17. ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
  18. done
  19. IFS="$backupIFS"
  20. changetohttpswebserver
  21. for FILE in rootdir/etc/apt/sources.list.d/*-sid-* ; do
  22. sed -i -e 's#https:#http:#' -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/#" "$FILE"
  23. done
  24. pretest() {
  25. msgmsg "$@"
  26. rm -rf rootdir/var/lib/apt/lists
  27. testsuccessequal 'N: Unable to locate package foo' aptcache policy foo
  28. }
  29. pretest 'initialize test' 'update'
  30. testsuccess aptget update
  31. testsuccessequal "foo:
  32. Installed: (none)
  33. Candidate: 2
  34. Version table:
  35. 2 500
  36. 500 http://localhost:${APTHTTPPORT} sid/main all Packages
  37. 1 500
  38. 500 https://localhost:${APTHTTPSPORT} stable/main all Packages" aptcache policy foo
  39. pretest 'not found' 'release files'
  40. mv aptarchive/dists/stable aptarchive/dists/stable.good
  41. testfailuremsg "E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  42. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  43. N: See apt-secure(8) manpage for repository creation and user configuration details." apt update
  44. testfailure aptget update --no-allow-insecure-repositories
  45. testequalor2 "Hit:1 http://localhost:${APTHTTPPORT} sid InRelease
  46. Ign:2 https://localhost:${APTHTTPSPORT} stable InRelease
  47. 404 Not Found
  48. Err:3 https://localhost:${APTHTTPSPORT} stable Release
  49. 404 Not Found
  50. Reading package lists...
  51. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  52. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  53. N: See apt-secure(8) manpage for repository creation and user configuration details." "Ign:1 https://localhost:${APTHTTPSPORT} stable InRelease
  54. 404 Not Found
  55. Err:2 https://localhost:${APTHTTPSPORT} stable Release
  56. 404 Not Found
  57. Hit:3 http://localhost:${APTHTTPPORT} sid InRelease
  58. Reading package lists...
  59. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  60. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  61. N: See apt-secure(8) manpage for repository creation and user configuration details." cat rootdir/tmp/testfailure.output
  62. mv aptarchive/dists/stable.good aptarchive/dists/stable
  63. posttest() {
  64. testsuccessequal "foo:
  65. Installed: (none)
  66. Candidate: 2
  67. Version table:
  68. 2 500
  69. 500 http://localhost:${APTHTTPPORT} sid/main all Packages" aptcache policy foo
  70. }
  71. posttest
  72. pretest 'method disabled' 'https'
  73. echo 'Dir::Bin::Methods::https "false";' > rootdir/etc/apt/apt.conf.d/99disable-https
  74. testfailuremsg "E: The method 'https' is explicitly disabled via configuration.
  75. N: If you meant to use Tor remember to use tor+https instead of https.
  76. E: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
  77. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  78. rm -f rootdir/etc/apt/apt.conf.d/99disable-https
  79. posttest
  80. pretest 'method not installed' 'https'
  81. rm "${NEWMETHODS}/https"
  82. testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
  83. N: Is the package apt-transport-https installed?
  84. E: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
  85. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  86. posttest
  87. pretest 'https connection refused' 'doom port'
  88. for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
  89. # lets see how many testservers run also Doom
  90. sed -i -e "s#:${APTHTTPSPORT}/#:666/#" "$FILE"
  91. done
  92. testwarning aptget update -o Dir::Bin::Methods::https="${OLDMETHODS}/https"
  93. testequalor2 "W: Failed to fetch https://localhost:666/dists/stable/InRelease Failed to connect to localhost port 666: Connection refused
  94. W: Some index files failed to download. They have been ignored, or old ones used instead." "W: Failed to fetch https://localhost:666/dists/stable/InRelease couldn't connect to host
  95. W: Some index files failed to download. They have been ignored, or old ones used instead." tail -n 2 rootdir/tmp/testwarning.output
  96. posttest