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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. echo '601 Configuration
  14. Config-Item: Acquire::http::DependOnSTDIN=0
  15. 600 Acquire URI
  16. URI: http://localhost:8080/holygrail
  17. Filename: knights-talking
  18. ' | http >/dev/null 2>&1 && msgpass || msgfail
  19. testfileequal knights-talking 'ni ni ni'
  20. ensure_n_canary_strings_in_dir() {
  21. local DIR="$1"
  22. local CANARY_STRING="$2"
  23. local EXPECTED_N="$3"
  24. msgtest "Testing in $DIR for $EXPECTED_N canary" "$CANARY_STRING"
  25. local N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
  26. test "$N" = "$EXPECTED_N" && msgpass || msgfail "Expected $EXPECTED_N canaries, got $N"
  27. }
  28. LISTS='rootdir/var/lib/apt/lists'
  29. rm -rf rootdir/var/lib/apt/lists
  30. msgtest 'Got expected NODATA failure in' 'apt-get update'
  31. aptget update -qq 2>&1 | grep -q 'E: GPG error.*NODATA' && msgpass || msgfail
  32. ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0
  33. testequal '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. msgtest 'Got expected NODATA failure in' 'apt-get update'
  39. aptget update -qq 2>&1 | grep -q 'E: GPG error.*NODATA' && msgpass || msgfail
  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. aptget update -qq 2>&1 | grep -q 'E: GPG error.*NODATA' && msgpass || msgfail
  47. ensure_n_canary_strings_in_dir $LISTS 'peng neee-wom' 3
  48. ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0