]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-not-modified
don't try other compressions on hashsum mismatch
[apt.git] / test / integration / test-apt-update-not-modified
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'amd64' 'i386'
9
10 insertpackage 'unstable' 'apt' 'all' '1.0'
11
12 setupaptarchive --no-update
13
14 methodtest() {
15 msgmsg 'Test InRelease with' "$1"
16 rm -rf rootdir/var/lib/apt/lists
17 cp -a aptarchive/dists aptarchive/dists.good
18 # get our cache populated
19 testsuccess aptget update
20 listcurrentlistsdirectory > listsdir.lst
21
22 # hit again with a good cache
23 testsuccessequal "Hit $1 unstable InRelease
24 Reading package lists..." aptget update
25 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
26
27 # drop an architecture, which means the file should be gone now
28 configarchitecture 'i386'
29 sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
30 testsuccessequal "Hit $1 unstable InRelease
31 Reading package lists..." aptget update
32 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
33
34 # readd arch so its downloaded again…
35 configarchitecture 'amd64' 'i386'
36 # … but oh noes, hashsum mismatch!
37 find aptarchive/dists/unstable/main/binary-amd64/ -type f -delete
38 cat >> aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF
39
40 Package: thisisbad
41 Architecture: amd64
42 Version: 1
43 EOF
44 compressfile aptarchive/dists/unstable/main/binary-amd64/Packages
45 testfailureequal "Hit $1 unstable InRelease
46 Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists.good/unstable/main/binary-amd64/Packages.gz') B]
47 W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch
48
49 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
50 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
51 rm -rf aptarchive/dists
52 cp -a aptarchive/dists.good aptarchive/dists
53
54 # … now everything is fine again
55 testsuccessequal "Hit $1 unstable InRelease
56 Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
57 Reading package lists..." aptget update
58 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
59
60 webserverconfig 'aptwebserver::support::modified-since' 'false'
61 webserverconfig 'aptwebserver::support::last-modified' 'false'
62 testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
63 Reading package lists..." aptget update
64 webserverconfig 'aptwebserver::support::modified-since' 'true'
65 webserverconfig 'aptwebserver::support::last-modified' 'true'
66
67 msgmsg 'Test Release.gpg with' "$1"
68 rm -rf rootdir/var/lib/apt/lists
69 find aptarchive/dists -name 'InRelease' -delete
70 # get our cache populated
71 testsuccess aptget update
72 listcurrentlistsdirectory > listsdir.lst
73
74 # hit again with a good cache
75 testsuccessequal "Ign $1 unstable InRelease
76 404 Not Found
77 Hit $1 unstable Release
78 Reading package lists..." aptget update
79 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
80
81 # drop an architecture, which means the file should be gone now
82 configarchitecture 'i386'
83 sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
84 testsuccessequal "Ign $1 unstable InRelease
85 404 Not Found
86 Hit $1 unstable Release
87 Reading package lists..." aptget update
88 testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
89
90 # readd arch so its downloaded again
91 configarchitecture 'amd64' 'i386'
92 testsuccessequal "Ign $1 unstable InRelease
93 404 Not Found
94 Hit $1 unstable Release
95 Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
96 Reading package lists..." aptget update
97 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
98
99 webserverconfig 'aptwebserver::support::modified-since' 'false'
100 webserverconfig 'aptwebserver::support::last-modified' 'false'
101 testsuccessequal "Ign $1 unstable InRelease
102 404 Not Found
103 Get:1 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
104 Reading package lists..." aptget update
105 webserverconfig 'aptwebserver::support::modified-since' 'true'
106 webserverconfig 'aptwebserver::support::last-modified' 'true'
107
108 rm -rf aptarchive/dists
109 cp -a aptarchive/dists.good aptarchive/dists
110 }
111
112 changetowebserver
113 methodtest 'http://localhost:8080'
114
115 changetohttpswebserver
116 methodtest 'https://localhost:4433'