diff options
Diffstat (limited to 'framework/src/domain/mime/tests/mailtemplatetest.cpp')
-rw-r--r-- | framework/src/domain/mime/tests/mailtemplatetest.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index 6338cd58..d5642bb6 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp | |||
@@ -31,16 +31,16 @@ static std::vector< GpgME::Key, std::allocator< GpgME::Key > > getKeys(bool smim | |||
31 | if (smime) { | 31 | if (smime) { |
32 | const QGpgME::Protocol *const backend = QGpgME::smime(); | 32 | const QGpgME::Protocol *const backend = QGpgME::smime(); |
33 | Q_ASSERT(backend); | 33 | Q_ASSERT(backend); |
34 | job = backend->keyListJob(false); | 34 | job = backend->keyListJob(/* remote = */ false); |
35 | } else { | 35 | } else { |
36 | const QGpgME::Protocol *const backend = QGpgME::openpgp(); | 36 | const QGpgME::Protocol *const backend = QGpgME::openpgp(); |
37 | Q_ASSERT(backend); | 37 | Q_ASSERT(backend); |
38 | job = backend->keyListJob(false); | 38 | job = backend->keyListJob(/* remote = */ false); |
39 | } | 39 | } |
40 | Q_ASSERT(job); | 40 | Q_ASSERT(job); |
41 | 41 | ||
42 | std::vector< GpgME::Key > keys; | 42 | std::vector< GpgME::Key > keys; |
43 | GpgME::KeyListResult res = job->exec(QStringList(), true, keys); | 43 | GpgME::KeyListResult res = job->exec(QStringList(), /* secretOnly = */ true, keys); |
44 | 44 | ||
45 | if (!smime) { | 45 | if (!smime) { |
46 | Q_ASSERT(keys.size() == 3); | 46 | Q_ASSERT(keys.size() == 3); |
@@ -401,7 +401,7 @@ private slots: | |||
401 | 401 | ||
402 | std::vector<GpgME::Key> keys = getKeys(); | 402 | std::vector<GpgME::Key> keys = getKeys(); |
403 | 403 | ||
404 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys); | 404 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]); |
405 | 405 | ||
406 | QVERIFY(result); | 406 | QVERIFY(result); |
407 | // qWarning() << "---------------------------------"; | 407 | // qWarning() << "---------------------------------"; |
@@ -409,9 +409,17 @@ private slots: | |||
409 | // qWarning() << "---------------------------------"; | 409 | // qWarning() << "---------------------------------"; |
410 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 410 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
411 | QVERIFY(result->date(false)->dateTime().isValid()); | 411 | QVERIFY(result->date(false)->dateTime().isValid()); |
412 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); | ||
413 | 412 | ||
414 | const auto contents = result->contents(); | 413 | QCOMPARE(result->contentType()->mimeType(), "multipart/mixed"); |
414 | auto resultAttachments = result->attachments(); | ||
415 | QCOMPARE(resultAttachments.size(), 1); | ||
416 | QCOMPARE(resultAttachments[0]->contentDisposition()->filename(), "0x8F246DE6.asc"); | ||
417 | |||
418 | auto signedMessage = result->contents()[0]; | ||
419 | |||
420 | QVERIFY(signedMessage->contentType()->isMimeType("multipart/signed")); | ||
421 | |||
422 | const auto contents = signedMessage->contents(); | ||
415 | QCOMPARE(contents.size(), 2); | 423 | QCOMPARE(contents.size(), 2); |
416 | { | 424 | { |
417 | auto c = contents.at(0); | 425 | auto c = contents.at(0); |
@@ -441,9 +449,19 @@ private slots: | |||
441 | QVERIFY(result); | 449 | QVERIFY(result); |
442 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 450 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
443 | QVERIFY(result->date(false)->dateTime().isValid()); | 451 | QVERIFY(result->date(false)->dateTime().isValid()); |
444 | QVERIFY(result->contentType()->isMimeType("multipart/signed")); | ||
445 | 452 | ||
446 | const auto contents = result->contents(); | 453 | QCOMPARE(result->contentType()->mimeType(), "multipart/mixed"); |
454 | auto resultAttachments = result->attachments(); | ||
455 | QCOMPARE(resultAttachments.size(), 3); | ||
456 | // It seems KMime searches for the attachments using depth-first | ||
457 | // search, so the public key is last | ||
458 | QCOMPARE(resultAttachments[2]->contentDisposition()->filename(), "0x8F246DE6.asc"); | ||
459 | |||
460 | auto signedMessage = result->contents()[0]; | ||
461 | |||
462 | QVERIFY(signedMessage->contentType()->isMimeType("multipart/signed")); | ||
463 | |||
464 | const auto contents = signedMessage->contents(); | ||
447 | QCOMPARE(contents.size(), 2); | 465 | QCOMPARE(contents.size(), 2); |
448 | { | 466 | { |
449 | auto c = contents.at(0); | 467 | auto c = contents.at(0); |