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.
 
 
 
 
 
 

184 lines
8.5 KiB

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