]>
Commit | Line | Data |
---|---|---|
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' 'amd64,i386' '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 $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 $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 | SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') | |
38 | find aptarchive/dists/unstable/main/binary-amd64/ -type f -delete | |
39 | cat >> aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF | |
40 | ||
41 | Package: thisisbad | |
42 | Architecture: amd64 | |
43 | Version: 1 | |
44 | EOF | |
45 | compressfile aptarchive/dists/unstable/main/binary-amd64/Packages | |
46 | testfailureequal "Hit:1 $1 unstable InRelease | |
47 | Get:2 $1 unstable/main amd64 Packages [$SIZE B] | |
48 | Err:2 $1 unstable/main amd64 Packages | |
49 | Hash Sum mismatch | |
50 | Reading package lists... | |
51 | E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch | |
52 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update | |
53 | testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" | |
54 | rm -rf aptarchive/dists | |
55 | cp -a aptarchive/dists.good aptarchive/dists | |
56 | ||
57 | # … now everything is fine again | |
58 | testsuccessequal "Hit:1 $1 unstable InRelease | |
59 | Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B] | |
60 | Reading package lists..." aptget update | |
61 | testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)" | |
62 | ||
63 | webserverconfig 'aptwebserver::support::modified-since' 'false' | |
64 | webserverconfig 'aptwebserver::support::last-modified' 'false' | |
65 | testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B] | |
66 | Reading package lists..." aptget update | |
67 | webserverconfig 'aptwebserver::support::modified-since' 'true' | |
68 | webserverconfig 'aptwebserver::support::last-modified' 'true' | |
69 | ||
70 | msgmsg 'Test Release.gpg with' "$1" | |
71 | rm -rf rootdir/var/lib/apt/lists | |
72 | find aptarchive/dists -name 'InRelease' -delete | |
73 | # get our cache populated | |
74 | testsuccess aptget update | |
75 | listcurrentlistsdirectory > listsdir.lst | |
76 | ||
77 | # hit again with a good cache | |
78 | testsuccessequal "Ign:1 $1 unstable InRelease | |
79 | 404 Not Found | |
80 | Hit:2 $1 unstable Release | |
81 | Reading package lists..." aptget update | |
82 | testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)" | |
83 | ||
84 | # drop an architecture, which means the file should be gone now | |
85 | configarchitecture 'i386' | |
86 | sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst | |
87 | testsuccessequal "Ign:1 $1 unstable InRelease | |
88 | 404 Not Found | |
89 | Hit:2 $1 unstable Release | |
90 | Reading package lists..." aptget update | |
91 | testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" | |
92 | ||
93 | # readd arch so its downloaded again… | |
94 | configarchitecture 'amd64' 'i386' | |
95 | # … but oh noes, hashsum mismatch! | |
96 | SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') | |
97 | find aptarchive/dists/unstable/main/binary-amd64/ -type f -delete | |
98 | cat >> aptarchive/dists/unstable/main/binary-amd64/Packages <<EOF | |
99 | ||
100 | Package: thisisbad | |
101 | Architecture: amd64 | |
102 | Version: 1 | |
103 | EOF | |
104 | compressfile aptarchive/dists/unstable/main/binary-amd64/Packages | |
105 | testfailureequal "Ign:1 $1 unstable InRelease | |
106 | 404 Not Found | |
107 | Hit:2 $1 unstable Release | |
108 | Get:4 $1 unstable/main amd64 Packages [$SIZE B] | |
109 | Err:4 $1 unstable/main amd64 Packages | |
110 | Hash Sum mismatch | |
111 | Reading package lists... | |
112 | E: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch | |
113 | E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update | |
114 | testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" | |
115 | rm -rf aptarchive/dists | |
116 | cp -a aptarchive/dists.good aptarchive/dists | |
117 | find aptarchive/dists -name 'InRelease' -delete | |
118 | ||
119 | # … now everything is fine again | |
120 | testsuccessequal "Ign:1 $1 unstable InRelease | |
121 | 404 Not Found | |
122 | Hit:2 $1 unstable Release | |
123 | Get:4 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B] | |
124 | Reading package lists..." aptget update | |
125 | testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)" | |
126 | ||
127 | webserverconfig 'aptwebserver::support::modified-since' 'false' | |
128 | webserverconfig 'aptwebserver::support::last-modified' 'false' | |
129 | testsuccessequal "Ign:1 $1 unstable InRelease | |
130 | 404 Not Found | |
131 | Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B] | |
132 | Reading package lists..." aptget update | |
133 | webserverconfig 'aptwebserver::support::modified-since' 'true' | |
134 | webserverconfig 'aptwebserver::support::last-modified' 'true' | |
135 | ||
136 | rm -rf aptarchive/dists | |
137 | cp -a aptarchive/dists.good aptarchive/dists | |
138 | ||
139 | # new release file, but the indexes are the same | |
140 | redatereleasefiles '+2 hours' | |
141 | ||
142 | rm -rf rootdir/var/lib/apt/lists.good | |
143 | cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good | |
144 | testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B] | |
145 | Reading package lists..." aptget update | |
146 | ||
147 | rm -rf rootdir/var/lib/apt/lists | |
148 | cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists | |
149 | find rootdir/var/lib/apt/lists -name '*_Packages*' -delete | |
150 | testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B] | |
151 | Get:2 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B] | |
152 | Get:3 $1 unstable/main i386 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-i386/Packages.gz') B] | |
153 | Reading package lists..." aptget update | |
154 | ||
155 | rm -rf aptarchive/dists | |
156 | cp -a aptarchive/dists.good aptarchive/dists | |
157 | } | |
158 | ||
159 | changetowebserver | |
160 | methodtest "http://localhost:${APTHTTPPORT}" | |
161 | ||
162 | changetohttpswebserver | |
163 | methodtest "https://localhost:${APTHTTPSPORT}" |