test-apt-update-failure-propagation 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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" ! -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. rm -rf rootdir/var/lib/apt/lists
  26. testsuccessequal 'N: Unable to locate package foo' aptcache policy foo
  27. }
  28. pretest
  29. testsuccess aptget update
  30. testsuccessequal "foo:
  31. Installed: (none)
  32. Candidate: 2
  33. Version table:
  34. 2 500
  35. 500 http://localhost:${APTHTTPPORT} sid/main all Packages
  36. 1 500
  37. 500 https://localhost:${APTHTTPSPORT} stable/main all Packages" aptcache policy foo
  38. pretest
  39. mv aptarchive/dists/stable aptarchive/dists/stable.good
  40. testfailuremsg "E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  41. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  42. N: See apt-secure(8) manpage for repository creation and user configuration details." apt update
  43. testfailure aptget update --no-allow-insecure-repositories
  44. testequalor2 "Hit:1 http://localhost:${APTHTTPPORT} sid InRelease
  45. Ign:2 https://localhost:${APTHTTPSPORT} stable InRelease
  46. 404 Not Found
  47. Err:3 https://localhost:${APTHTTPSPORT} stable Release
  48. 404 Not Found
  49. Reading package lists...
  50. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  51. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  52. N: See apt-secure(8) manpage for repository creation and user configuration details." "Ign:1 https://localhost:${APTHTTPSPORT} stable InRelease
  53. 404 Not Found
  54. Err:2 https://localhost:${APTHTTPSPORT} stable Release
  55. 404 Not Found
  56. Hit:3 http://localhost:${APTHTTPPORT} sid InRelease
  57. Reading package lists...
  58. E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
  59. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  60. N: See apt-secure(8) manpage for repository creation and user configuration details." cat rootdir/tmp/testfailure.output
  61. mv aptarchive/dists/stable.good aptarchive/dists/stable
  62. posttest() {
  63. testsuccessequal "foo:
  64. Installed: (none)
  65. Candidate: 2
  66. Version table:
  67. 2 500
  68. 500 http://localhost:${APTHTTPPORT} sid/main all Packages" aptcache policy foo
  69. }
  70. posttest
  71. pretest
  72. rm "${NEWMETHODS}/https"
  73. testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
  74. N: Is the package apt-transport-https installed?
  75. W: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
  76. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  77. posttest
  78. ln -s "$OLDMETHODS/https" "$NEWMETHODS"
  79. pretest
  80. for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
  81. # lets see how many testservers run also Doom
  82. sed -i -e "s#:${APTHTTPSPORT}/#:666/#" "$FILE"
  83. done
  84. testwarning aptget update
  85. testequalor2 "W: Failed to fetch https://localhost:666/dists/stable/InRelease Failed to connect to localhost port 666: Connection refused
  86. 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
  87. W: Some index files failed to download. They have been ignored, or old ones used instead." tail -n 2 rootdir/tmp/testwarning.output
  88. posttest