]>
Commit | Line | Data |
---|---|---|
80f3aeb0 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
4 | TESTDIR=$(readlink -f $(dirname $0)) | |
5 | . $TESTDIR/framework | |
6 | ||
7 | setupenvironment | |
8 | configarchitecture 'amd64' | |
9 | ||
93d0d08c DK |
10 | # start from a clean plate again |
11 | cleanplate() { | |
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 | |
16 | echo 'APT::Key::ArchiveKeyring "./keys/joesixpack.pub"; | |
17 | APT::Key::RemovedKeys "./keys/rexexpired.pub";' > rootdir/etc/apt/apt.conf.d/aptkey.conf | |
18 | ||
93d0d08c DK |
19 | testrun() { |
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 |
33 | gpg: Total number processed: 1 | |
34 | gpg: 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] | |
43 | pub 2048R/DBAC8DAE 2010-08-18' | |
04937adc | 44 | |
93d0d08c DK |
45 | msgtest 'Execute update again to trigger removal of' 'Rex Expired key' |
46 | testsuccess --nomsg aptkey --fakeroot update | |
47 | ||
48 | aptkey list | grep '^pub' > aptkey.list | |
49 | testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18' | |
50 | ||
51 | msgtest "Try to remove a key which exists, but isn't in the" 'forced keyring' | |
52 | testsuccess --nomsg aptkey --fakeroot --keyring rootdir/etc/apt/trusted.gpg del DBAC8DAE | |
53 | ||
54 | aptkey list | grep '^pub' > aptkey.list | |
55 | testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18' | |
56 | ||
57 | testsuccess aptkey --fakeroot del DBAC8DAE | |
58 | testempty aptkey list | |
59 | ||
60 | msgtest 'Test key removal with' 'single key in real file' | |
61 | cleanplate | |
62 | cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
63 | testsuccess --nomsg aptkey --fakeroot del DBAC8DAE | |
64 | testempty aptkey list | |
65 | testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
66 | testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~ | |
67 | ||
68 | msgtest 'Test key removal with' 'single key in softlink' | |
69 | cleanplate | |
70 | ln -s $(readlink -f ./keys/joesixpack.pub) rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
71 | testsuccess --nomsg aptkey --fakeroot del DBAC8DAE | |
72 | testempty aptkey list | |
73 | testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
74 | testsuccess test -L rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~ | |
75 | ||
76 | cleanplate | |
77 | testsuccess aptkey --fakeroot add ./keys/joesixpack.pub | |
78 | testsuccess aptkey --fakeroot add ./keys/marvinparanoid.pub | |
79 | aptkey list | grep '^pub' > aptkey.list | |
80 | testfileequal ./aptkey.list 'pub 2048R/DBAC8DAE 2010-08-18 | |
81 | pub 2048R/528144E2 2011-01-16' | |
82 | cp -a rootdir/etc/apt/trusted.gpg keys/testcase-multikey.pub # store for reuse | |
83 | ||
84 | msgtest 'Test key removal with' 'multi key in real file' | |
85 | cleanplate | |
86 | cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg | |
87 | testsuccess --nomsg aptkey --fakeroot del DBAC8DAE | |
88 | aptkey list | grep '^pub' > aptkey.list | |
89 | testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16' | |
90 | testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~ | |
91 | ||
92 | msgtest 'Test key removal with' 'multi key in softlink' | |
93 | cleanplate | |
94 | ln -s $(readlink -f ./keys/testcase-multikey.pub) rootdir/etc/apt/trusted.gpg.d/multikey.gpg | |
95 | testsuccess --nomsg aptkey --fakeroot del DBAC8DAE | |
96 | aptkey list | grep '^pub' > aptkey.list | |
97 | testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16' | |
98 | testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~ | |
99 | testsuccess test ! -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg | |
100 | testsuccess test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg~ | |
101 | ||
102 | msgtest 'Test key removal with' 'multiple files including key' | |
103 | cleanplate | |
104 | cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
105 | cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg | |
106 | testsuccess --nomsg aptkey --fakeroot del DBAC8DAE | |
107 | aptkey list | grep '^pub' > aptkey.list | |
108 | testfileequal ./aptkey.list 'pub 2048R/528144E2 2011-01-16' | |
109 | testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
110 | testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~ | |
111 | testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~ | |
112 | } | |
04937adc | 113 | |
93d0d08c DK |
114 | setupgpgcommand() { |
115 | echo "APT::Key::GPGCommand \"$1\";" > rootdir/etc/apt/apt.conf.d/00gpgcmd | |
116 | msgtest 'Test that apt-key uses for the following tests command' "$1" | |
117 | aptkey adv --version >aptkey.version 2>&1 | |
118 | if grep -q "^Executing: $1 --" aptkey.version; then | |
119 | msgpass | |
120 | else | |
121 | cat aptkey.version | |
122 | msgfail | |
123 | fi | |
04937adc DK |
124 | } |
125 | ||
93d0d08c DK |
126 | # run with default (whatever this is) |
127 | testrun | |
128 | # run with … | |
129 | setupgpgcommand 'gpg' | |
130 | testrun | |
131 | setupgpgcommand 'gpg2' | |
132 | testrun |