test-bug-617690-allow-unauthenticated-makes-all-untrusted 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'i386'
  7. buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable'
  8. setupaptarchive --no-update
  9. testfileexists() {
  10. msgtest 'Test for existence of file' "$1"
  11. test -e "$1" && msgpass || msgfail
  12. rm -f "$1"
  13. }
  14. testfilemissing() {
  15. msgtest 'Test for non-existance of file' "$1"
  16. test -e "$1" && msgfail || msgpass
  17. rm -f "$1"
  18. }
  19. testrun() {
  20. rm -rf rootdir/var/lib/apt
  21. testsuccess aptget update
  22. if [ "$1" = 'trusted' ]; then
  23. testsuccess aptget download cool
  24. testfileexists 'cool_1.0_i386.deb'
  25. testsuccess aptget download cool --allow-unauthenticated
  26. testfileexists 'cool_1.0_i386.deb'
  27. else
  28. testfailure aptget download cool
  29. testfilemissing 'cool_1.0_i386.deb'
  30. testsuccess aptget download cool --allow-unauthenticated
  31. testfileexists 'cool_1.0_i386.deb'
  32. fi
  33. mv aptarchive/pool/cool_1.0_i386.deb aptarchive/pool/cool_1.0_i386.deb.bak
  34. echo 'this is not a good package' > aptarchive/pool/cool_1.0_i386.deb
  35. testfailure aptget download cool
  36. testfilemissing cool_1.0_i386.deb
  37. testfailure aptget download cool --allow-unauthenticated # unauthenticated doesn't mean unchecked
  38. testfilemissing cool_1.0_i386.deb
  39. rm -f aptarchive/pool/cool_1.0_i386.deb
  40. mv aptarchive/pool/cool_1.0_i386.deb.bak aptarchive/pool/cool_1.0_i386.deb
  41. testsuccess aptget download cool --allow-unauthenticated
  42. testfileexists 'cool_1.0_i386.deb'
  43. }
  44. testrun 'trusted'
  45. find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
  46. testrun 'untrusted'
  47. changetowebserver
  48. testrun 'untrusted'