]>
Commit | Line | Data |
---|---|---|
ae99ce2e DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
ae99ce2e DK |
6 | |
7 | setupenvironment | |
8 | configarchitecture 'native' | |
9 | ||
10 | insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable' | |
11 | insertsource 'unstable' 'unrelated' 'all' '1.0' 'stable' | |
12 | ||
13 | echo 'ni ni ni' > aptarchive/knights | |
14 | ||
15 | setupaptarchive | |
16 | changetowebserver -o 'aptwebserver::overwrite::.*::filename=/knights' | |
17 | ||
18 | msgtest 'Acquire test file from the webserver to check' 'overwrite' | |
6c0765c0 | 19 | if downloadfile http://localhost:${APTHTTPPORT}/holygrail ./knights-talking >/dev/null; then |
b2640c0a | 20 | msgpass |
3b5607fc | 21 | else |
b2640c0a | 22 | msgfail |
3b5607fc | 23 | fi |
ae99ce2e | 24 | |
ae99ce2e DK |
25 | testfileequal knights-talking 'ni ni ni' |
26 | ||
27 | ensure_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 | ||
37 | LISTS='rootdir/var/lib/apt/lists' | |
38 | rm -rf rootdir/var/lib/apt/lists | |
dd676dc7 | 39 | testfailure aptget update |
f695e761 | 40 | testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output |
ae99ce2e | 41 | |
b2640c0a | 42 | ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0 |
546dbfc8 | 43 | testequal 'lock |
b2640c0a | 44 | partial' ls "$LISTS" |
ae99ce2e DK |
45 | |
46 | # and again with pre-existing files with "valid data" which should remain | |
47 | for f in Release Release.gpg main_binary-amd64_Packages main_source_Sources; do | |
6c0765c0 DK |
48 | echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}" |
49 | chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_${f}" | |
ae99ce2e DK |
50 | done |
51 | ||
dd676dc7 | 52 | testfailure aptget update |
f695e761 | 53 | testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output |
ae99ce2e | 54 | |
b2640c0a DK |
55 | ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 4 |
56 | ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0 | |
ae99ce2e DK |
57 | |
58 | # and now with a pre-existing InRelease file | |
6c0765c0 DK |
59 | echo 'peng neee-wom' > "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease" |
60 | chmod 644 "$LISTS/localhost:${APTHTTPPORT}_dists_stable_InRelease" | |
61 | rm -f "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release" "$LISTS/localhost:${APTHTTPPORT}_dists_stable_Release.gpg" | |
ae99ce2e | 62 | msgtest 'excpected failure of' 'apt-get update' |
dd676dc7 | 63 | testfailure aptget update |
f695e761 | 64 | testsuccess grep '^E:.*Clearsigned file .*NOSPLIT.*' rootdir/tmp/testfailure.output |
ae99ce2e | 65 | |
b2640c0a DK |
66 | ensure_n_canary_strings_in_dir "$LISTS" 'peng neee-wom' 3 |
67 | ensure_n_canary_strings_in_dir "$LISTS" 'ni ni ni' 0 |