]>
Commit | Line | Data |
---|---|---|
ae99ce2e DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
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' | |
3b5607fc MV |
19 | if downloadfile http://localhost:8080/holygrail ./knights-talking >/dev/null; then |
20 | msgpass | |
21 | else | |
22 | msgfail | |
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 | |
09475beb MV |
39 | msgtest 'Got expected failure message' 'apt-get update' |
40 | aptget update -qq 2>&1 | grep -q 'W:.*Does not start with a cleartext signature' && msgpass || msgfail | |
ae99ce2e DK |
41 | |
42 | ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0 | |
546dbfc8 DK |
43 | testequal 'lock |
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 | |
48 | echo 'peng neee-wom' > $LISTS/localhost:8080_dists_stable_${f} | |
49 | done | |
50 | ||
09475beb MV |
51 | msgtest 'Got expected failure message in' 'apt-get update' |
52 | aptget update -qq 2>&1 | grep -q 'W:.*Does not start with a cleartext signature' && msgpass || msgfail | |
ae99ce2e DK |
53 | |
54 | ensure_n_canary_strings_in_dir $LISTS 'peng neee-wom' 4 | |
55 | ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0 | |
56 | ||
57 | # and now with a pre-existing InRelease file | |
58 | echo 'peng neee-wom' > $LISTS/localhost:8080_dists_stable_InRelease | |
59 | rm -f $LISTS/localhost:8080_dists_stable_Release $LISTS/localhost:8080_dists_stable_Release.gpg | |
60 | msgtest 'excpected failure of' 'apt-get update' | |
09475beb | 61 | aptget update -qq 2>&1 | grep -q 'W:.*Does not start with a cleartext signature' && msgpass || msgfail |
ae99ce2e DK |
62 | |
63 | ensure_n_canary_strings_in_dir $LISTS 'peng neee-wom' 3 | |
64 | ensure_n_canary_strings_in_dir $LISTS 'ni ni ni' 0 |