]> git.saurik.com Git - apt.git/blob - test/integration/test-bug-818628-unreadable-source
report warnings&errors consistently in edit-sources
[apt.git] / test / integration / test-bug-818628-unreadable-source
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'amd64'
8
9 if [ "$(id -u)" = '0' ]; then
10 msgskip 'Tests for unreadable files do not work as root'
11 exit 0
12 fi
13
14 insertinstalledpackage 'foo' 'amd64' '1'
15 insertpackage 'unstable' 'foo' 'amd64' '2'
16
17 setupaptarchive --no-update
18
19 touch rootdir/etc/apt/apt.conf.d/unreadable.conf
20 touch rootdir/etc/apt/preferences.d/unreadable.pref
21
22 addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
23 chmod -r rootdir/etc/apt/trusted.gpg.d
24 testfailure apt update
25 chmod +r rootdir/etc/apt/trusted.gpg.d
26 testsuccess apt update
27 testsuccess apt policy foo
28 testsuccess apt search foo
29 testsuccessequal "Listing...
30 foo/unstable 2 amd64 [upgradable from: 1]
31 N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable
32
33 runthemall() {
34 local ERR1="$1"
35 local ERR2="$1$2"
36 testfailureequal "$ERR1" aptcache policy
37 testfailureequal "$ERR1" aptcache policy foo
38 testfailureequal "$ERR2" aptcache depends foo
39 testfailureequal "$ERR2" aptcache rdepends foo
40 testfailureequal "$ERR2" aptcache search foo
41 testfailureequal "$ERR1" apt policy
42 testfailureequal "$ERR1" apt policy foo
43 testfailureequal "$ERR2" apt depends foo
44 testfailureequal "$ERR2" apt rdepends foo
45 testfailureequal "$ERR2" apt search foo
46 testfailureequal "$ERR2" apt list --upgradable
47 testfailureequal "$ERR2" apt show foo
48 testfailureequal "$ERR2" aptcache show foo --no-all-versions
49 testfailureequal "$ERR2" aptmark auto foo
50 testfailureequal "$ERR2" aptmark manual foo
51 testfailureequal "$ERR2" aptmark auto foo
52 }
53 echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf
54
55 msgmsg 'Unreadable sources file'
56 chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
57 runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied)
58 E: The list of sources could not be read."
59 chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
60
61 msgmsg 'Unreadable config file'
62 chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
63 runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)"
64 chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf
65
66 msgmsg 'Unreadable preferences file'
67 chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
68 runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
69 chmod +r rootdir/etc/apt/preferences.d/unreadable.pref
70
71 msgmsg 'Unreadable sources directory'
72 chmod -r rootdir/etc/apt/sources.list.d
73 runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" "
74 W: You may want to run apt-get update to correct these problems
75 E: The package cache file is corrupted"
76 chmod +r rootdir/etc/apt/sources.list.d
77
78 msgmsg 'Unreadable config directory'
79 chmod -r rootdir/etc/apt/apt.conf.d
80 runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
81 chmod +r rootdir/etc/apt/apt.conf.d
82
83 msgmsg 'Unreadable preferences directory'
84 chmod -r rootdir/etc/apt/preferences.d
85 runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
86 chmod +r rootdir/etc/apt/preferences.d