]> git.saurik.com Git - apt.git/blob - test/integration/test-sourceslist-trusted-options
testcases runable as root
[apt.git] / test / integration / test-sourceslist-trusted-options
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'amd64'
9
10 buildsimplenativepackage 'foo' 'amd64' '1' 'stable'
11 buildsimplenativepackage 'foo' 'amd64' '2' 'testing'
12
13 setupaptarchive --no-update
14
15 APTARCHIVE=$(readlink -f ./aptarchive)
16
17 everythingsucceeds() {
18 testequal 'Listing...
19 foo/testing 2 amd64
20 foo/stable 1 amd64
21 ' apt list foo -a
22
23 rm -f foo_1_amd64.deb foo_2_amd64.deb
24 testsuccess aptget download foo "$@"
25 testsuccess test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
26
27 rm -f foo_1.dsc foo_2.dsc
28 testsuccess aptget source foo --dsc-only -d "$@"
29 testsuccess test -s foo_1.dsc -o -s foo_2.dsc
30 }
31
32 everythingfails() {
33 testequal 'Listing...
34 foo/testing 2 amd64
35 foo/stable 1 amd64
36 ' apt list foo -a
37
38 local WARNING='WARNING: The following packages cannot be authenticated!
39 foo
40 E: Some packages could not be authenticated'
41
42 rm -f foo_1_amd64.deb foo_2_amd64.deb
43 testfailure aptget download foo "$@"
44 testequal "$WARNING" tail -n 3 rootdir/tmp/testfailure.output
45 testfailure test -s foo_1_amd64.deb -o -s foo_2_amd64.deb
46
47 rm -f foo_1.dsc foo_2.dsc
48 testfailure aptget source foo --dsc-only -d "$@"
49 testequal "$WARNING" tail -n 3 rootdir/tmp/testfailure.output
50 testfailure test -s foo_1.dsc -o -s foo_2.dsc
51 }
52
53 cp -a rootdir/etc/apt/sources.list.d/ rootdir/etc/apt/sources.list.d.bak/
54
55 aptgetupdate() {
56 rm -rf rootdir/var/lib/apt/lists
57 # note that insecure with trusted=yes are allowed
58 # as the trusted=yes indicates that security is provided by
59 # something above the understanding of apt
60 testsuccess aptget update --no-allow-insecure-repositories
61 }
62
63 insecureaptgetupdate() {
64 rm -rf rootdir/var/lib/apt/lists
65 testfailure aptget update --no-allow-insecure-repositories
66 rm -rf rootdir/var/lib/apt/lists
67 testsuccess aptget update --allow-insecure-repositories
68 }
69
70 msgmsg 'Test without trusted option and good sources'
71 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
72 aptgetupdate
73 everythingsucceeds
74 everythingsucceeds -t stable
75 everythingsucceeds -t testing
76
77 msgmsg 'Test with trusted=yes option and good sources'
78 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
79 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
80 aptgetupdate
81 everythingsucceeds
82 everythingsucceeds -t stable
83 everythingsucceeds -t testing
84
85 msgmsg 'Test with trusted=no option and good sources'
86 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
87 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
88 # we want the warnings on the actions, but for 'update' everything is fine
89 aptgetupdate
90 everythingfails
91 everythingfails -t stable
92 everythingfails -t testing
93
94 find aptarchive/dists/stable \( -name 'InRelease' -o -name 'Release.gpg' \) -delete
95
96 msgmsg 'Test without trusted option and good and unsigned sources'
97 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
98 insecureaptgetupdate
99 everythingsucceeds
100 everythingfails -t stable
101 everythingsucceeds -t testing
102
103 msgmsg 'Test with trusted=yes option and good and unsigned sources'
104 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
105 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
106 aptgetupdate
107 everythingsucceeds
108 everythingsucceeds -t stable
109 everythingsucceeds -t testing
110
111 msgmsg 'Test with trusted=no option and good and unsigned sources'
112 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
113 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
114 insecureaptgetupdate
115 everythingfails
116 everythingfails -t stable
117 everythingfails -t testing
118
119 signreleasefiles 'Marvin Paranoid' 'aptarchive/dists/stable'
120
121 msgmsg 'Test without trusted option and good and unknown sources'
122 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
123 insecureaptgetupdate
124 everythingsucceeds
125 everythingfails -t stable
126 everythingsucceeds -t testing
127
128 msgmsg 'Test with trusted=yes option and good and unknown sources'
129 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
130 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
131 aptgetupdate
132 everythingsucceeds
133 everythingsucceeds -t stable
134 everythingsucceeds -t testing
135
136 msgmsg 'Test with trusted=no option and good and unknown sources'
137 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
138 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
139 insecureaptgetupdate
140 everythingfails
141 everythingfails -t stable
142 everythingfails -t testing
143
144 signreleasefiles 'Rex Expired' 'aptarchive/dists/stable'
145 cp -a keys/rexexpired.pub rootdir/etc/apt/trusted.gpg.d/rexexpired.gpg
146
147 msgmsg 'Test without trusted option and good and expired sources'
148 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
149 insecureaptgetupdate
150 everythingsucceeds
151 everythingfails -t stable
152 everythingsucceeds -t testing
153
154 msgmsg 'Test with trusted=yes option and good and expired sources'
155 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
156 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
157 aptgetupdate
158 everythingsucceeds
159 everythingsucceeds -t stable
160 everythingsucceeds -t testing
161
162 msgmsg 'Test with trusted=no option and good and expired sources'
163 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
164 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
165 insecureaptgetupdate
166 everythingfails
167 everythingfails -t stable
168 everythingfails -t testing
169
170 # same as the one further above, but this time testing is unsigned
171 find aptarchive/ \( -name 'InRelease' -o -name 'Release.gpg' \) -delete
172 signreleasefiles 'Joe Sixpack' 'aptarchive/dists/stable'
173
174 msgmsg 'Test without trusted option and unsigned and good sources'
175 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
176 insecureaptgetupdate
177 everythingfails
178 everythingsucceeds -t stable
179 everythingfails -t testing
180
181 msgmsg 'Test with trusted=yes option and unsigned and good sources'
182 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
183 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
184 aptgetupdate
185 everythingsucceeds
186 everythingsucceeds -t stable
187 everythingsucceeds -t testing
188
189 msgmsg 'Test with trusted=no option and unsigned and good sources'
190 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
191 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=no] #' rootdir/etc/apt/sources.list.d/*
192 insecureaptgetupdate
193 everythingfails
194 everythingfails -t stable
195 everythingfails -t testing