]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-ims
rework errors and warnings around insecure repositories
[apt.git] / test / integration / test-apt-update-ims
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6 setupenvironment
7 configarchitecture 'amd64'
8
9 insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10 insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
11
12 setupaptarchive --no-update
13 changetowebserver
14
15 runtest() {
16 if [ -n "$1" ]; then
17 configallowinsecurerepositories 'true'
18 else
19 configallowinsecurerepositories 'false'
20 fi
21
22 rm -rf rootdir/var/lib/apt/lists/
23
24 local TEST="test${1:-success}"
25 $TEST aptget update
26 if [ "$1" = 'failure' ]; then
27 # accept the outdated Release file so we can check Hit behaviour
28 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999
29 fi
30 listcurrentlistsdirectory > listsdir.lst
31 testsuccess grep '_Packages\(\.gz\)\?$' listsdir.lst
32 testsuccess grep '_Sources\(\.gz\)\?$' listsdir.lst
33 testsuccess grep '_Translation-en\(\.gz\)\?$' listsdir.lst
34
35 # ensure no leftovers in partial
36 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
37
38 # check that I-M-S header is kept in redirections
39 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
40 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 -q=0
41 sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
42 testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
43 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
44
45 # ensure that we still do a hash check for other files on ims hit of Release
46 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
47 $TEST aptget update -o Debug::Acquire::gpgv=1
48 cp rootdir/tmp/${TEST}.output goodsign.output
49 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
50 testsuccess grep '^Got GOODSIG, key ID:GOODSIG' goodsign.output
51 fi
52
53 # ensure no leftovers in partial
54 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
55 }
56
57 msgmsg 'InRelease'
58 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
59 Reading package lists..."
60 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
61 runtest
62 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
63 runtest
64
65 msgmsg 'Release/Release.gpg'
66 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
67 404 Not Found
68 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
69 Reading package lists..."
70 find aptarchive -name 'InRelease' -delete
71 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
72 runtest
73 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
74 runtest
75
76 msgmsg 'Release only'
77 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
78 404 Not Found
79 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
80 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
81 404 Not Found
82 Reading package lists...
83 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
84 N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use."
85 find aptarchive -name 'Release.gpg' -delete
86 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
87 runtest 'warning'
88 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
89 runtest 'warning'
90
91
92 # make the release file old
93 find aptarchive -name '*Release' -exec sed -i \
94 -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
95 -e '/^Valid-Until: / d' -e "/^Date: / a\
96 Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
97 signreleasefiles
98
99 msgmsg 'expired InRelease'
100 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
101 Reading package lists...
102 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
103 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
104 runtest 'failure'
105 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
106 runtest 'failure'
107
108 msgmsg 'expired Release/Release.gpg'
109 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
110 404 Not Found
111 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
112 Reading package lists...
113 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
114 find aptarchive -name 'InRelease' -delete
115 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
116 runtest 'failure'
117 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
118 runtest 'failure'
119
120 msgmsg 'expired Release only'
121 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
122 404 Not Found
123 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
124 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
125 404 Not Found
126 Reading package lists...
127 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
128 N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use.
129 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
130 find aptarchive -name 'Release.gpg' -delete
131 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
132 runtest 'failure' 'warning'
133 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
134 runtest 'failure' 'warning'
135
136
137 msgmsg 'no Release at all'
138 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
139 404 Not Found
140 Ign:2 http://localhost:${APTHTTPPORT} unstable Release
141 404 Not Found
142 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
143 404 Not Found
144 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
145 404 Not Found
146 Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
147 404 Not Found
148 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
149 404 Not Found
150 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
151 404 Not Found
152 Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
153 404 Not Found
154 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
155 404 Not Found
156 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
157 404 Not Found
158 Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
159 404 Not Found
160 Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
161 Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
162 Hit:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
163 Reading package lists...
164 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
165 N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use."
166 find aptarchive -name '*Release*' -delete
167 echo 'Acquire::GzipIndexes "0";
168 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
169 runtest 'warning'
170 echo 'Acquire::GzipIndexes "1";
171 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
172 runtest 'warning'