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.
 
 
 
 
 
 

219 lines
7.6 KiB

  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. testsuccessequal 'Listing...
  13. foo/testing 2 amd64
  14. foo/stable 1 amd64
  15. ' apt list foo -a
  16. cd downloaded
  17. rm -f foo_1_amd64.deb foo_2_amd64.deb
  18. testsuccess aptget download foo "$@"
  19. testsuccess test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
  20. rm -f foo_1.dsc foo_2.dsc
  21. testsuccess aptget source foo --dsc-only -d "$@"
  22. testsuccess test -s foo_1.dsc -o -s foo_2.dsc
  23. cd - >/dev/null
  24. }
  25. everythingfails() {
  26. testsuccessequal 'Listing...
  27. foo/testing 2 amd64
  28. foo/stable 1 amd64
  29. ' apt list foo -a
  30. local WARNING='WARNING: The following packages cannot be authenticated!
  31. foo
  32. E: Some packages could not be authenticated'
  33. cd downloaded
  34. rm -f foo_1_amd64.deb foo_2_amd64.deb
  35. testfailure aptget download foo "$@"
  36. testequal "$WARNING" tail -n 3 ../rootdir/tmp/testfailure.output
  37. testfailure test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
  38. rm -f foo_1.dsc foo_2.dsc
  39. testfailure aptget source foo --dsc-only -d "$@"
  40. testequal "$WARNING" tail -n 3 ../rootdir/tmp/testfailure.output
  41. testfailure test -s foo_1.dsc -o -s foo_2.dsc
  42. cd - >/dev/null
  43. }
  44. cp -a rootdir/etc/apt/sources.list.d/ rootdir/etc/apt/sources.list.d.bak/
  45. echo 'Debug::Acquire::Transaction "true";
  46. Debug::pkgAcquire::Worker "true";' > rootdir/etc/apt/apt.conf.d/00debugging
  47. aptgetupdate() {
  48. rm -rf rootdir/var/lib/apt/lists
  49. # note that insecure with trusted=yes are allowed
  50. # as the trusted=yes indicates that security is provided by
  51. # something above the understanding of apt
  52. ${1:-testsuccess} aptget update --no-allow-insecure-repositories
  53. }
  54. insecureaptgetupdate() {
  55. rm -rf rootdir/var/lib/apt/lists
  56. testfailure aptget update --no-allow-insecure-repositories
  57. rm -rf rootdir/var/lib/apt/lists
  58. testwarning aptget update --allow-insecure-repositories
  59. }
  60. msgmsg 'Test without trusted option and good sources'
  61. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  62. aptgetupdate
  63. everythingsucceeds
  64. everythingsucceeds -t stable
  65. everythingsucceeds -t testing
  66. msgmsg 'Test with trusted=yes option and good sources'
  67. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  68. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  69. aptgetupdate
  70. everythingsucceeds
  71. everythingsucceeds -t stable
  72. everythingsucceeds -t testing
  73. msgmsg 'Test with trusted=no option and good sources'
  74. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  75. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  76. # we want the warnings on the actions, but for 'update' everything is fine
  77. aptgetupdate
  78. everythingfails
  79. everythingfails -t stable
  80. everythingfails -t testing
  81. find aptarchive/dists/stable \( -name 'InRelease' -o -name 'Release.gpg' \) -delete
  82. msgmsg 'Test without trusted option and good and unsigned sources'
  83. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  84. insecureaptgetupdate
  85. everythingsucceeds
  86. everythingfails -t stable
  87. everythingsucceeds -t testing
  88. msgmsg 'Test with trusted=yes option and good and unsigned sources'
  89. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  90. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  91. aptgetupdate 'testwarning'
  92. everythingsucceeds
  93. everythingsucceeds -t stable
  94. everythingsucceeds -t testing
  95. msgmsg 'Test with trusted=no option and good and unsigned sources'
  96. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  97. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  98. insecureaptgetupdate
  99. everythingfails
  100. everythingfails -t stable
  101. everythingfails -t testing
  102. signreleasefiles 'Marvin Paranoid' 'aptarchive/dists/stable'
  103. msgmsg 'Test without trusted option and good and unknown sources'
  104. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  105. insecureaptgetupdate
  106. everythingsucceeds
  107. everythingfails -t stable
  108. everythingsucceeds -t testing
  109. msgmsg 'Test with trusted=yes option and good and unknown sources'
  110. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  111. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  112. aptgetupdate 'testwarning'
  113. everythingsucceeds
  114. everythingsucceeds -t stable
  115. everythingsucceeds -t testing
  116. msgmsg 'Test with trusted=no option and good and unknown sources'
  117. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  118. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  119. insecureaptgetupdate
  120. everythingfails
  121. everythingfails -t stable
  122. everythingfails -t testing
  123. signreleasefiles 'Rex Expired' 'aptarchive/dists/stable'
  124. cp -a keys/rexexpired.pub rootdir/etc/apt/trusted.gpg.d/rexexpired.gpg
  125. msgmsg 'Test without trusted option and good and expired sources'
  126. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  127. insecureaptgetupdate
  128. everythingsucceeds
  129. everythingfails -t stable
  130. everythingsucceeds -t testing
  131. msgmsg 'Test with trusted=yes option and good and expired sources'
  132. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  133. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  134. aptgetupdate 'testwarning'
  135. everythingsucceeds
  136. everythingsucceeds -t stable
  137. everythingsucceeds -t testing
  138. msgmsg 'Test with trusted=no option and good and expired sources'
  139. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  140. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  141. insecureaptgetupdate
  142. everythingfails
  143. everythingfails -t stable
  144. everythingfails -t testing
  145. # same as the one further above, but this time testing is unsigned
  146. find aptarchive/ \( -name 'InRelease' -o -name 'Release.gpg' \) -delete
  147. signreleasefiles 'Joe Sixpack' 'aptarchive/dists/stable'
  148. msgmsg 'Test without trusted option and unsigned and good sources'
  149. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  150. insecureaptgetupdate
  151. everythingfails
  152. everythingsucceeds -t stable
  153. everythingfails -t testing
  154. msgmsg 'Test with trusted=yes option and unsigned and good sources'
  155. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  156. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
  157. aptgetupdate 'testwarning'
  158. everythingsucceeds
  159. everythingsucceeds -t stable
  160. everythingsucceeds -t testing
  161. msgmsg 'Test with trusted=no option and unsigned and good sources'
  162. cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
  163. sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
  164. insecureaptgetupdate
  165. everythingfails
  166. everythingfails -t stable
  167. everythingfails -t testing
  168. msgmsg 'Test conflicting trusted options are refused'
  169. testsource() {
  170. echo "$@" > rootdir/etc/apt/sources.list.d/example.list
  171. testfailuremsg 'E: Conflicting values set for option Trusted concerning source http://example.org/bad/ unstable
  172. E: The list of sources could not be read.' aptget update --print-uris
  173. }
  174. for VAL in 'yes' 'no'; do
  175. testsource "deb http://example.org/bad unstable main
  176. deb [trusted=${VAL}] http://example.org/bad unstable non-free"
  177. testsource "deb [trusted=${VAL}] http://example.org/bad unstable main
  178. deb http://example.org/bad unstable non-free"
  179. done
  180. testsource 'deb [trusted=yes] http://example.org/bad unstable main
  181. deb [trusted=no] http://example.org/bad unstable non-free'
  182. testsource 'deb [trusted=no] http://example.org/bad unstable main
  183. deb [trusted=yes] http://example.org/bad unstable non-free'