test-apt-update-not-modified 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64' 'i386'
  7. confighashes 'SHA256'
  8. insertpackage 'unstable' 'apt' 'amd64,i386' '1.0'
  9. export APT_DONT_SIGN=''
  10. setupaptarchive --no-update
  11. methodtest() {
  12. msgmsg 'Test InRelease with' "$1"
  13. rm -rf rootdir/var/lib/apt/lists
  14. cp -a aptarchive/dists aptarchive/dists.good
  15. # get our cache populated
  16. testsuccess aptget update
  17. listcurrentlistsdirectory > listsdir.lst
  18. # hit again with a good cache
  19. testsuccessequal "Hit:1 $1 unstable InRelease
  20. Reading package lists..." aptget update
  21. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  22. # drop an architecture, which means the file should be gone now
  23. configarchitecture 'i386'
  24. sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
  25. testsuccessequal "Hit:1 $1 unstable InRelease
  26. Reading package lists..." aptget update
  27. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  28. # readd arch so its downloaded again…
  29. configarchitecture 'amd64' 'i386'
  30. # … but oh noes, hashsum mismatch!
  31. SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  32. mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig
  33. cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF
  34. Package: thisisbad
  35. Architecture: amd64
  36. Version: 1
  37. EOF
  38. compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
  39. testfailureequal "Hit:1 $1 unstable InRelease
  40. Get:2 $1 unstable/main amd64 Packages [$SIZE B]
  41. Err:2 $1 unstable/main amd64 Packages
  42. Hash Sum mismatch
  43. Hashes of expected file:
  44. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
  45. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
  46. Hashes of received file:
  47. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
  48. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
  49. Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  50. Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
  51. Reading package lists...
  52. E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
  53. Hashes of expected file:
  54. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
  55. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
  56. Hashes of received file:
  57. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
  58. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
  59. Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  60. Release file created at: $(releasefiledate 'aptarchive/dists/unstable/InRelease')
  61. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  62. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  63. rm -rf aptarchive/dists
  64. cp -a aptarchive/dists.good aptarchive/dists
  65. # … now everything is fine again
  66. testsuccessequal "Hit:1 $1 unstable InRelease
  67. Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
  68. Reading package lists..." aptget update
  69. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  70. webserverconfig 'aptwebserver::support::modified-since' 'false'
  71. webserverconfig 'aptwebserver::support::last-modified' 'false'
  72. testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
  73. Reading package lists..." aptget update
  74. webserverconfig 'aptwebserver::support::modified-since' 'true'
  75. webserverconfig 'aptwebserver::support::last-modified' 'true'
  76. msgmsg 'Test Release.gpg with' "$1"
  77. rm -rf rootdir/var/lib/apt/lists
  78. find aptarchive/dists -name 'InRelease' -delete
  79. # get our cache populated
  80. testsuccess aptget update
  81. listcurrentlistsdirectory > listsdir.lst
  82. # hit again with a good cache
  83. testsuccessequal "Ign:1 $1 unstable InRelease
  84. 404 Not Found
  85. Hit:2 $1 unstable Release
  86. Reading package lists..." aptget update
  87. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  88. # drop an architecture, which means the file should be gone now
  89. configarchitecture 'i386'
  90. sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
  91. testsuccessequal "Ign:1 $1 unstable InRelease
  92. 404 Not Found
  93. Hit:2 $1 unstable Release
  94. Reading package lists..." aptget update
  95. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  96. # readd arch so its downloaded again…
  97. configarchitecture 'amd64' 'i386'
  98. # … but oh noes, hashsum mismatch!
  99. SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  100. mv aptarchive/dists/unstable/main/binary-amd64/Packages.gz aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig
  101. cat > aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF
  102. Package: thisisbad
  103. Architecture: amd64
  104. Version: 1
  105. EOF
  106. compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
  107. testfailureequal "Ign:1 $1 unstable InRelease
  108. 404 Not Found
  109. Hit:2 $1 unstable Release
  110. Get:4 $1 unstable/main amd64 Packages [$SIZE B]
  111. Err:4 $1 unstable/main amd64 Packages
  112. Hash Sum mismatch
  113. Hashes of expected file:
  114. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
  115. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
  116. Hashes of received file:
  117. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
  118. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
  119. Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  120. Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
  121. Reading package lists...
  122. E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
  123. Hashes of expected file:
  124. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig') [weak]
  125. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz.orig' | cut -d' ' -f 1)
  126. Hashes of received file:
  127. - SHA256:$(sha256sum 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz' | cut -d' ' -f 1)
  128. - Filesize:$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') [weak]
  129. Last modification reported: $(lastmodification 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz')
  130. Release file created at: $(releasefiledate 'aptarchive/dists/unstable/Release')
  131. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
  132. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  133. rm -rf aptarchive/dists
  134. cp -a aptarchive/dists.good aptarchive/dists
  135. find aptarchive/dists -name 'InRelease' -delete
  136. # … now everything is fine again
  137. testsuccessequal "Ign:1 $1 unstable InRelease
  138. 404 Not Found
  139. Hit:2 $1 unstable Release
  140. Get:4 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
  141. Reading package lists..." aptget update
  142. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  143. webserverconfig 'aptwebserver::support::modified-since' 'false'
  144. webserverconfig 'aptwebserver::support::last-modified' 'false'
  145. testsuccessequal "Ign:1 $1 unstable InRelease
  146. 404 Not Found
  147. Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
  148. Reading package lists..." aptget update
  149. webserverconfig 'aptwebserver::support::modified-since' 'true'
  150. webserverconfig 'aptwebserver::support::last-modified' 'true'
  151. rm -rf aptarchive/dists
  152. cp -a aptarchive/dists.good aptarchive/dists
  153. # new release file, but the indexes are the same
  154. redatereleasefiles '+2 hours'
  155. rm -rf rootdir/var/lib/apt/lists.good
  156. cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  157. testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
  158. Reading package lists..." aptget update
  159. rm -rf rootdir/var/lib/apt/lists
  160. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  161. find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
  162. testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
  163. Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
  164. Get:3 $1 unstable/main i386 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-i386/Packages.gz') B]
  165. Reading package lists..." aptget update
  166. rm -rf aptarchive/dists
  167. cp -a aptarchive/dists.good aptarchive/dists
  168. }
  169. changetowebserver
  170. methodtest "http://localhost:${APTHTTPPORT}"
  171. changetohttpswebserver
  172. methodtest "https://localhost:${APTHTTPSPORT}"