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