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.
 
 
 
 
 
 

103 lines
4.1 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'native'
  7. insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable'
  8. insertsource 'unstable' 'unrelated' 'all' '1.0' 'stable'
  9. echo 'ni ni ni' > aptarchive/knights
  10. setupaptarchive
  11. changetowebserver -o 'aptwebserver::overwrite::.*InRelease::filename=/knights' -o 'aptwebserver::overwrite::.*::filename=/knights'
  12. msgtest 'Acquire test file from the webserver to check' 'overwrite'
  13. if downloadfile http://localhost:${APTHTTPPORT}/holygrail ./knights-talking >/dev/null; then
  14. msgpass
  15. else
  16. msgfail
  17. fi
  18. testfileequal knights-talking 'ni ni ni'
  19. ensure_n_canary_strings_in_dir() {
  20. local DIR="$1"
  21. local CANARY_STRING="$2"
  22. local EXPECTED_N="$3"
  23. msgtest "Testing in $DIR for $EXPECTED_N canary" "$CANARY_STRING"
  24. local N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
  25. test "$N" = "$EXPECTED_N" && msgpass || msgfail "Expected $EXPECTED_N canaries, got $N"
  26. }
  27. runtests() {
  28. LISTS='rootdir/var/lib/apt/lists'
  29. rm -rf "$LISTS"
  30. testfailure aptget update
  31. testsuccess grep "$1" rootdir/tmp/testfailure.output
  32. ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
  33. testequal 'auxfiles
  34. lock
  35. partial' ls "$LISTS"
  36. # and again with pre-existing files with "valid data" which should remain
  37. for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do
  38. echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
  39. chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
  40. done
  41. testfailure aptget update
  42. testsuccess grep "$1" rootdir/tmp/testfailure.output
  43. ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4
  44. ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
  45. # and now with a pre-existing InRelease file
  46. echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
  47. chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
  48. rm -f "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release" "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release.gpg"
  49. msgtest 'excpected failure of' 'apt-get update'
  50. testfailure aptget update
  51. testsuccess grep "$1" rootdir/tmp/testfailure.output
  52. ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 3
  53. ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
  54. }
  55. runtests '^E:.*Clearsigned file .*NOSPLIT.*'
  56. webserverconfig 'aptwebserver::overwrite::.*InRelease::filename' '/404'
  57. runtests '^E:.*Signed file .*NODATA.*'
  58. webserverconfig 'aptwebserver::overwrite::.*::filename' '/404'
  59. webserverconfig 'aptwebserver::httpcode::404' '511 Network Authentication Required'
  60. rm -rf rootdir/var/lib/apt/lists
  61. testfailureequal "Err:1 http://localhost:${APTHTTPPORT} unstable InRelease
  62. 511 Network Authentication Required
  63. Reading package lists...
  64. E: Failed to fetch http://localhost:${APTHTTPPORT}/dists/unstable/InRelease 511 Network Authentication Required
  65. E: The repository 'http://localhost:${APTHTTPPORT} unstable InRelease' is not signed.
  66. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  67. N: See apt-secure(8) manpage for repository creation and user configuration details." aptget update
  68. # on S3 all files get a 403. If we accept unsigned, lets be liberal in non-existence acceptance
  69. webserverconfig 'aptwebserver::httpcode::404' '403 Forbidden'
  70. rm -rf rootdir/var/lib/apt/lists
  71. testfailureequal "Err:1 http://localhost:${APTHTTPPORT} unstable InRelease
  72. 403 Forbidden
  73. Reading package lists...
  74. E: Failed to fetch http://localhost:${APTHTTPPORT}/dists/unstable/InRelease 403 Forbidden
  75. E: The repository 'http://localhost:${APTHTTPPORT} unstable InRelease' is not signed.
  76. N: Updating from such a repository can't be done securely, and is therefore disabled by default.
  77. N: See apt-secure(8) manpage for repository creation and user configuration details." apt update
  78. sed -i 's#^deb\(-src\)\? #deb\1 [allow-insecure=yes] #' rootdir/etc/apt/sources.list.d/*
  79. testfailure apt update
  80. testequal "Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  81. 403 Forbidden
  82. Ign:2 http://localhost:${APTHTTPPORT} unstable Release
  83. 403 Forbidden" head -n 4 rootdir/tmp/testfailure.output