]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-ims
refer to apt-secure(8) in unsecure repositories warning
[apt.git] / test / integration / test-apt-update-ims
CommitLineData
63d0f853
MV
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6setupenvironment
7configarchitecture 'amd64'
8
ba6b79bd
DK
9insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
63d0f853 11
846bc058 12setupaptarchive --no-update
63d0f853
MV
13changetowebserver
14
47450dea 15runtest() {
ba6b79bd
DK
16 if [ -n "$1" ]; then
17 configallowinsecurerepositories 'true'
18 else
19 configallowinsecurerepositories 'false'
20 fi
4fa34122 21
ba6b79bd 22 rm -rf rootdir/var/lib/apt/lists/
63d0f853 23
ba6b79bd
DK
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
90b56f54 28 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999
4fa34122 29 fi
ba6b79bd
DK
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
47450dea
MV
34
35 # ensure no leftovers in partial
ba6b79bd 36 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
47450dea
MV
37
38 # check that I-M-S header is kept in redirections
ba6b79bd 39 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
f18f2338 40 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 -q=0
ba6b79bd
DK
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
1eb1836f 46 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
ba6b79bd
DK
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
47450dea
MV
52
53 # ensure no leftovers in partial
ba6b79bd 54 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
47450dea
MV
55}
56
ba6b79bd 57msgmsg 'InRelease'
6c0765c0
DK
58EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
59Reading package lists..."
ba6b79bd 60echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
1ce24318 61runtest
ba6b79bd 62echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
1ce24318
MV
63runtest
64
ba6b79bd 65msgmsg 'Release/Release.gpg'
6c0765c0 66EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
4dbfe436 67 404 Not Found
6c0765c0
DK
68Hit:2 http://localhost:${APTHTTPPORT} unstable Release
69Reading package lists..."
ab25bf1f 70find aptarchive -name 'InRelease' -delete
ba6b79bd 71echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
47450dea 72runtest
ba6b79bd 73echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
47450dea 74runtest
f3097647 75
ba6b79bd 76msgmsg 'Release only'
6c0765c0 77EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
4dbfe436 78 404 Not Found
6c0765c0
DK
79Hit:2 http://localhost:${APTHTTPPORT} unstable Release
80Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
4dbfe436 81 404 Not Found
9d653a6d 82Reading package lists...
f18f2338 83W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
002b1bc4
DK
84N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use.
85N: See apt-secure(8) manpage for repository creation and user configuration details."
ba6b79bd
DK
86find aptarchive -name 'Release.gpg' -delete
87echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
88runtest 'warning'
89echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
90runtest 'warning'
91
92
93# make the release file old
94find aptarchive -name '*Release' -exec sed -i \
95 -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
96 -e '/^Valid-Until: / d' -e "/^Date: / a\
97Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
98signreleasefiles
99
100msgmsg 'expired InRelease'
6c0765c0 101EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
95278287 102Reading package lists...
6c0765c0 103E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
ba6b79bd
DK
104echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
105runtest 'failure'
106echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
107runtest 'failure'
108
109msgmsg 'expired Release/Release.gpg'
6c0765c0 110EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 111 404 Not Found
6c0765c0 112Hit:2 http://localhost:${APTHTTPPORT} unstable Release
95278287 113Reading package lists...
6c0765c0 114E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
ba6b79bd
DK
115find aptarchive -name 'InRelease' -delete
116echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
117runtest 'failure'
118echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
119runtest 'failure'
f3097647 120
ba6b79bd 121msgmsg 'expired Release only'
6c0765c0 122EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 123 404 Not Found
6c0765c0
DK
124Hit:2 http://localhost:${APTHTTPPORT} unstable Release
125Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
ba6b79bd 126 404 Not Found
95278287 127Reading package lists...
f18f2338
DK
128W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
129N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use.
002b1bc4 130N: See apt-secure(8) manpage for repository creation and user configuration details.
6c0765c0 131E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
ab25bf1f 132find aptarchive -name 'Release.gpg' -delete
ba6b79bd
DK
133echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
134runtest 'failure' 'warning'
135echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
136runtest 'failure' 'warning'
f3097647 137
f3097647 138
ba6b79bd 139msgmsg 'no Release at all'
6c0765c0 140EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 141 404 Not Found
6c0765c0 142Ign:2 http://localhost:${APTHTTPPORT} unstable Release
ba6b79bd 143 404 Not Found
6c0765c0 144Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 145 404 Not Found
6c0765c0 146Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 147 404 Not Found
6c0765c0 148Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 149 404 Not Found
6c0765c0 150Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 151 404 Not Found
6c0765c0 152Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 153 404 Not Found
6c0765c0 154Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 155 404 Not Found
6c0765c0 156Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 157 404 Not Found
6c0765c0 158Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 159 404 Not Found
6c0765c0 160Ign:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 161 404 Not Found
6c0765c0
DK
162Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
163Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
164Hit:5 http://localhost:${APTHTTPPORT} unstable/main Translation-en
ba6b79bd 165Reading package lists...
f18f2338 166W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
002b1bc4
DK
167N: Data from such a repository can not be authenticated and is therefore potentially dangerous to use.
168N: See apt-secure(8) manpage for repository creation and user configuration details."
ba6b79bd
DK
169find aptarchive -name '*Release*' -delete
170echo 'Acquire::GzipIndexes "0";
171Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
172runtest 'warning'
173echo 'Acquire::GzipIndexes "1";
174Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
175runtest 'warning'