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