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