test-apt-update-ims 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 .* \(InRelease\|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 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 http://localhost:8080 unstable InRelease
  55. 404 Not Found
  56. Hit http://localhost:8080 unstable Release
  57. Hit http://localhost:8080 unstable Release.gpg
  58. Reading package lists...'
  59. find aptarchive -name 'InRelease' -delete
  60. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  61. runtest
  62. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  63. runtest
  64. msgmsg 'Release only'
  65. EXPECT="Ign http://localhost:8080 unstable InRelease
  66. 404 Not Found
  67. Hit http://localhost:8080 unstable Release
  68. Ign http://localhost:8080 unstable Release.gpg
  69. 404 Not Found
  70. Reading package lists...
  71. W: The data from 'http://localhost:8080 unstable Release.gpg' is not signed. Packages from that repository can not be authenticated."
  72. find aptarchive -name 'Release.gpg' -delete
  73. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  74. runtest 'warning'
  75. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  76. runtest 'warning'
  77. # make the release file old
  78. find aptarchive -name '*Release' -exec sed -i \
  79. -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
  80. -e '/^Valid-Until: / d' -e "/^Date: / a\
  81. Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
  82. signreleasefiles
  83. msgmsg 'expired InRelease'
  84. EXPECT='Hit http://localhost:8080 unstable InRelease
  85. E: Release file for http://localhost:8080/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied.'
  86. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  87. runtest 'failure'
  88. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  89. runtest 'failure'
  90. msgmsg 'expired Release/Release.gpg'
  91. EXPECT='Ign http://localhost:8080 unstable InRelease
  92. 404 Not Found
  93. Hit http://localhost:8080 unstable Release
  94. Hit http://localhost:8080 unstable Release.gpg
  95. E: Release file for http://localhost:8080/dists/unstable/Release.gpg is expired (invalid since). Updates for this repository will not be applied.'
  96. find aptarchive -name 'InRelease' -delete
  97. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  98. runtest 'failure'
  99. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  100. runtest 'failure'
  101. msgmsg 'expired Release only'
  102. EXPECT="Ign http://localhost:8080 unstable InRelease
  103. 404 Not Found
  104. Hit http://localhost:8080 unstable Release
  105. Ign http://localhost:8080 unstable Release.gpg
  106. 404 Not Found
  107. W: The data from 'http://localhost:8080 unstable Release.gpg' is not signed. Packages from that repository can not be authenticated.
  108. E: Release file for http://localhost:8080/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
  109. find aptarchive -name 'Release.gpg' -delete
  110. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  111. runtest 'failure' 'warning'
  112. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  113. runtest 'failure' 'warning'
  114. msgmsg 'no Release at all'
  115. EXPECT="Ign http://localhost:8080 unstable InRelease
  116. 404 Not Found
  117. Ign http://localhost:8080 unstable Release
  118. 404 Not Found
  119. Hit http://localhost:8080 unstable/main Sources
  120. Hit http://localhost:8080 unstable/main amd64 Packages
  121. Hit http://localhost:8080 unstable/main Translation-en
  122. Reading package lists...
  123. W: The repository 'http://localhost:8080 unstable Release' does not have a Release file. This is deprecated, please contact the owner of the repository."
  124. find aptarchive -name '*Release*' -delete
  125. echo 'Acquire::GzipIndexes "0";
  126. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  127. runtest 'warning'
  128. echo 'Acquire::GzipIndexes "1";
  129. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  130. runtest 'warning'