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.
 
 
 
 
 
 

162 lines
6.3 KiB

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