]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-key
add --secret-keyring option for apt-key
[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
93d0d08c
DK
10# start from a clean plate again
11cleanplate() {
12 rm -rf rootdir/etc/apt/trusted.gpg.d/ rootdir/etc/apt/trusted.gpg
13 mkdir rootdir/etc/apt/trusted.gpg.d/
14}
80f3aeb0
DK
15
16echo 'APT::Key::ArchiveKeyring "./keys/joesixpack.pub";
17APT::Key::RemovedKeys "./keys/rexexpired.pub";' > rootdir/etc/apt/apt.conf.d/aptkey.conf
18
93d0d08c
DK
19testrun() {
20 cleanplate
21 ln -sf ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
80f3aeb0 22
93d0d08c
DK
23 msgtest 'Check that paths in list output are not' 'double-slashed'
24 aptkey list 2>&1 | grep -q '//' && msgfail || msgpass
80f3aeb0 25
93d0d08c
DK
26 msgtest 'Check that paths in finger output are not' 'double-slashed'
27 aptkey finger 2>&1 | grep -q '//' && msgfail || msgpass
80f3aeb0 28
93d0d08c
DK
29 aptkey list | grep '^pub' > aptkey.list
30 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
80f3aeb0 31
93d0d08c
DK
32 testequal 'gpg: key DBAC8DAE: "Joe Sixpack (APT Testcases Dummy) <joe@example.org>" not changed
33gpg: Total number processed: 1
34gpg: unchanged: 1' aptkey --fakeroot update
80f3aeb0 35
93d0d08c
DK
36 aptkey list | grep '^pub' > aptkey.list
37 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
04937adc 38
93d0d08c 39 testsuccess aptkey --fakeroot add ./keys/rexexpired.pub
04937adc 40
93d0d08c
DK
41 aptkey list | grep '^pub' > aptkey.list
42 testfileequal ./aptkey.list 'pub 2048R/27CE74F9 2013-07-12 [expired: 2013-07-13]
43pub 2048R/DBAC8DAE 2010-08-18'
04937adc 44
38005d8b
DK
45 msgtest 'Check that Sixpack key can be' 'exported'
46 aptkey export 'Sixpack' > aptkey.export
47 aptkey --keyring rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg exportall > aptkey.exportall
48 testsuccess --nomsg cmp aptkey.export aptkey.exportall
49 testsuccess test -s aptkey.export
50 testsuccess test -s aptkey.exportall
51
93d0d08c
DK
52 msgtest 'Execute update again to trigger removal of' 'Rex Expired key'
53 testsuccess --nomsg aptkey --fakeroot update
54
55 aptkey list | grep '^pub' > aptkey.list
56 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
57
58 msgtest "Try to remove a key which exists, but isn't in the" 'forced keyring'
59 testsuccess --nomsg aptkey --fakeroot --keyring rootdir/etc/apt/trusted.gpg del DBAC8DAE
60
61 aptkey list | grep '^pub' > aptkey.list
62 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18'
63
64 testsuccess aptkey --fakeroot del DBAC8DAE
65 testempty aptkey list
66
67 msgtest 'Test key removal with' 'single key in real file'
68 cleanplate
69 cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
70 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
71 testempty aptkey list
72 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
73 testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
74
ba72845c
DK
75 msgtest 'Test key removal with' 'fingerprint'
76 cleanplate
77 cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
78 testsuccess --nomsg aptkey --fakeroot del 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
79 testempty aptkey list
80 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
81 testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
82
93d0d08c
DK
83 msgtest 'Test key removal with' 'single key in softlink'
84 cleanplate
85 ln -s $(readlink -f ./keys/joesixpack.pub) rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
86 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
87 testempty aptkey list
88 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
89 testsuccess test -L rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
90
91 cleanplate
92 testsuccess aptkey --fakeroot add ./keys/joesixpack.pub
93 testsuccess aptkey --fakeroot add ./keys/marvinparanoid.pub
94 aptkey list | grep '^pub' > aptkey.list
95 testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18
96pub 2048R/528144E2 2011-01-16'
97 cp -a rootdir/etc/apt/trusted.gpg keys/testcase-multikey.pub # store for reuse
98
99 msgtest 'Test key removal with' 'multi key in real file'
100 cleanplate
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 cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
106
107 msgtest 'Test key removal with' 'multi key in softlink'
108 cleanplate
109 ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir/etc/apt/trusted.gpg.d/multikey.gpg
110 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
111 aptkey list | grep '^pub' > aptkey.list
112 testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
113 testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
114 testsuccess test ! -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg
115 testsuccess test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
116
117 msgtest 'Test key removal with' 'multiple files including key'
118 cleanplate
119 cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
120 cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
121 testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
122 aptkey list | grep '^pub' > aptkey.list
123 testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16'
124 testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
125 testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
126 testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
127}
04937adc 128
93d0d08c
DK
129setupgpgcommand() {
130 echo "APT::Key::GPGCommand \"$1\";" > rootdir/etc/apt/apt.conf.d/00gpgcmd
131 msgtest 'Test that apt-key uses for the following tests command' "$1"
132 aptkey adv --version >aptkey.version 2>&1
133 if grep -q "^Executing: $1 --" aptkey.version; then
134 msgpass
135 else
136 cat aptkey.version
137 msgfail
138 fi
04937adc
DK
139}
140
93d0d08c
DK
141# run with default (whatever this is)
142testrun
143# run with …
144setupgpgcommand 'gpg'
145testrun
146setupgpgcommand 'gpg2'
147testrun