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
/
18 # gpg 2.1 has a slightly different output format
19 if grep -q ' rsa2048/' aptkey.list
; then
21 *Joe
*|*Sixpack
*) echo 'pub rsa2048/DBAC8DAE 2010-08-18';;
22 *Rex
*|*Expired
*) echo 'pub rsa2048/27CE74F9 2013-07-12 [expired: 2013-07-13]';;
23 *Marvin
*|*Paranoid
*) echo 'pub rsa2048/528144E2 2011-01-16';;
24 *) echo 'UNKNOWN KEY';;
28 *Joe
*|*Sixpack
*) echo 'pub 2048R/DBAC8DAE 2010-08-18';;
29 *Rex
*|*Expired
*) echo 'pub 2048R/27CE74F9 2013-07-12 [expired: 2013-07-13]';;
30 *Marvin
*|*Paranoid
*) echo 'pub 2048R/528144E2 2011-01-16';;
31 *) echo 'UNKNOWN KEY';;
39 if ! aptkey list
| grep '^pub' > aptkey.list
; then
42 testfileequal
'./aptkey.list' "$(createlistofkeys "$@")"
45 echo 'APT::Key::ArchiveKeyring "./keys/joesixpack.pub";
46 APT::Key::RemovedKeys "./keys/rexexpired.pub";' > rootdir
/etc
/apt
/apt.conf.d
/aptkey.conf
50 ln -sf ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
52 msgtest
'Check that paths in list output are not' 'double-slashed'
53 aptkey list
2>&1 | grep -q '//' && msgfail
|| msgpass
55 msgtest
'Check that paths in finger output are not' 'double-slashed'
56 aptkey
finger 2>&1 | grep -q '//' && msgfail
|| msgpass
57 testaptkeys
'Joe Sixpack'
59 testsuccessequal
'gpg: key DBAC8DAE: "Joe Sixpack (APT Testcases Dummy) <joe@example.org>" not changed
60 gpg: Total number processed: 1
61 gpg: unchanged: 1' aptkey
--fakeroot update
63 testaptkeys
'Joe Sixpack'
64 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg
66 testsuccess aptkey
--fakeroot add .
/keys
/rexexpired.pub
67 msgtest
'Check if trusted.gpg is created with permissions set to' '0644'
68 if [ "$(stat -c '%a' rootdir/etc/apt/trusted.gpg )" = '644' ]; then
74 testaptkeys
'Rex Expired' 'Joe Sixpack'
76 msgtest
'Check that Sixpack key can be' 'exported'
77 aptkey
export 'Sixpack' > aptkey.
export
78 aptkey
--keyring rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg exportall
> aptkey.exportall
79 testsuccess
--nomsg cmp aptkey.
export aptkey.exportall
80 testsuccess
test -s aptkey.
export
81 testsuccess
test -s aptkey.exportall
83 msgtest
'Execute update again to trigger removal of' 'Rex Expired key'
84 testsuccess
--nomsg aptkey
--fakeroot update
86 testaptkeys
'Joe Sixpack'
88 msgtest
"Try to remove a key which exists, but isn't in the" 'forced keyring'
89 testsuccess
--nomsg aptkey
--fakeroot --keyring rootdir
/etc
/apt
/trusted.gpg del DBAC8DAE
91 testaptkeys
'Joe Sixpack'
93 testsuccess aptkey
--fakeroot del DBAC8DAE
96 msgtest
'Test key removal with' 'lowercase key ID' #keylength somewhere between 8byte and short
98 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
99 testsuccess
--nomsg aptkey
--fakeroot del d141dbac8dae
100 testempty aptkey list
102 msgtest
'Test key removal with' 'single key in real file'
104 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
105 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
106 testempty aptkey list
107 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
108 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
110 msgtest
'Test key removal with' 'long key ID'
112 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
113 testsuccess
--nomsg aptkey
--fakeroot del
5A90D141DBAC8DAE
114 testempty aptkey list
115 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
116 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
118 msgtest
'Test key removal with' 'fingerprint'
120 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
121 testsuccess
--nomsg aptkey
--fakeroot del
34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
122 testempty aptkey list
123 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
124 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
126 msgtest
'Test key removal with' 'single key in softlink'
128 ln -s $(readlink -f ./keys/joesixpack.pub) rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
129 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
130 testempty aptkey list
131 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
132 testsuccess
test -L rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
135 testsuccess aptkey
--fakeroot add .
/keys
/joesixpack.pub
136 testsuccess aptkey
--fakeroot add .
/keys
/marvinparanoid.pub
137 testaptkeys
'Joe Sixpack' 'Marvin Paranoid'
138 cp -a rootdir
/etc
/apt
/trusted.gpg keys
/testcase
-multikey.pub
# store for reuse
140 msgtest
'Test key removal with' 'multi key in real file'
142 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
143 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
144 testaptkeys
'Marvin Paranoid'
145 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
147 msgtest
'Test key removal with' 'multi key in softlink'
149 ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
150 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
151 testaptkeys
'Marvin Paranoid'
152 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
153 testfailure
test -L rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
154 testsuccess
test -L rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
156 msgtest
'Test key removal with' 'multiple files including key'
158 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
159 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
160 testsuccess
--nomsg aptkey
--fakeroot del DBAC8DAE
161 testaptkeys
'Marvin Paranoid'
162 testfailure
test -e rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
163 testsuccess
cmp keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg~
164 testsuccess
cmp keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg~
167 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
168 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
169 testaptkeys
'Joe Sixpack' 'Joe Sixpack' 'Marvin Paranoid'
170 msgtest
'Test merge-back of' 'added keys'
171 testsuccess
--nomsg aptkey adv
--batch --yes --import keys
/rexexpired.pub
172 testaptkeys
'Rex Expired' 'Joe Sixpack' 'Joe Sixpack' 'Marvin Paranoid'
174 msgtest
'Test merge-back of' 'removed keys'
175 testsuccess
--nomsg aptkey adv
--batch --yes --delete-keys 27CE74F9
176 testaptkeys
'Joe Sixpack' 'Joe Sixpack' 'Marvin Paranoid'
178 msgtest
'Test merge-back of' 'removed duplicate keys'
179 testsuccess
--nomsg aptkey adv
--batch --yes --delete-keys DBAC8DAE
180 testaptkeys
'Marvin Paranoid'
183 cp -a keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
184 cp -a keys
/testcase
-multikey.pub rootdir
/etc
/apt
/trusted.gpg.d
/multikey.gpg
185 msgtest
'Test signing a file' 'with a key'
186 echo 'Verify me. This is my signature.' > signature
187 testsuccess
--nomsg aptkey
--quiet --keyring keys
/marvinparanoid.pub
--secret-keyring keys
/marvinparanoid.sec
--readonly \
188 adv
--batch --yes --default-key 'Marvin' --armor --detach-sign --sign --output signature.gpg signature
191 for GPGV
in '' 'gpgv' 'gpgv2'; do
192 echo "APT::Key::GPGVCommand \"$GPGV\";" > rootdir
/etc
/apt
/apt.conf.d
/00gpgvcmd
194 msgtest
'Test verify a file' 'with all keys'
195 testsuccess
--nomsg aptkey
--quiet --readonly verify signature.gpg signature
197 msgtest
'Test verify a file' 'with good keyring'
198 testsuccess
--nomsg aptkey
--quiet --readonly --keyring keys
/testcase
-multikey.pub verify signature.gpg signature
200 msgtest
'Test fail verify a file' 'with bad keyring'
201 testfailure
--nomsg aptkey
--quiet --readonly --keyring keys
/joesixpack.pub verify signature.gpg signature
203 msgtest
'Test fail verify a file' 'with non-existing keyring'
204 testfailure
--nomsg aptkey
--quiet --readonly --keyring keys
/does
-not-exist.pub verify signature.gpg signature
205 testfailure
test -e keys
/does
-not-exist.pub
207 # note: this isn't how apts gpgv method implements keyid for verify
208 msgtest
'Test verify a file' 'with good keyid'
209 testsuccess
--nomsg aptkey
--quiet --readonly --keyid 'Paranoid' verify signature.gpg signature
211 msgtest
'Test fail verify a file' 'with bad keyid'
212 testfailure
--nomsg aptkey
--quiet --readonly --keyid 'Sixpack' verify signature.gpg signature
214 msgtest
'Test fail verify a file' 'with non-existing keyid'
215 testfailure
--nomsg aptkey
--quiet --readonly --keyid 'Kalnischkies' verify signature.gpg signature
217 msgtest
'Test verify fails on' 'bad file'
218 echo 'lalalalala' > signature2
219 testfailure
--nomsg aptkey
--quiet --readonly verify signature.gpg signature2
224 echo "APT::Key::GPGCommand \"$1\";" > rootdir
/etc
/apt
/apt.conf.d
/00gpgcmd
225 msgmsg
'Force tests to be run with' "$1"
226 testsuccess aptkey
--readonly adv
--version
227 cp rootdir
/tmp
/testsuccess.output aptkey.version
228 testsuccess
grep "^Executing: $1 --" aptkey.version
231 # run with default (whatever this is)
234 setupgpgcommand
'gpg'
236 setupgpgcommand
'gpg2'