Make email lookup case-insensitive
This commit is contained in:
parent
ea3eb7c09b
commit
82368f58c5
2 changed files with 11 additions and 2 deletions
|
@ -11,7 +11,7 @@ class KeyCache:
|
|||
|
||||
With keyring_dir given, set location of the directory from which keys should be loaded.
|
||||
"""
|
||||
self._keys = keys
|
||||
self._keys = { fpr: eml.upper() for (fpr, eml) in keys.items() }
|
||||
|
||||
def __getitem__(self, fingerpring):
|
||||
"""Look up email assigned to the given fingerprint."""
|
||||
|
@ -29,7 +29,7 @@ class KeyCache:
|
|||
|
||||
def has_email(self, email):
|
||||
"""Check if cache contains a key assigned to the given email."""
|
||||
return email in self._keys.values()
|
||||
return email.upper() in self._keys.values()
|
||||
|
||||
def __repr__(self):
|
||||
"""Return text representation of this object."""
|
||||
|
|
|
@ -18,3 +18,12 @@ class LacreKeyCacheTest(unittest.TestCase):
|
|||
|
||||
self.assertTrue(kc.has_email('bob@example.com'))
|
||||
self.assertFalse(kc.has_email('dave@example.com'))
|
||||
|
||||
def test_case_insensitivity(self):
|
||||
kc = KeyCache({
|
||||
'FINGERPRINT': 'alice@example.com',
|
||||
'OTHERPRINT': 'bob@example.com',
|
||||
})
|
||||
|
||||
self.assertTrue(kc.has_email('Alice@example.com'))
|
||||
self.assertTrue(kc.has_email('BOB@EXAMPLE.COM'))
|
||||
|
|
Loading…
Reference in a new issue