test-sourceslist-trusted-options 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. buildsimplenativepackage 'foo' 'amd64' '1' 'stable'
  8. buildsimplenativepackage 'foo' 'amd64' '2' 'testing'
  9. setupaptarchive --no-update
  10. APTARCHIVE=$(readlink -f ./aptarchive)
  11. everythingsucceeds() {
  12. testequal 'Listing...
  13. foo/testing 2 amd64
  14. foo/stable 1 amd64
  15. ' apt list foo -a
  16. rm -f foo_1_amd64.deb foo_2_amd64.deb
  17. testsuccess aptget download foo "$@"
  18. testsuccess test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
  19. rm -f foo_1.dsc foo_2.dsc
  20. testsuccess aptget source foo --dsc-only -d "$@"
  21. testsuccess test -s foo_1.dsc -o -s foo_2.dsc
  22. }
  23. everythingfails() {
  24. testequal 'Listing...
  25. foo/testing 2 amd64
  26. foo/stable 1 amd64
  27. ' apt list foo -a
  28. local WARNING='WARNING: The following packages cannot be authenticated!
  29. foo
  30. E: Some packages could not be authenticated'
  31. rm -f foo_1_amd64.deb foo_2_amd64.deb
  32. testfailure aptget download foo "$@"
  33. testequal "$WARNING" tail -n 3 rootdir/tmp/testfailure.output
  34. testfailure test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
  35. rm -f foo_1.dsc foo_2.dsc
  36. testfailure aptget source foo --dsc-only -d "$@"
  37. testequal "$WARNING" tail -n 3 rootdir/tmp/testfailure.output
  38. testfailure test -s foo_1.dsc -o -s foo_2.dsc
  39. }
  40. cp -a rootdir/etc/apt/sources.list.d/ rootdir/etc/apt/sources.list.d.bak/
  41. aptgetupdate() {
  42. rm -rf rootdir/var/lib/apt/lists
  43. # note that insecure with trusted=yes are allowed
  44. # as the trusted=yes indicates that security is provided by
  45. # something above the understanding of apt
  46. testsuccess aptget update --no-allow-insecure-repositories
  47. }
  48. insecureaptgetupdate() {
  49. rm -rf rootdir/var/lib/apt/lists
  50. testfailure aptget update
  51. rm -rf rootdir/var/lib/apt/lists
  52. testsuccess aptget update --allow-insecure-repositories
  53. }
  54. msgmsg 'Test without trusted option and good sources'
  55. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  56. aptgetupdate
  57. everythingsucceeds
  58. everythingsucceeds -t stable
  59. everythingsucceeds -t testing
  60. msgmsg 'Test with trusted=yes option and good sources'
  61. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  62. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  63. aptgetupdate
  64. everythingsucceeds
  65. everythingsucceeds -t stable
  66. everythingsucceeds -t testing
  67. msgmsg 'Test with trusted=no option and good sources'
  68. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  69. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  70. # we want the warnings on the actions, but for 'update' everything is fine
  71. aptgetupdate
  72. everythingfails
  73. everythingfails -t stable
  74. everythingfails -t testing
  75. find aptarchive/dists/stable \( -name 'InRelease' -o -name 'Release.gpg' \) -delete
  76. msgmsg 'Test without trusted option and good and unsigned sources'
  77. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  78. insecureaptgetupdate
  79. everythingsucceeds
  80. everythingfails -t stable
  81. everythingsucceeds -t testing
  82. msgmsg 'Test with trusted=yes option and good and unsigned sources'
  83. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  84. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  85. aptgetupdate
  86. everythingsucceeds
  87. everythingsucceeds -t stable
  88. everythingsucceeds -t testing
  89. msgmsg 'Test with trusted=no option and good and unsigned sources'
  90. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  91. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  92. insecureaptgetupdate
  93. everythingfails
  94. everythingfails -t stable
  95. everythingfails -t testing
  96. signreleasefiles 'Marvin Paranoid' 'aptarchive/dists/stable'
  97. msgmsg 'Test without trusted option and good and unknown sources'
  98. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  99. insecureaptgetupdate
  100. everythingsucceeds
  101. everythingfails -t stable
  102. everythingsucceeds -t testing
  103. msgmsg 'Test with trusted=yes option and good and unknown sources'
  104. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  105. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  106. aptgetupdate
  107. everythingsucceeds
  108. everythingsucceeds -t stable
  109. everythingsucceeds -t testing
  110. msgmsg 'Test with trusted=no option and good and unknown sources'
  111. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  112. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  113. insecureaptgetupdate
  114. everythingfails
  115. everythingfails -t stable
  116. everythingfails -t testing
  117. signreleasefiles 'Rex Expired' 'aptarchive/dists/stable'
  118. cp -a keys/rexexpired.pub rootdir/etc/apt/trusted.gpg.d/rexexpired.gpg
  119. msgmsg 'Test without trusted option and good and expired sources'
  120. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  121. insecureaptgetupdate
  122. everythingsucceeds
  123. everythingfails -t stable
  124. everythingsucceeds -t testing
  125. msgmsg 'Test with trusted=yes option and good and expired sources'
  126. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  127. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  128. aptgetupdate
  129. everythingsucceeds
  130. everythingsucceeds -t stable
  131. everythingsucceeds -t testing
  132. msgmsg 'Test with trusted=no option and good and expired sources'
  133. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  134. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  135. insecureaptgetupdate
  136. everythingfails
  137. everythingfails -t stable
  138. everythingfails -t testing