diff options
Diffstat (limited to 'framework/src/domain/mime/tests/mailtemplatetest.cpp')
-rw-r--r-- | framework/src/domain/mime/tests/mailtemplatetest.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index 8d044608..6338cd58 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp | |||
@@ -248,6 +248,55 @@ private slots: | |||
248 | QCOMPARE(origMsg->subject(false)->asUnicodeString(), {"A random subject with alternative contenttype"}); | 248 | QCOMPARE(origMsg->subject(false)->asUnicodeString(), {"A random subject with alternative contenttype"}); |
249 | } | 249 | } |
250 | 250 | ||
251 | void testEncryptedForwardAsAttachment() | ||
252 | { | ||
253 | auto msg = readMail("openpgp-encrypted.mbox"); | ||
254 | KMime::Message::Ptr result; | ||
255 | MailTemplates::forward(msg, [&](const KMime::Message::Ptr &r) { result = r; }); | ||
256 | QTRY_VERIFY(result); | ||
257 | QCOMPARE(result->subject(false)->asUnicodeString(), {"FW: OpenPGP encrypted"}); | ||
258 | QCOMPARE(result->to()->addresses(), {}); | ||
259 | QCOMPARE(result->cc()->addresses(), {}); | ||
260 | |||
261 | auto attachments = result->attachments(); | ||
262 | QCOMPARE(attachments.size(), 1); | ||
263 | auto attachment = attachments[0]; | ||
264 | QCOMPARE(attachment->contentDisposition(false)->disposition(), KMime::Headers::CDinline); | ||
265 | QCOMPARE(attachment->contentDisposition(false)->filename(), {"OpenPGP encrypted.eml"}); | ||
266 | QVERIFY(attachment->bodyIsMessage()); | ||
267 | |||
268 | attachment->parse(); | ||
269 | auto origMsg = attachment->bodyAsMessage(); | ||
270 | QCOMPARE(origMsg->subject(false)->asUnicodeString(), {"OpenPGP encrypted"}); | ||
271 | } | ||
272 | |||
273 | void testEncryptedWithAttachmentsForwardAsAttachment() | ||
274 | { | ||
275 | auto msg = readMail("openpgp-encrypted-two-attachments.mbox"); | ||
276 | KMime::Message::Ptr result; | ||
277 | MailTemplates::forward(msg, [&](const KMime::Message::Ptr &r) { result = r; }); | ||
278 | QTRY_VERIFY(result); | ||
279 | QCOMPARE(result->subject(false)->asUnicodeString(), {"FW: OpenPGP encrypted with 2 text attachments"}); | ||
280 | QCOMPARE(result->to()->addresses(), {}); | ||
281 | QCOMPARE(result->cc()->addresses(), {}); | ||
282 | |||
283 | auto attachments = result->attachments(); | ||
284 | QCOMPARE(attachments.size(), 1); | ||
285 | auto attachment = attachments[0]; | ||
286 | QCOMPARE(attachment->contentDisposition(false)->disposition(), KMime::Headers::CDinline); | ||
287 | QCOMPARE(attachment->contentDisposition(false)->filename(), {"OpenPGP encrypted with 2 text attachments.eml"}); | ||
288 | QVERIFY(attachment->bodyIsMessage()); | ||
289 | |||
290 | attachment->parse(); | ||
291 | auto origMsg = attachment->bodyAsMessage(); | ||
292 | QCOMPARE(origMsg->subject(false)->asUnicodeString(), {"OpenPGP encrypted with 2 text attachments"}); | ||
293 | |||
294 | auto attattachments = origMsg->attachments(); | ||
295 | QCOMPARE(attattachments.size(), 2); | ||
296 | QCOMPARE(attattachments[0]->contentDisposition(false)->filename(), {"attachment1.txt"}); | ||
297 | QCOMPARE(attattachments[1]->contentDisposition(false)->filename(), {"attachment2.txt"}); | ||
298 | } | ||
299 | |||
251 | void testCreatePlainMail() | 300 | void testCreatePlainMail() |
252 | { | 301 | { |
253 | QStringList to = {{"to@example.org"}}; | 302 | QStringList to = {{"to@example.org"}}; |