def test_get_no_keys(self): ui = utilities.make_ui() envelope = Envelope() envelope['To'] = '*****@*****.**' yield utils.set_encrypt(ui, envelope) self.assertFalse(envelope.encrypt) self.assertEqual(envelope.encrypt_keys, {})
def test_get_partial_keys(self): ui = mock.Mock() envelope = Envelope() envelope['Cc'] = '[email protected], [email protected]' yield utils.set_encrypt(ui, envelope) self.assertTrue(envelope.encrypt) self.assertEqual([f.fpr for f in envelope.encrypt_keys.itervalues()], [crypto.get_key(FPR).fpr])
def test_get_partial_keys(self): ui = utilities.make_ui() envelope = Envelope() envelope['Cc'] = '[email protected], [email protected]' yield utils.set_encrypt(ui, envelope) self.assertTrue(envelope.encrypt) self.assertEqual( [f.fpr for f in envelope.encrypt_keys.itervalues()], [crypto.get_key(FPR).fpr])
def test_get_keys_from_cc(self): ui = utilities.make_ui() envelope = Envelope() envelope['Cc'] = '[email protected], [email protected]' yield utils.set_encrypt(ui, envelope) self.assertTrue(envelope.encrypt) self.assertEqual( [f.fpr for f in envelope.encrypt_keys.itervalues()], [crypto.get_key(FPR).fpr, crypto.get_key(EXTRA_FPRS[0]).fpr])
def test_encrypt_to_self_false(self): ui = utilities.make_ui() envelope = Envelope() envelope['From'] = '*****@*****.**' envelope['To'] = '*****@*****.**' gpg_key = crypto.get_key(FPR) 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) self.assertTrue(envelope.encrypt) self.assertNotIn(FPR, envelope.encrypt_keys)