]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-key
only consider versioned kernel packages in autoremove
[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 key which exists, but isn't in the" 'forced keyring'
42 testsuccess --nomsg aptkey --fakeroot --keyring rootdir/etc/apt/trusted.gpg del DBAC8DAE
43
44 aptkey list | grep '^pub' > aptkey.list
45 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
46
47 testsuccess aptkey --fakeroot del DBAC8DAE
48 testempty aptkey list
49
50 # start from a clean plate again
51 cleanplate() {
52 rm -rf rootdir/etc/apt/trusted.gpg.d/ rootdir/etc/apt/trusted.gpg
53 mkdir rootdir/etc/apt/trusted.gpg.d/
54 }
55
56 msgtest 'Test key removal with' 'single key in real file'
57 cleanplate
58 cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
59 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
60 testempty aptkey list
61 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
62 testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
63
64 msgtest 'Test key removal with' 'single key in softlink'
65 cleanplate
66 ln -s $(readlink -f ./keys/joesixpack.pub) rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
67 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
68 testempty aptkey list
69 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
70 testsuccess test -L rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
71
72 cleanplate
73 testsuccess aptkey --fakeroot add ./keys/joesixpack.pub
74 testsuccess aptkey --fakeroot add ./keys/marvinparanoid.pub
75 aptkey list | grep '^pub' > aptkey.list
76 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18
77 pub 2048R/528144E2 2011-01-16'
78 cp -a rootdir/etc/apt/trusted.gpg keys/testcase-multikey.pub # store for reuse
79
80 msgtest 'Test key removal with' 'multi key in real file'
81 cleanplate
82 cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
83 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
84 aptkey list | grep '^pub' > aptkey.list
85 testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
86 testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
87
88 msgtest 'Test key removal with' 'multi key in softlink'
89 cleanplate
90 ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir/etc/apt/trusted.gpg.d/multikey.gpg
91 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
92 aptkey list | grep '^pub' > aptkey.list
93 testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
94 testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
95 testsuccess test ! -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg
96 testsuccess test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
97
98 msgtest 'Test key removal with' 'multiple files including key'
99 cleanplate
100 cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
101 cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
102 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
103 aptkey list | grep '^pub' > aptkey.list
104 testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
105 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
106 testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
107 testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~