def test_length_0(self): mail = self.FakeMail() utils.add_signature_headers(mail, [], u'') self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers) self.assertIn( (utils.X_SIGNATURE_MESSAGE_HEADER, u'Invalid: no signature found'), mail.headers)
def test_length_0(self): mail = self.FakeMail() utils.add_signature_headers(mail, [], u'') self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers) self.assertIn( (utils.X_SIGNATURE_MESSAGE_HEADER, u'Invalid: no signature found'), mail.headers)
def test_get_key_fails(self): mail = self.FakeMail() with mock.patch('alot.db.utils.crypto.get_key', mock.Mock(side_effect=GPGProblem(u'', 0))): utils.add_signature_headers(mail, [mock.Mock(fpr='')], u'') self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers) self.assertIn((utils.X_SIGNATURE_MESSAGE_HEADER, u'Untrusted: '), mail.headers)
def test_get_key_fails(self): mail = self.FakeMail() with mock.patch('alot.db.utils.crypto.get_key', mock.Mock(side_effect=GPGProblem(u'', 0))): utils.add_signature_headers(mail, [mock.Mock(fpr='')], u'') self.assertIn((utils.X_SIGNATURE_VALID_HEADER, u'False'), mail.headers) self.assertIn( (utils.X_SIGNATURE_MESSAGE_HEADER, u'Untrusted: '), mail.headers)
def check(self, key, valid, error_msg=u''): mail = self.FakeMail() with mock.patch('alot.db.utils.crypto.get_key', mock.Mock(return_value=key)), \ mock.patch('alot.db.utils.crypto.check_uid_validity', mock.Mock(return_value=valid)): utils.add_signature_headers(mail, [mock.Mock(fpr='')], error_msg) return mail
def check(self, key, valid, error_msg=u''): mail = self.FakeMail() with mock.patch('alot.db.utils.crypto.get_key', mock.Mock(return_value=key)), \ mock.patch('alot.db.utils.crypto.check_uid_validity', mock.Mock(return_value=valid)): utils.add_signature_headers(mail, [mock.Mock(fpr='')], error_msg) return mail