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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. chmod 644 "$LISTS/localhost:8080_dists_stable_${f}"
  38. done
  39. testfailure aptget update
  40. testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
  41. ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4
  42. ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
  43. # and now with a pre-existing InRelease file
  44. echo 'peng neee-wom' > "$LISTS/localhost:8080_dists_stable_InRelease"
  45. chmod 644 "$LISTS/localhost:8080_dists_stable_InRelease"
  46. rm -f "$LISTS/localhost:8080_dists_stable_Release" "$LISTS/localhost:8080_dists_stable_Release.gpg"
  47. msgtest 'excpected failure of' 'apt-get update'
  48. testfailure aptget update
  49. testsuccess grep '^W:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output
  50. ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 3
  51. ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0