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.
 
 
 
 
 
 

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