Extract key-loading code to a dedicated class KeyRing in lacre.keyring module. KeyCache only keeps a static map of identities, making it safe to use in asynchronous context (and race condition resistant).
20 lines
618 B
Python
20 lines
618 B
Python
from lacre.keyring import KeyCache
|
|
|
|
import unittest
|
|
|
|
class LacreKeyCacheTest(unittest.TestCase):
|
|
def test_extend_keyring(self):
|
|
kc = KeyCache({'FINGERPRINT': 'john.doe@example.com'})
|
|
self.assertTrue('FINGERPRINT' in kc)
|
|
|
|
def test_membership_methods(self):
|
|
kc = KeyCache({
|
|
'FINGERPRINT': 'alice@example.com',
|
|
'OTHERPRINT': 'bob@example.com'
|
|
})
|
|
|
|
self.assertTrue('FINGERPRINT' in kc)
|
|
self.assertFalse('FOOTPRINT' in kc)
|
|
|
|
self.assertTrue(kc.has_email('bob@example.com'))
|
|
self.assertFalse(kc.has_email('dave@example.com'))
|