test-apt-update-not-modified 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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' 'all' '1.0'
  8. setupaptarchive --no-update
  9. methodtest() {
  10. msgmsg 'Test InRelease with' "$1"
  11. rm -rf rootdir/var/lib/apt/lists
  12. # get our cache populated
  13. testsuccess aptget update
  14. listcurrentlistsdirectory > listsdir.lst
  15. # hit again with a good cache
  16. testsuccessequal "Hit $1 unstable InRelease
  17. Reading package lists..." aptget update
  18. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  19. # drop an architecture, which means the file should be gone now
  20. configarchitecture 'i386'
  21. sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
  22. testsuccessequal "Hit $1 unstable InRelease
  23. Reading package lists..." aptget update
  24. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  25. # readd arch so its downloaded again
  26. configarchitecture 'amd64' 'i386'
  27. testsuccessequal "Hit $1 unstable InRelease
  28. Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
  29. Reading package lists..." aptget update
  30. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  31. webserverconfig 'aptwebserver::support::modified-since' 'false'
  32. webserverconfig 'aptwebserver::support::last-modified' 'false'
  33. testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
  34. Reading package lists..." aptget update
  35. webserverconfig 'aptwebserver::support::modified-since' 'true'
  36. webserverconfig 'aptwebserver::support::last-modified' 'true'
  37. msgmsg 'Test Release.gpg with' "$1"
  38. rm -rf rootdir/var/lib/apt/lists
  39. cp -a aptarchive/dists aptarchive/dists.good
  40. find aptarchive/dists -name 'InRelease' -delete
  41. # get our cache populated
  42. testsuccess aptget update
  43. listcurrentlistsdirectory > listsdir.lst
  44. # hit again with a good cache
  45. testsuccessequal "Ign $1 unstable InRelease
  46. 404 Not Found
  47. Hit $1 unstable Release
  48. Reading package lists..." aptget update
  49. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  50. # drop an architecture, which means the file should be gone now
  51. configarchitecture 'i386'
  52. sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
  53. testsuccessequal "Ign $1 unstable InRelease
  54. 404 Not Found
  55. Hit $1 unstable Release
  56. Reading package lists..." aptget update
  57. testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
  58. # readd arch so its downloaded again
  59. configarchitecture 'amd64' 'i386'
  60. testsuccessequal "Ign $1 unstable InRelease
  61. 404 Not Found
  62. Hit $1 unstable Release
  63. Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
  64. Reading package lists..." aptget update
  65. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  66. webserverconfig 'aptwebserver::support::modified-since' 'false'
  67. webserverconfig 'aptwebserver::support::last-modified' 'false'
  68. testsuccessequal "Ign $1 unstable InRelease
  69. 404 Not Found
  70. Get:1 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
  71. Reading package lists..." aptget update
  72. webserverconfig 'aptwebserver::support::modified-since' 'true'
  73. webserverconfig 'aptwebserver::support::last-modified' 'true'
  74. rm -rf aptarchive/dists
  75. cp -a aptarchive/dists.good aptarchive/dists
  76. }
  77. changetowebserver
  78. methodtest 'http://localhost:8080'
  79. changetohttpswebserver
  80. methodtest 'https://localhost:4433'