4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'amd64'
10 # start from a clean plate again
12 rm -rf rootdir
/etc
/apt
/trusted.gpg.d
/ rootdir
/etc
/apt
/trusted.gpg
13 mkdir rootdir
/etc
/apt
/trusted.gpg.d
/
17 if ! aptkey list
| grep '^pub' > aptkey.list
; then
20 testfileequal
'./aptkey.list' "$1"
23 echo 'APT::Key::ArchiveKeyring "./keys/joesixpack.pub";
24 APT::Key::RemovedKeys "./keys/rexexpired.pub";' > rootdir
/etc
/apt
/apt.conf.d
/aptkey.conf
28 ln -sf ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
30 msgtest
'Check that paths in list output are not' 'double-slashed'
31 aptkey list
2>&1 | grep -q '//' && msgfail
|| msgpass
33 msgtest
'Check that paths in finger output are not' 'double-slashed'
34 aptkey
finger 2>&1 | grep -q '//' && msgfail
|| msgpass
36 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18'
38 testsuccessequal
'gpg: key DBAC8DAE: "Joe Sixpack (APT Testcases Dummy) <joe@example.org>" not changed
39 gpg: Total number processed: 1
40 gpg: unchanged: 1' aptkey
--fakeroot update
42 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18'
44 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg
45 testsuccess aptkey
--fakeroot add .
/keys
/rexexpired.pub
46 msgtest
'Check if trusted.gpg is created with permissions set to' '0644'
47 if [ "$(stat -c '%a' rootdir/etc/apt/trusted.gpg )" = '644' ]; then
53 testaptkeys
'pub 2048R/27CE74F9 2013-07-12 [expired: 2013-07-13]
54 pub 2048R/DBAC8DAE 2010-08-18'
56 msgtest
'Check that Sixpack key can be' 'exported'
57 aptkey
export 'Sixpack' > aptkey.
export
58 aptkey
--keyring rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg exportall
> aptkey.exportall
59 testsuccess
--nomsg cmp aptkey.
export aptkey.exportall
60 testsuccess
test -s aptkey.
export
61 testsuccess
test -s aptkey.exportall
63 msgtest
'Execute update again to trigger removal of' 'Rex Expired key'
64 testsuccess
--nomsg aptkey
--fakeroot update
66 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18'
68 msgtest
"Try to remove a key which exists, but isn't in the" 'forced keyring'
69 testsuccess
--nomsg aptkey
--fakeroot --keyring rootdir
/etc
/apt
/trusted.gpg del DBAC8DAE
71 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18'
73 testsuccess aptkey
--fakeroot del DBAC8DAE
76 msgtest
'Test key removal with' 'lowercase key ID' #keylength somewhere between 8byte and short
78 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
79 testsuccess
--nomsg aptkey
--fakeroot del d141dbac8dae
82 msgtest
'Test key removal with' 'single key in real file'
84 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
85 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
87 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
88 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
90 msgtest
'Test key removal with' 'long key ID'
92 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
93 testsuccess
--nomsg aptkey
--fakeroot del
5A90D141DBAC8DAE
95 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
96 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
98 msgtest
'Test key removal with' 'fingerprint'
100 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
101 testsuccess
--nomsg aptkey
--fakeroot del
34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
102 testempty aptkey list
103 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
104 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
106 msgtest
'Test key removal with' 'single key in softlink'
108 ln -s $(readlink -f ./keys/joesixpack.pub) rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
109 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
110 testempty aptkey list
111 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
112 testsuccess
test -L rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
115 testsuccess aptkey
--fakeroot add .
/keys
/joesixpack.pub
116 testsuccess aptkey
--fakeroot add .
/keys
/marvinparanoid.pub
117 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18
118 pub 2048R/528144E2 2011-01-16'
119 cp -a rootdir
/etc
/apt
/trusted.gpg keys
/testcase
-multikey.pub
# store for reuse
121 msgtest
'Test key removal with' 'multi key in real file'
123 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
124 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
125 testaptkeys
'pub 2048R/528144E2 2011-01-16'
126 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
128 msgtest
'Test key removal with' 'multi key in softlink'
130 ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
131 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
132 testaptkeys
'pub 2048R/528144E2 2011-01-16'
133 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
134 testfailure
test -L rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
135 testsuccess
test -L rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
137 msgtest
'Test key removal with' 'multiple files including key'
139 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
140 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
141 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
142 testaptkeys
'pub 2048R/528144E2 2011-01-16'
143 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
144 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
145 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
148 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
149 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
150 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18
151 pub 2048R/DBAC8DAE 2010-08-18
152 pub 2048R/528144E2 2011-01-16'
153 msgtest
'Test merge-back of' 'added keys'
154 testsuccess
--nomsg aptkey adv
--batch --yes --import keys
/rexexpired.pub
155 testaptkeys
'pub 2048R/27CE74F9 2013-07-12 [expired: 2013-07-13]
156 pub 2048R/DBAC8DAE 2010-08-18
157 pub 2048R/DBAC8DAE 2010-08-18
158 pub 2048R/528144E2 2011-01-16'
160 msgtest
'Test merge-back of' 'removed keys'
161 testsuccess
--nomsg aptkey adv
--batch --yes --delete-keys 27CE74F9
162 testaptkeys
'pub 2048R/DBAC8DAE 2010-08-18
163 pub 2048R/DBAC8DAE 2010-08-18
164 pub 2048R/528144E2 2011-01-16'
166 msgtest
'Test merge-back of' 'removed duplicate keys'
167 testsuccess
--nomsg aptkey adv
--batch --yes --delete-keys DBAC8DAE
168 testaptkeys
'pub 2048R/528144E2 2011-01-16'
171 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
172 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
173 msgtest
'Test signing a file' 'with a key'
174 echo 'Verify me. This is my signature.' > signature
175 testsuccess
--nomsg aptkey
--quiet --keyring keys
/marvinparanoid.pub
--secret-keyring keys
/marvinparanoid.sec
--readonly \
176 adv
--batch --yes --default-key 'Marvin' --armor --detach-sign --sign --output signature.gpg signature
178 msgtest
'Test verify a file' 'with all keys'
179 testsuccess
--nomsg aptkey
--quiet --readonly verify signature.gpg signature
181 msgtest
'Test verify a file' 'with good keyring'
182 testsuccess
--nomsg aptkey
--quiet --readonly --keyring keys
/testcase
-multikey.pub verify signature.gpg signature
184 msgtest
'Test fail verify a file' 'with bad keyring'
185 testfailure
--nomsg aptkey
--quiet --readonly --keyring keys
/joesixpack.pub verify signature.gpg signature
187 msgtest
'Test fail verify a file' 'with non-existing keyring'
188 testfailure
--nomsg aptkey
--quiet --readonly --keyring keys
/does
-not-exist.pub verify signature.gpg signature
189 testfailure
test -e keys
/does
-not-exist.pub
191 msgtest
'Test verify a file' 'with good keyid'
192 testsuccess
--nomsg aptkey
--quiet --readonly --keyid 'Paranoid' verify signature.gpg signature
194 msgtest
'Test fail verify a file' 'with bad keyid'
195 testfailure
--nomsg aptkey
--quiet --readonly --keyid 'Sixpack' verify signature.gpg signature
197 msgtest
'Test fail verify a file' 'with non-existing keyid'
198 testfailure
--nomsg aptkey
--quiet --readonly --keyid 'Kalnischkies' verify signature.gpg signature
200 msgtest
'Test verify fails on' 'bad file'
201 echo 'lalalalala' > signature
202 testfailure
--nomsg aptkey
--quiet --readonly verify signature.gpg signature
206 echo "APT::Key::GPGCommand \"$1\";" > rootdir
/etc
/apt
/apt.conf.d
/00gpgcmd
207 msgtest
'Test that apt-key uses for the following tests command' "$1"
208 aptkey adv
--version >aptkey.version
2>&1
209 if grep -q "^Executing: $1 --" aptkey.version
; then
217 # run with default (whatever this is)
220 setupgpgcommand
'gpg'
222 setupgpgcommand
'gpg2'