summaryrefslogtreecommitdiff
path: root/tests/db
Commit message (Collapse)AuthorAge
* restore lenient libmagic decodingMichael J Gruber2019-02-07
| | | | | | | | 176cffcd ("refactor alot.db.utils.remove_cte", 2018-12-04) created a few problems with 8bit quoted-printable e-mails, see #1291 #1360. This commit restores the old libmagic fallback which did not cause this problem.
* Rename test filesLucas Hoffmann2019-01-29
| | | | | | | | The two main reasons are - to run `python3 -m unittest discover` without specifying a custom `--pattern *_test.py` - to include the test files automatically when generating the MANIFEST file.
* Add test case for new encoding problemsLucas Hoffmann2018-12-24
|
* refactor test_issue_1291Patrick Totzke2018-12-07
| | | | | | this is now test_char_vs_cte_mismatch; It checks if a mime part contains a character which is not encoded in the encoding declared in the Content-Transfer-Encoding header
* add test test_unknown_cte_valuePatrick Totzke2018-12-07
| | | | | that tests if a message with unknown content-transfer-encoding header, but otherwise correct ascii encoded payload, is warned about.
* tests: update test_malformed_cte_valuePatrick Totzke2018-12-07
| | | | | It now tests if malformed Content-Transfer-Encoding values are reported in the logs
* pep8 fixesPatrick Totzke2018-12-03
|
* Add test for #1301Lucas Hoffmann2018-12-03
| | | | | | This adds a test for detecting a malformed content-transfer-encoding (trailing semi-colon). It also changes the raised exception to the more appropriate ValueError.
* Add simple test to demonstrate #1291Lucas Hoffmann2018-12-03
| | | | This does just call the final bit of code that throws the exception.
* crypto: Use session-key to decrypt messages if present in the indexRuben Pollan2018-10-08
| | | | | | | | | | notmuch caches the OpenPGP session keys if configured to do so. See index.decrypt on: https://notmuchmail.org/manpages/notmuch-config-1/ Using the cached session key decryption of messages can be done without the need of having the private OpenPGP key. There is some speed up on decryption, mostly notable on long encrypted threads.
* db/utils: Replace encode_header with Message.add_headerDylan Baker2018-08-04
| | | | | Which appears to be capable of doing all the same things, but is in the stdlib instead of something we hand rolled.
* db: encode Header objects to strDylan Baker2018-08-04
| | | | | | | | | | | In python 3 with the use of Policy objects (other than the Compat32 object which maintains the previous (python 2.x and <=3.2) API) change the way headers work, and the old Header object is no longer used. This is rather convenient in that python now implements many of the rules required for sepcial header types, but it changes the API. This fixes that by encoding the Header objects to strings. Fixes #1289
* tests/db/envelope: Add tests for construct_mailDylan Baker2018-08-04
|
* helper: replace email_as_* with email builtinsDylan Baker2018-08-02
| | | | | | | | | | | | | | Python 3.3 added a new feature to the email module, policies (https://docs.python.org/3.5/library/email.policy.html). Policy objects allow precise control over how numerous features work when converting to and from str or bytes. With the `email.policy.SMTP` the behavior of email_as_bytes and email_as_string can be achieved using the builtin `.as_string()` and `.as_bytes()` methods, without custom code or the need to test it. Additionally these methods handle corner cases that we don't currently handle, such as multi-part messages with different encodings. Fixes #1257
* tests for alot.db.managerPatrick Totzke2018-07-24
| | | | | This adds a new TestCase for the database manager and adds a test for saving/reading named query strings to the database.
* rename message_from_ functionsMichael J Gruber2018-07-11
| | | | | | | | | | Our message_from_functions decrypt PGP encryped parts in addition to creating a message object (from bytes or file handles) and recognizing the encoding in one way or the other. Rename them before refactoring to make their function clearer and to distinguish them from the email.message_from_ functions (which do not decrypt).
* Remove old __future__ importsLucas Hoffmann2018-06-19
| | | | They are not needed for python >= 3.0.
* Fix bad refactor of a testDylan Baker2018-05-07
|
* Fix some formatting requests for @luccDylan Baker2018-04-24
|
* Wrap long statements on open-bracket syntax.Ben Finney2018-04-23
|
* Refactor some long statements to allow shorter lines.Ben Finney2018-04-23
|
* db/utils: decoded_headers will be passed str not bytesDylan Baker2018-03-12
| | | | | | | I had made the assumption early on that this would get bytes, but when I added `assert isinstance(header, bytes)` alot would crash on startup, changing `bytes` to `str` fixed that. I noticed this when trying to fix the warning generated in the logging call.
* Fix some of the quoted words tests for py3kDylan Baker2018-03-01
|
* fix a bunch of utils tests for py3kDylan Baker2018-03-01
| | | | | There are a few that are still broken because of bytes to unicode conversion, and this may not all be correct, but most of the tests pass
* tests/db/thread: Fix tests for py3kDylan Baker2018-03-01
|
* db/message: Try to use the 'Sender' header if the 'From' header is nullDylan Baker2017-09-06
| | | | This makes drafts display correctly.
* db/message: Don't set sender to ''Dylan Baker2017-09-06
| | | | | | | If the message doesn't have a sender, try to come up with one. If the message has the draft tag we known that the user is the sender, just use the default account as the from if we can't find one another way. If it doesn't have the draft tag just set the sending to 'Unknown'.
* tests/db/message: Add some tests for the message moduleDylan Baker2017-09-06
| | | | | These are just enough to look at the bug that will be fixed in the patches that follow.
* tests/db/utils: Add tests for message_from_stringDylan Baker2017-08-28
|
* tests/db/utils: Add tests for extract_body functionDylan Baker2017-08-28
| | | | | | there are probably still some corners with mailcap handling (parameters like copiousoutput) that are untested, but this covers a large swath of the functionality.
* db/utils: Don't mark signature valid if there is no key to verifyDylan Baker2017-08-23
|
* tests/db/utils: Add some more coverage to add_signature_headersDylan Baker2017-08-23
| | | | | There are a couple of pieces of this function that aren't covered, including a bug. yay bugs.
* db/utils: Allow encrypted messages to be put in mixed payloads as wellDylan Baker2017-08-17
| | | | | | | | Since a multipart/mixed can contain anything that a normal message could, this should be allowed. The only case that I can think of this actually happening is if an email server takes the original message, puts it in a multipart/mixed, and then attaches it's own message, like on of the annoying "this mail scanned for viruses by <product>".
* db/utils: Handle multipart/signed inside multipart/mixedDylan Baker2017-08-17
| | | | | | | | It is possible (and actual mail clients such as kmail do) to embed a multipart/signed within a multipart/mixed (this is briefly mentioned in the acknowledgements of RFC 3156, and is perfectly valid according to RFC 1341, which says that a multipart/mixed is exactly like a top level message, except that the header may be empty.
* tests/db/utils: Add tests for encapsulating gpg messagesDylan Baker2017-08-17
| | | | | | | It is valid to encapsulate the multipart/signed and multipart/encrypted payloads in a multipart/mixed payload. All of these tests currently fail.
* db/utils: Don't attach invalid signature to unsigned but encrypted messagesDylan Baker2017-08-17
| | | | | | The logic in the comment is faulty. There are perfectly legitimate reasons to encrypt but not sign a message, some of them are fleshed out in the previous commit.
* tests/db/utils: Add tests for message_from_fileDylan Baker2017-08-17
| | | | | | | | | | | | | | | | | | | | This class tests most of the function fairly thoroughly. There are a couple of error cases that are untested, but could be tested fairly easily with some mocking. There is one test marked as expected failure. In this case I disagree with what alot does, though there probably isn't a canonical correct behavior. Specifically, if a message is encrypted but unsigned, we generate a header that says the signature is invalid. This seems incorrect for a number of reasons. First, since there is no signature, it cannot be invalid. Second, the reasoning is that it "seems suspicious" that someone would encrypt but not sign a message. This is silly, there are plenty of people who encrypt but don't sign their messages, since signing and encrypting have two totally different purposes. Signatures verify who *wrote* the message, but encryption verifies who *reads* the message. People who need some level of deniability about who wrote the message, but not about who read it (like a political activist or whistle blower) might encrypt but not sign.
* db/utils: Support unicode in signaturesDylan Baker2017-07-24
| | | | | | Currently if a signature name has a non-ascii unicode character in it, the thread will fail to load because a UnicodeEncodeError. This patch fixes that by converting the str into unicode.
* tests/db/utils: Add tests for unicode as uidsDylan Baker2017-07-24
| | | | One of these tests is known to fail, and marked as xfail.
* tests/db/utils: share some mock biolerplateDylan Baker2017-07-24
|
* tests: move shared helpers out of crypto module into common moduleDylan Baker2017-07-24
|
* tests: Add some basic tests for alot.db.utils.add_signature_headerDylan Baker2017-07-24
| | | | | These are pretty basic, but they do cover most of the conditions, even if they rely heavily on mocking.
* tests: fix typo in module name envelop -> envelopeDylan Baker2017-07-10
|
* Use stdlib functions in db.utils.encode_headerLucas Hoffmann2017-06-30
| | | | | | | Instead of manual parsing with regexp and manual string formatting the functions from email.utils are used. This fixes some small inconsistencies with addresses with empty realnames and with commas in realnames.
* Add more tests for db.utils.encode_headerLucas Hoffmann2017-06-30
|
* Add helper function to quote test stringsLucas Hoffmann2017-06-21
|
* Add test for db.utils.decode_headerLucas Hoffmann2017-06-21
|
* Add test for db.utils.encode_headerLucas Hoffmann2017-06-21
|
* Add test for db.utils.extract_headersLucas Hoffmann2017-06-21
|
* Add test for db.utils.is_subdir_ofLucas Hoffmann2017-06-21
|