]> git.saurik.com Git - apt.git/blame - test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
report warnings&errors consistently in edit-sources
[apt.git] / test / integration / test-ubuntu-bug-346386-apt-get-update-paywall
CommitLineData
ae99ce2e
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
ae99ce2e
DK
6
7setupenvironment
8configarchitecture 'native'
9
10insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable'
11insertsource 'unstable' 'unrelated' 'all' '1.0' 'stable'
12
13echo 'ni ni ni' > aptarchive/knights
14
15setupaptarchive
2fac0dd5 16changetowebserver -o 'aptwebserver::overwrite::.*InRelease::filename=/knights' -o 'aptwebserver::overwrite::.*::filename=/knights'
ae99ce2e
DK
17
18msgtest 'Acquire test file from the webserver to check' 'overwrite'
6c0765c0 19if downloadfile http://localhost:${APTHTTPPORT}/holygrail ./knights-talking >/dev/null; then
b2640c0a 20 msgpass
3b5607fc 21else
b2640c0a 22 msgfail
3b5607fc 23fi
ae99ce2e 24
ae99ce2e
DK
25testfileequal knights-talking 'ni ni ni'
26
27ensure_n_canary_strings_in_dir() {
28 local DIR="$1"
29 local CANARY_STRING="$2"
30 local EXPECTED_N="$3"
31
32 msgtest "Testing in $DIR for $EXPECTED_N canary" "$CANARY_STRING"
33 local N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
34 test "$N" = "$EXPECTED_N" && msgpass || msgfail "Expected $EXPECTED_N canaries, got $N"
35}
36
2fac0dd5
DK
37runtests() {
38 LISTS='rootdir/var/lib/apt/lists'
39 rm -rf "$LISTS"
40 testfailure aptget update
41 testsuccess grep "$1" rootdir/tmp/testfailure.output
ae99ce2e 42
2fac0dd5
DK
43 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
44 testequal 'lock
b2640c0a 45partial' ls "$LISTS"
ae99ce2e 46
2fac0dd5
DK
47 # and again with pre-existing files with "valid data" which should remain
48 for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do
49 echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
50 chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}"
51 done
ae99ce2e 52
2fac0dd5
DK
53 testfailure aptget update
54 testsuccess grep "$1" rootdir/tmp/testfailure.output
ae99ce2e 55
2fac0dd5
DK
56 ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4
57 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
ae99ce2e 58
2fac0dd5
DK
59 # and now with a pre-existing InRelease file
60 echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
61 chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease"
62 rm -f "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release" "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release.gpg"
63 msgtest 'excpected failure of' 'apt-get update'
64 testfailure aptget update
65 testsuccess grep "$1" rootdir/tmp/testfailure.output
ae99ce2e 66
2fac0dd5
DK
67 ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 3
68 ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0
69}
70runtests '^E:.*Clearsigned file .*NOSPLIT.*'
71webserverconfig 'aptwebserver::overwrite::.*InRelease::filename' '/404'
72runtests '^E:.*Signed file .*NODATA.*'