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.
 
 
 
 
 
 

185 lines
7.7 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
  8. insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
  9. insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
  10. setupaptarchive --no-update
  11. changetowebserver
  12. runtest() {
  13. local APTOPT=""
  14. if [ -n "$1" ]; then
  15. APTOPT='--allow-insecure-repositories'
  16. else
  17. APTOPT='--no-allow-insecure-repositories'
  18. fi
  19. rm -rf rootdir/var/lib/apt/lists/
  20. local TEST="test${1:-success}"
  21. $TEST aptget update $APTOPT
  22. if [ "$1" = 'failure' ]; then
  23. # accept the outdated Release file so we can check Hit behaviour
  24. "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
  25. fi
  26. listcurrentlistsdirectory > listsdir.lst
  27. testsuccess grep '_Packages\(\.gz\)\?$' listsdir.lst
  28. testsuccess grep '_Sources\(\.gz\)\?$' listsdir.lst
  29. testsuccess grep '_Translation-en\(\.gz\)\?$' listsdir.lst
  30. # ensure no leftovers in partial
  31. testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
  32. # check that I-M-S header is kept in redirections
  33. echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
  34. $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
  35. sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
  36. testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
  37. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  38. # ensure that we still do a hash check for other files on ims hit of Release
  39. if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
  40. $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
  41. cp rootdir/tmp/${TEST}.output goodsign.output
  42. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  43. testsuccess grep '^Got GOODSIG, key ID:GOODSIG' goodsign.output
  44. fi
  45. # ensure no leftovers in partial
  46. testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
  47. }
  48. msgmsg 'InRelease'
  49. EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
  50. Reading package lists..."
  51. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  52. runtest
  53. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  54. runtest
  55. msgmsg 'Release/Release.gpg'
  56. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  57. 404 Not Found
  58. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  59. Reading package lists..."
  60. find aptarchive -name 'InRelease' -delete
  61. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  62. runtest
  63. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  64. runtest
  65. msgmsg 'Release only'
  66. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  67. 404 Not Found
  68. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  69. Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
  70. 404 Not Found
  71. Reading package lists...
  72. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
  73. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  74. N: See apt-secure(8) manpage for repository creation and user configuration details."
  75. find aptarchive -name 'Release.gpg' -delete
  76. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  77. runtest 'warning'
  78. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  79. runtest 'warning'
  80. # make the release file old
  81. find aptarchive -name '*Release' -exec sed -i \
  82. -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
  83. -e '/^Valid-Until: / d' -e "/^Date: / a\
  84. Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
  85. signreleasefiles
  86. msgmsg 'expired InRelease'
  87. EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
  88. Reading package lists...
  89. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
  90. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  91. runtest 'failure'
  92. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  93. runtest 'failure'
  94. msgmsg 'expired Release/Release.gpg'
  95. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  96. 404 Not Found
  97. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  98. Reading package lists...
  99. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
  100. find aptarchive -name 'InRelease' -delete
  101. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  102. runtest 'failure'
  103. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  104. runtest 'failure'
  105. msgmsg 'expired Release only'
  106. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  107. 404 Not Found
  108. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  109. Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
  110. 404 Not Found
  111. Reading package lists...
  112. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
  113. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  114. N: See apt-secure(8) manpage for repository creation and user configuration details.
  115. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
  116. find aptarchive -name 'Release.gpg' -delete
  117. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  118. runtest 'failure' 'warning'
  119. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  120. runtest 'failure' 'warning'
  121. msgmsg 'no Release at all'
  122. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  123. 404 Not Found
  124. Ign:2 http://localhost:${APTHTTPPORT} unstable Release
  125. 404 Not Found
  126. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  127. 404 Not Found
  128. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  129. 404 Not Found
  130. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  131. 404 Not Found
  132. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  133. 404 Not Found
  134. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  135. 404 Not Found
  136. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  137. 404 Not Found
  138. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  139. 404 Not Found
  140. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  141. 404 Not Found
  142. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  143. 404 Not Found
  144. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  145. 404 Not Found
  146. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  147. 404 Not Found
  148. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  149. 404 Not Found
  150. Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  151. Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  152. Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  153. Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  154. Reading package lists...
  155. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
  156. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  157. N: See apt-secure(8) manpage for repository creation and user configuration details."
  158. find aptarchive -name '*Release*' -delete
  159. echo 'Acquire::GzipIndexes "0";
  160. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  161. runtest 'warning'
  162. echo 'Acquire::GzipIndexes "1";
  163. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  164. runtest 'warning'