Changeset View
Changeset View
Standalone View
Standalone View
framework/src/domain/mime/tests/mailtemplatetest.cpp
Context not available. | |||||
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); | ||
Context not available. | |||||
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() << "---------------------------------"; | ||
Context not available. | |||||
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); | ||
Context not available. | |||||
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); | ||
Context not available. |