]>
Commit | Line | Data |
---|---|---|
ba6b79bd DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
ba6b79bd DK |
6 | |
7 | setupenvironment | |
8 | configarchitecture 'amd64' 'i386' | |
9 | ||
1dd20368 | 10 | insertpackage 'unstable' 'apt' 'amd64,i386' '1.0' |
ba6b79bd DK |
11 | |
12 | setupaptarchive --no-update | |
13 | ||
14 | methodtest() { | |
8eafc759 | 15 | msgmsg 'Test InRelease with' "$1" |
ba6b79bd | 16 | rm -rf rootdir/var/lib/apt/lists |
58702f85 | 17 | cp -a aptarchive/dists aptarchive/dists.good |
ba6b79bd DK |
18 | # get our cache populated |
19 | testsuccess aptget update | |
20 | listcurrentlistsdirectory > listsdir.lst | |
21 | ||
22 | # hit again with a good cache | |
1eb1836f | 23 | testsuccessequal "Hit:1 $1 unstable InRelease |
ba6b79bd DK |
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 | |
1eb1836f | 30 | testsuccessequal "Hit:1 $1 unstable InRelease |
ba6b79bd DK |
31 | Reading package lists..." aptget update |
32 | testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" | |
33 | ||
58702f85 | 34 | # readd arch so its downloaded again… |
ba6b79bd | 35 | configarchitecture 'amd64' 'i386' |
58702f85 | 36 | # … but oh noes, hashsum mismatch! |
fb193b1c | 37 | SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') |
58702f85 DK |
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 | |
1eb1836f | 46 | testfailureequal "Hit:1 $1 unstable InRelease |
fb193b1c | 47 | Get:2 $1 unstable/main amd64 Packages [$SIZE B] |
1eb1836f | 48 | Err:2 $1 unstable/main amd64 Packages |
448c38bd | 49 | Hash Sum mismatch |
95278287 | 50 | Reading package lists... |
58702f85 | 51 | W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch |
58702f85 DK |
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 | |
1eb1836f DK |
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] | |
ba6b79bd DK |
60 | Reading package lists..." aptget update |
61 | testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)" | |
8eafc759 DK |
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 | |
8eafc759 DK |
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 | |
1eb1836f | 78 | testsuccessequal "Ign:1 $1 unstable InRelease |
8eafc759 | 79 | 404 Not Found |
1eb1836f | 80 | Hit:2 $1 unstable Release |
8eafc759 DK |
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 | |
1eb1836f | 87 | testsuccessequal "Ign:1 $1 unstable InRelease |
8eafc759 | 88 | 404 Not Found |
1eb1836f | 89 | Hit:2 $1 unstable Release |
8eafc759 DK |
90 | Reading package lists..." aptget update |
91 | testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)" | |
92 | ||
448c38bd | 93 | # readd arch so its downloaded again… |
8eafc759 | 94 | configarchitecture 'amd64' 'i386' |
448c38bd | 95 | # … but oh noes, hashsum mismatch! |
fb193b1c | 96 | SIZE=$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') |
448c38bd DK |
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 | |
1eb1836f | 105 | testfailureequal "Ign:1 $1 unstable InRelease |
448c38bd | 106 | 404 Not Found |
1eb1836f | 107 | Hit:2 $1 unstable Release |
fb193b1c | 108 | Get:4 $1 unstable/main amd64 Packages [$SIZE B] |
1eb1836f | 109 | Err:4 $1 unstable/main amd64 Packages |
448c38bd | 110 | Hash Sum mismatch |
95278287 | 111 | Reading package lists... |
448c38bd | 112 | W: Failed to fetch $1/dists/unstable/main/binary-amd64/Packages.gz Hash Sum mismatch |
448c38bd DK |
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 | |
1eb1836f | 120 | testsuccessequal "Ign:1 $1 unstable InRelease |
8eafc759 | 121 | 404 Not Found |
1eb1836f DK |
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] | |
8eafc759 DK |
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' | |
1eb1836f | 129 | testsuccessequal "Ign:1 $1 unstable InRelease |
8eafc759 | 130 | 404 Not Found |
1eb1836f | 131 | Get:2 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B] |
8eafc759 DK |
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 | |
8d041b4f DK |
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 | |
ba6b79bd DK |
157 | } |
158 | ||
159 | changetowebserver | |
6c0765c0 | 160 | methodtest "http://localhost:${APTHTTPPORT}" |
ba6b79bd DK |
161 | |
162 | changetohttpswebserver | |
6c0765c0 | 163 | methodtest "https://localhost:${APTHTTPSPORT}" |