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