apt-key del: Ignore case when checking if a keyid exists in a keyring.
[ntk/apt.git] / test / integration / test-apt-key
CommitLineData
80f3aeb0
DK
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture 'amd64'
9
10msgtest 'Check that paths in list output are not' 'double-slashed'
11aptkey list 2>&1 | grep -q '//' && msgfail || msgpass
12
13msgtest 'Check that paths in finger output are not' 'double-slashed'
14aptkey finger 2>&1 | grep -q '//' && msgfail || msgpass
15
16echo 'APT::Key::ArchiveKeyring "./keys/joesixpack.pub";
17APT::Key::RemovedKeys "./keys/rexexpired.pub";' > rootdir/etc/apt/apt.conf.d/aptkey.conf
18
19aptkey list | grep '^pub' > aptkey.list
20testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
21
22testequal 'gpg: key DBAC8DAE: "Joe Sixpack (APT Testcases Dummy) <joe@example.org>" not changed
23gpg: Total number processed: 1
24gpg: unchanged: 1' aptkey --fakeroot update
25
26aptkey list | grep '^pub' > aptkey.list
27testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
28
29testsuccess aptkey --fakeroot add ./keys/rexexpired.pub
30
31aptkey list | grep '^pub' > aptkey.list
32testfileequal ./aptkey.list 'pub 2048R/27CE74F9 2013-07-12 [expired: 2013-07-13]
33pub 2048R/DBAC8DAE 2010-08-18'
34
35msgtest 'Execute update again to trigger removal of' 'Rex Expired key'
36testsuccess --nomsg aptkey --fakeroot update
37
38aptkey list | grep '^pub' > aptkey.list
39testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
04937adc 40
c42ab00a
NK
41msgtest "Try to remove a" 'nonexistent keyid'
42testfailure --nomsg aptkey --fakeroot --keyring rootdir/etc/apt/trusted.gpg del BOGUSKEY
43
44aptkey list | grep '^pub' > aptkey2.list
45testsuccess diff ./aptkey.list ./aptkey2.list
46
04937adc
DK
47msgtest "Try to remove a key which exists, but isn't in the" 'forced keyring'
48testsuccess --nomsg aptkey --fakeroot --keyring rootdir/etc/apt/trusted.gpg del DBAC8DAE
49
50aptkey list | grep '^pub' > aptkey.list
51testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
52
53testsuccess aptkey --fakeroot del DBAC8DAE
54testempty aptkey list
55
56# start from a clean plate again
57cleanplate() {
58 rm -rf rootdir/etc/apt/trusted.gpg.d/ rootdir/etc/apt/trusted.gpg
59 mkdir rootdir/etc/apt/trusted.gpg.d/
60}
61
62msgtest 'Test key removal with' 'single key in real file'
63cleanplate
64cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
65testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
66testempty aptkey list
67testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
68testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
69
c42ab00a
NK
70msgtest 'Test key removal with' 'lowercase keyid'
71cleanplate
72cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
73testsuccess --nomsg aptkey --fakeroot del dbac8dae
74testempty aptkey list
75testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
76testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
77
04937adc
DK
78msgtest 'Test key removal with' 'single key in softlink'
79cleanplate
80ln -s $(readlink -f ./keys/joesixpack.pub) rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
81testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
82testempty aptkey list
83testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
84testsuccess test -L rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
85
86cleanplate
87testsuccess aptkey --fakeroot add ./keys/joesixpack.pub
88testsuccess aptkey --fakeroot add ./keys/marvinparanoid.pub
89aptkey list | grep '^pub' > aptkey.list
90testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18
91pub 2048R/528144E2 2011-01-16'
92cp -a rootdir/etc/apt/trusted.gpg keys/testcase-multikey.pub # store for reuse
93
94msgtest 'Test key removal with' 'multi key in real file'
95cleanplate
96cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
97testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
98aptkey list | grep '^pub' > aptkey.list
99testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
100testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
101
102msgtest 'Test key removal with' 'multi key in softlink'
103cleanplate
104ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir/etc/apt/trusted.gpg.d/multikey.gpg
105testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
106aptkey list | grep '^pub' > aptkey.list
107testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
108testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
109testsuccess test ! -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg
110testsuccess test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
111
112msgtest 'Test key removal with' 'multiple files including key'
113cleanplate
114cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
115cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
116testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
117aptkey list | grep '^pub' > aptkey.list
118testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
119testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
120testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
121testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
69d8b853
JM
122
123msgtest 'Test key removal with' '8 byte key ID'
124cleanplate
125cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
126testsuccess --nomsg aptkey --fakeroot del 5A90D141DBAC8DAE
127testempty aptkey list