test-ubuntu-bug-346386-apt-get-update-paywall 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture 'native'
  7. insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable'
  8. insertsource 'unstable' 'unrelated' 'all' '1.0' 'stable'
  9. echo 'ni ni ni' > aptarchive/knights
  10. setupaptarchive
  11. changetowebserver -o 'aptwebserver::overwrite::.*::filename=/knights'
  12. msgtest 'Acquire test file from the webserver to check' 'overwrite'
  13. if downloadfile http://localhost:8080/holygrail ./knights-talking >/dev/null; then
  14. msgpass
  15. else
  16. msgfail
  17. fi
  18. testfileequal knights-talking 'ni ni ni'
  19. ensure_n_canary_strings_in_dir() {
  20. local DIR="$1"
  21. local CANARY_STRING="$2"
  22. local EXPECTED_N="$3"
  23. msgtest "Testing in $DIR for $EXPECTED_N canary" "$CANARY_STRING"
  24. local N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
  25. test "$N" = "$EXPECTED_N" && msgpass || msgfail "Expected $EXPECTED_N canaries, got $N"
  26. }
  27. LISTS='rootdir/var/lib/apt/lists'
  28. rm -rf rootdir/var/lib/apt/lists
  29. testfailure aptget update
  30. testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
  31. ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0
  32. testequal 'lock
  33. partial' ls $LISTS
  34. # and again with pre-existing files with "valid data" which should remain
  35. for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do
  36. echo 'peng neee-wom' > $LISTS/localhost:8080_dists_stable_${f}
  37. done
  38. testfailure aptget update
  39. testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
  40. ensure_n_canary_strings_in_dir $LISTS 'peng neee-wom' 4
  41. ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0
  42. # and now with a pre-existing InRelease file
  43. echo 'peng neee-wom' > $LISTS/localhost:8080_dists_stable_InRelease
  44. rm -f $LISTS/localhost:8080_dists_stable_Release $LISTS/localhost:8080_dists_stable_Release.gpg
  45. msgtest 'excpected failure of' 'apt-get update'
  46. testfailure aptget update
  47. testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
  48. ensure_n_canary_strings_in_dir $LISTS 'peng neee-wom' 3
  49. ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0