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.
 
 
 
 
 
 

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