1
# pygpgme - a Python wrapper for the gpgme library
2
# Copyright (C) 2006 James Henstridge
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Lesser General Public
6
# License as published by the Free Software Foundation; either
7
# version 2.1 of the License, or (at your option) any later version.
9
# This library is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public
15
# License along with this library; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
from gpgme.tests.util import GpgHomeTestCase
23
class KeylistTestCase(GpgHomeTestCase):
25
import_keys = ['key1.pub', 'key2.pub', 'revoked.pub', 'signonly.pub',
28
def test_listall(self):
30
keyids = set(key.subkeys[0].keyid for key in ctx.keylist())
31
self.assertTrue(keyids, set(['46BB55F0885C65A4',
36
def test_list_by_email(self):
38
keyids = set(key.subkeys[0].keyid
39
for key in ctx.keylist('key1@example.org'))
40
self.assertTrue(keyids, set(['46BB55F0885C65A4']))
41
keyids = set(key.subkeys[0].keyid
42
for key in ctx.keylist(['key1@example.org',
43
'signonly@example.com']))
44
self.assertTrue(keyids, set(['46BB55F0885C65A4', 'F540A569CB935A42']))
46
def test_list_by_name(self):
48
keyids = set(key.subkeys[0].keyid
49
for key in ctx.keylist('Key 1'))
50
self.assertTrue(keyids, set(['46BB55F0885C65A4']))
52
def test_list_by_email_substring(self):
54
keyids = set(key.subkeys[0].keyid
55
for key in ctx.keylist('@example.org'))
56
self.assertTrue(keyids, set(['46BB55F0885C65A4',
61
def test_list_secret(self):
63
keyids = set(key.subkeys[0].keyid
64
for key in ctx.keylist(None, True))
65
self.assertTrue(keyids, set(['46BB55F0885C65A4']))
69
loader = unittest.TestLoader()
70
return loader.loadTestsFromName(__name__)