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