summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2018-06-21 11:04:40 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2018-06-21 11:40:02 +0100
commit43e370fa92dfc7c0977c311e0d71e9e57f3ea575 (patch)
tree41477b1abeff702f27e02b02dfad292b6dd8413f
parentc30afc72150e30770da6fc1e5f6e68dce2b9a6bb (diff)
rename function that updates gpg keys in envelopes
-rw-r--r--alot/commands/envelope.py6
-rw-r--r--alot/commands/globals.py6
-rw-r--r--alot/commands/utils.py2
-rw-r--r--tests/commands/utils_tests.py12
4 files changed, 13 insertions, 13 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index 535ce06c..4b02e67e 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -428,7 +428,7 @@ class SetCommand(Command):
# as the key of the person BCC'd will be available to other recievers,
# defeating the purpose of BCCing them
if self.key.lower() in ['to', 'from', 'cc']:
- yield utils.set_encrypt(ui, ui.current_buffer.envelope)
+ yield utils.update_keys(ui, ui.current_buffer.envelope)
ui.current_buffer.rebuild()
@@ -452,7 +452,7 @@ class UnsetCommand(Command):
# as the key of the person BCC'd will be available to other recievers,
# defeating the purpose of BCCing them
if self.key.lower() in ['to', 'from', 'cc']:
- yield utils.set_encrypt(ui, ui.current_buffer.envelope)
+ yield utils.update_keys(ui, ui.current_buffer.envelope)
ui.current_buffer.rebuild()
@@ -603,7 +603,7 @@ class EncryptCommand(Command):
tmp_key = crypto.get_key(keyid)
envelope.encrypt_keys[tmp_key.fpr] = tmp_key
else:
- yield utils.set_encrypt(ui, envelope, signed_only=self.trusted)
+ yield utils.update_keys(ui, envelope, signed_only=self.trusted)
envelope.encrypt = encrypt
if not envelope.encrypt:
# This is an extra conditional as it can even happen if encrypt is
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 906117a6..0fae0630 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -17,7 +17,7 @@ from twisted.internet import threads
from . import Command, registerCommand
from . import CommandCanceled
-from .utils import set_encrypt
+from .utils import update_keys
from .. import commands
from .. import buffers
@@ -916,12 +916,12 @@ class ComposeCommand(Command):
logging.debug("Trying to encrypt message because encrypt=%s and "
"encrypt_by_default=%s", self.encrypt,
account.encrypt_by_default)
- yield set_encrypt(ui, self.envelope, block_error=self.encrypt)
+ yield update_keys(ui, self.envelope, block_error=self.encrypt)
elif account.encrypt_by_default == u"trusted":
logging.debug("Trying to encrypt message because "
"account.encrypt_by_default=%s",
account.encrypt_by_default)
- yield set_encrypt(ui, self.envelope, block_error=self.encrypt,
+ yield update_keys(ui, self.envelope, block_error=self.encrypt,
signed_only=True)
else:
logging.debug("No encryption by default, encrypt_by_default=%s",
diff --git a/alot/commands/utils.py b/alot/commands/utils.py
index 891f8e37..decaeae2 100644
--- a/alot/commands/utils.py
+++ b/alot/commands/utils.py
@@ -13,7 +13,7 @@ from .. import crypto
@inlineCallbacks
-def set_encrypt(ui, envelope, block_error=False, signed_only=False):
+def update_keys(ui, envelope, block_error=False, signed_only=False):
"""Find and set the encryption keys in an envolope.
:param ui: the main user interface object
diff --git a/tests/commands/utils_tests.py b/tests/commands/utils_tests.py
index c4e4805a..db304552 100644
--- a/tests/commands/utils_tests.py
+++ b/tests/commands/utils_tests.py
@@ -140,7 +140,7 @@ class TestSetEncrypt(unittest.TestCase):
ui = utilities.make_ui()
envelope = Envelope()
envelope['To'] = 'ambig@example.com, test@example.com'
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertTrue(envelope.encrypt)
self.assertCountEqual(
[f.fpr for f in envelope.encrypt_keys.values()],
@@ -151,7 +151,7 @@ class TestSetEncrypt(unittest.TestCase):
ui = utilities.make_ui()
envelope = Envelope()
envelope['Cc'] = 'ambig@example.com, test@example.com'
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertTrue(envelope.encrypt)
self.assertCountEqual(
[f.fpr for f in envelope.encrypt_keys.values()],
@@ -162,7 +162,7 @@ class TestSetEncrypt(unittest.TestCase):
ui = utilities.make_ui()
envelope = Envelope()
envelope['Cc'] = 'foo@example.com, test@example.com'
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertTrue(envelope.encrypt)
self.assertCountEqual(
[f.fpr for f in envelope.encrypt_keys.values()],
@@ -173,7 +173,7 @@ class TestSetEncrypt(unittest.TestCase):
ui = utilities.make_ui()
envelope = Envelope()
envelope['To'] = 'foo@example.com'
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertFalse(envelope.encrypt)
self.assertEqual(envelope.encrypt_keys, {})
@@ -187,7 +187,7 @@ class TestSetEncrypt(unittest.TestCase):
account = _Account(encrypt_to_self=True, gpg_key=gpg_key)
with mock.patch('alot.commands.thread.settings.get_account_by_address',
mock.Mock(return_value=account)):
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertTrue(envelope.encrypt)
self.assertIn(FPR, envelope.encrypt_keys)
self.assertEqual(gpg_key, envelope.encrypt_keys[FPR])
@@ -202,6 +202,6 @@ class TestSetEncrypt(unittest.TestCase):
account = _Account(encrypt_to_self=False, gpg_key=gpg_key)
with mock.patch('alot.commands.thread.settings.get_account_by_address',
mock.Mock(return_value=account)):
- yield utils.set_encrypt(ui, envelope)
+ yield utils.update_keys(ui, envelope)
self.assertTrue(envelope.encrypt)
self.assertNotIn(FPR, envelope.encrypt_keys)