]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-failure-propagation
test: Always install dpkg into our tests, regardless of MA
[apt.git] / test / integration / test-apt-update-failure-propagation
CommitLineData
002b1bc4
DK
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6setupenvironment
7configarchitecture 'amd64'
8
9buildsimplenativepackage 'foo' 'all' '1' 'stable'
10buildsimplenativepackage 'foo' 'all' '2' 'sid'
11setupaptarchive --no-update
12
13NEWMETHODS="$(readlink -f rootdir)/usr/lib/apt/methods"
14OLDMETHODS="$(readlink -f rootdir/usr/lib/apt/methods)"
15rm "$NEWMETHODS"
16mkdir "$NEWMETHODS"
17backupIFS="$IFS"
18IFS="$(printf "\n\b")"
782c60a6 19for METH in $(find "$OLDMETHODS" -maxdepth 1 ! -type d); do
002b1bc4
DK
20 ln -s "$OLDMETHODS/$(basename "$METH")" "$NEWMETHODS"
21done
22IFS="$backupIFS"
23
24changetohttpswebserver
25for FILE in rootdir/etc/apt/sources.list.d/*-sid-* ; do
26 sed -i -e 's#https:#http:#' -e "s#:${APTHTTPSPORT}/#:${APTHTTPPORT}/#" "$FILE"
27done
28
29pretest() {
c9c91069 30 msgmsg "$@"
002b1bc4 31 rm -rf rootdir/var/lib/apt/lists
87d6947d 32 testsuccessequal 'N: Unable to locate package foo' aptcache policy foo
002b1bc4 33}
c9c91069 34pretest 'initialize test' 'update'
002b1bc4
DK
35testsuccess aptget update
36testsuccessequal "foo:
37 Installed: (none)
38 Candidate: 2
39 Version table:
40 2 500
1dd20368 41 500 http://localhost:${APTHTTPPORT} sid/main all Packages
002b1bc4 42 1 500
1dd20368 43 500 https://localhost:${APTHTTPSPORT} stable/main all Packages" aptcache policy foo
002b1bc4 44
c9c91069 45pretest 'not found' 'release files'
002b1bc4 46mv aptarchive/dists/stable aptarchive/dists/stable.good
87d6947d 47testfailuremsg "E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
83960341 48N: Updating from such a repository can't be done securely, and is therefore disabled by default.
87d6947d
DK
49N: See apt-secure(8) manpage for repository creation and user configuration details." apt update
50testfailure aptget update --no-allow-insecure-repositories
1dd20368 51testequalor2 "Hit:1 http://localhost:${APTHTTPPORT} sid InRelease
002b1bc4
DK
52Ign:2 https://localhost:${APTHTTPSPORT} stable InRelease
53 404 Not Found
54Err:3 https://localhost:${APTHTTPSPORT} stable Release
55 404 Not Found
56Reading package lists...
57E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
83960341 58N: Updating from such a repository can't be done securely, and is therefore disabled by default.
1dd20368
DK
59N: See apt-secure(8) manpage for repository creation and user configuration details." "Ign:1 https://localhost:${APTHTTPSPORT} stable InRelease
60 404 Not Found
61Err:2 https://localhost:${APTHTTPSPORT} stable Release
62 404 Not Found
63Hit:3 http://localhost:${APTHTTPPORT} sid InRelease
64Reading package lists...
65E: The repository 'https://localhost:${APTHTTPSPORT} stable Release' does not have a Release file.
83960341 66N: Updating from such a repository can't be done securely, and is therefore disabled by default.
1dd20368
DK
67N: See apt-secure(8) manpage for repository creation and user configuration details." cat rootdir/tmp/testfailure.output
68
002b1bc4
DK
69mv aptarchive/dists/stable.good aptarchive/dists/stable
70posttest() {
71 testsuccessequal "foo:
72 Installed: (none)
73 Candidate: 2
74 Version table:
75 2 500
1dd20368 76 500 http://localhost:${APTHTTPPORT} sid/main all Packages" aptcache policy foo
002b1bc4
DK
77}
78posttest
79
c9c91069
DK
80pretest 'method disabled' 'https'
81echo 'Dir::Bin::Methods::https "false";' > rootdir/etc/apt/apt.conf.d/99disable-https
82testfailuremsg "E: The method 'https' is explicitly disabled via configuration.
83N: If you meant to use Tor remember to use tor+https instead of https.
84E: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
85E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
86rm -f rootdir/etc/apt/apt.conf.d/99disable-https
87posttest
88
89pretest 'method not installed' 'https'
002b1bc4
DK
90rm "${NEWMETHODS}/https"
91testfailuremsg "E: The method driver ${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods/https could not be found.
87d6947d 92N: Is the package apt-transport-https installed?
f695e761 93E: Failed to fetch https://localhost:${APTHTTPSPORT}/dists/stable/InRelease
002b1bc4
DK
94E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update
95posttest
96
c9c91069 97pretest 'https connection refused' 'doom port'
002b1bc4
DK
98for FILE in rootdir/etc/apt/sources.list.d/*-stable-* ; do
99 # lets see how many testservers run also Doom
100 sed -i -e "s#:${APTHTTPSPORT}/#:666/#" "$FILE"
101done
c9c91069 102testwarning aptget update -o Dir::Bin::Methods::https="${OLDMETHODS}/https"
30c8107e
DK
103testequalor2 "W: Failed to fetch https://localhost:666/dists/stable/InRelease Failed to connect to localhost port 666: Connection refused
104W: Some index files failed to download. They have been ignored, or old ones used instead." "W: Failed to fetch https://localhost:666/dists/stable/InRelease couldn't connect to host
105W: Some index files failed to download. They have been ignored, or old ones used instead." tail -n 2 rootdir/tmp/testwarning.output
002b1bc4 106posttest