From e7b29f53e9928ddb7b467fcf1bdd1bb650668cba Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Tue, 4 Dec 2018 22:38:04 +0000 Subject: add test test_unknown_cte_value that tests if a message with unknown content-transfer-encoding header, but otherwise correct ascii encoded payload, is warned about. --- tests/db/utils_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/db') diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 160ef453..6656aae5 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -750,3 +750,15 @@ class TestRemoveCte(unittest.TestCase): # We expect no Exceptions but a complaint in the log logmsg = 'INFO:root:Unknown Content-Transfer-Encoding: "7bit;"' self.assertEqual(cm.output, [logmsg]) + + def test_unknown_cte_value(self): + with open('tests/static/mail/malformed-header-CTE-2.eml') as fp: + mail = email.message_from_file(fp) + + with self.assertLogs(level='DEBUG') as cm: # keep logs + utils.remove_cte(mail, as_string=True) + + # We expect no Exceptions but a complaint in the log + logmsg = 'DEBUG:root:failed to interpret Content-Transfer-Encoding: '\ + '"normal"' + self.assertIn(logmsg, cm.output) -- cgit v1.2.3