]>
Commit | Line | Data |
---|---|---|
47aca3cf MV |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
de81b2e2 DK |
4 | # ensure that an update will only succeed entirely or not at all |
5 | ||
3abb6a6a DK |
6 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
7 | . "$TESTDIR/framework" | |
47aca3cf MV |
8 | |
9 | setupenvironment | |
de81b2e2 | 10 | configarchitecture 'i386' |
58702f85 | 11 | configcompression '.' 'gz' |
47aca3cf | 12 | |
1dd20368 DK |
13 | insertpackage 'unstable' 'foo' 'i386' '1.0' |
14 | insertsource 'unstable' 'foo' 'i386' '1.0' | |
47aca3cf MV |
15 | |
16 | setupaptarchive --no-update | |
47aca3cf | 17 | |
de81b2e2 | 18 | breakfile() { |
58702f85 DK |
19 | mv "${1}" "${1}.bak" |
20 | mv "${1}.gz" "${1}.gz.bak" | |
de81b2e2 | 21 | cat > "$1" <<EOF |
47aca3cf MV |
22 | Package: bar |
23 | EOF | |
de81b2e2 DK |
24 | compressfile "$1" |
25 | } | |
26 | restorefile() { | |
27 | mv "${1}.bak" "$1" | |
58702f85 | 28 | mv "${1}.gz.bak" "${1}.gz" |
de81b2e2 DK |
29 | } |
30 | ||
de81b2e2 | 31 | testrun() { |
8d041b4f DK |
32 | rm -rf aptarchive/dists.good |
33 | cp -a aptarchive/dists aptarchive/dists.good | |
1dd20368 DK |
34 | insertpackage 'unstable' 'bar' 'i386' '1.0' |
35 | insertsource 'unstable' 'bar' 'i386' '1.0' | |
8d041b4f DK |
36 | buildaptarchivefromfiles '+1 hour' |
37 | ||
de81b2e2 DK |
38 | # produce an unsigned repository |
39 | find aptarchive \( -name 'Release.gpg' -o -name 'InRelease' \) -delete | |
40 | testfailure aptget update --no-allow-insecure-repositories | |
846bc058 | 41 | testfileequal "$1" "$(listcurrentlistsdirectory)" |
de81b2e2 DK |
42 | |
43 | # signed but broken | |
44 | signreleasefiles | |
47aca3cf | 45 | |
8d041b4f DK |
46 | onehashbroken() { |
47 | testfailure aptget update | |
48 | # each file generates two messages with this string | |
49 | testequal '2' grep --count 'Hash Sum mismatch' rootdir/tmp/testfailure.output | |
50 | testfileequal "$1" "$(listcurrentlistsdirectory)" | |
51 | } | |
52 | ||
de81b2e2 | 53 | breakfile aptarchive/dists/unstable/main/binary-i386/Packages |
8d041b4f | 54 | onehashbroken "$1" |
de81b2e2 DK |
55 | restorefile aptarchive/dists/unstable/main/binary-i386/Packages |
56 | ||
57 | breakfile aptarchive/dists/unstable/main/source/Sources | |
8d041b4f | 58 | onehashbroken "$1" |
de81b2e2 | 59 | restorefile aptarchive/dists/unstable/main/source/Sources |
8d041b4f DK |
60 | |
61 | rm -rf aptarchive/dists | |
62 | cp -a aptarchive/dists.good aptarchive/dists | |
de81b2e2 DK |
63 | } |
64 | ||
65 | testsetup() { | |
66 | msgmsg 'Test with no initial data over' "$1" | |
67 | rm -rf rootdir/var/lib/apt/lists | |
8fe964f1 | 68 | mkdir -p rootdir/var/lib/apt/lists/partial |
846bc058 | 69 | listcurrentlistsdirectory > listsdir.lst |
de81b2e2 DK |
70 | testrun 'listsdir.lst' |
71 | ||
72 | msgmsg 'Test with initial data over' "$1" | |
58702f85 DK |
73 | rm -rf rootdir/var/lib/apt/lists |
74 | testsuccess aptget update -o Debug::pkgAcquire::Worker=1 | |
846bc058 | 75 | listcurrentlistsdirectory > listsdir.lst |
de81b2e2 DK |
76 | testrun 'listsdir.lst' |
77 | } | |
78 | ||
79 | testsetup 'file' | |
ba6b79bd | 80 | |
de81b2e2 | 81 | changetowebserver |
ba6b79bd DK |
82 | webserverconfig 'aptwebserver::support::modified-since' 'false' "$1" |
83 | webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also | |
dcbb364f | 84 | webserverconfig 'aptwebserver::support::range' 'false' "$1" |
ba6b79bd | 85 | |
de81b2e2 | 86 | testsetup 'http' |
2737f28a | 87 | |
ba6b79bd DK |
88 | changetohttpswebserver |
89 | ||
90 | testsetup 'https' |