summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mime/tests/mailtemplatetest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/mime/tests/mailtemplatetest.cpp')
-rw-r--r--framework/src/domain/mime/tests/mailtemplatetest.cpp50
1 files changed, 2 insertions, 48 deletions
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp
index d07b704d..75debd75 100644
--- a/framework/src/domain/mime/tests/mailtemplatetest.cpp
+++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp
@@ -6,10 +6,6 @@
6#include <QDir> 6#include <QDir>
7#include <QtWebEngine> 7#include <QtWebEngine>
8 8
9#include <QGpgME/KeyListJob>
10#include <QGpgME/Protocol>
11#include <gpgme++/key.h>
12#include <gpgme++/keylistresult.h>
13 9
14#include "mailtemplates.h" 10#include "mailtemplates.h"
15#include "mailcrypto.h" 11#include "mailcrypto.h"
@@ -24,45 +20,6 @@ static KMime::Content *getSubpart(KMime::Content *msg, const QByteArray &mimeTyp
24 return nullptr; 20 return nullptr;
25} 21}
26 22
27static std::vector< GpgME::Key, std::allocator< GpgME::Key > > getKeys(bool smime = false)
28{
29 QGpgME::KeyListJob *job = nullptr;
30
31 if (smime) {
32 const QGpgME::Protocol *const backend = QGpgME::smime();
33 Q_ASSERT(backend);
34 job = backend->keyListJob(/* remote = */ false);
35 } else {
36 const QGpgME::Protocol *const backend = QGpgME::openpgp();
37 Q_ASSERT(backend);
38 job = backend->keyListJob(/* remote = */ false);
39 }
40 Q_ASSERT(job);
41
42 std::vector< GpgME::Key > keys;
43 GpgME::KeyListResult res = job->exec(QStringList(), /* secretOnly = */ true, keys);
44
45 if (!smime) {
46 Q_ASSERT(keys.size() == 3);
47 }
48
49 Q_ASSERT(!res.error());
50
51 /*
52 qDebug() << "got private keys:" << keys.size();
53
54 for (std::vector< GpgME::Key >::iterator i = keys.begin(); i != keys.end(); ++i) {
55 qDebug() << "key isnull:" << i->isNull() << "isexpired:" << i->isExpired();
56 qDebug() << "key numuserIds:" << i->numUserIDs();
57 for (uint k = 0; k < i->numUserIDs(); ++k) {
58 qDebug() << "userIDs:" << i->userID(k).email();
59 }
60 }
61 */
62
63 return keys;
64}
65
66static QByteArray readMailFromFile(const QString &mailFile) 23static QByteArray readMailFromFile(const QString &mailFile)
67{ 24{
68 Q_ASSERT(!QString::fromLatin1(MAIL_DATA_DIR).isEmpty()); 25 Q_ASSERT(!QString::fromLatin1(MAIL_DATA_DIR).isEmpty());
@@ -399,8 +356,7 @@ private slots:
399 QString body = "body"; 356 QString body = "body";
400 QList<Attachment> attachments; 357 QList<Attachment> attachments;
401 358
402 std::vector<GpgME::Key> keys = getKeys(); 359 auto keys = MailCrypto::findKeys({}, true, false);
403
404 auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]); 360 auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]);
405 361
406 QVERIFY(result); 362 QVERIFY(result);
@@ -442,9 +398,7 @@ private slots:
442 QString body = "body"; 398 QString body = "body";
443 QList<Attachment> attachments = {{"name", "filename", "mimetype", true, "inlineAttachment"}, {"name", "filename", "mimetype", false, "nonInlineAttachment"}}; 399 QList<Attachment> attachments = {{"name", "filename", "mimetype", true, "inlineAttachment"}, {"name", "filename", "mimetype", false, "nonInlineAttachment"}};
444 400
445 std::vector<GpgME::Key> keys = getKeys(); 401 auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, MailCrypto::findKeys({}, true, false));
446
447 auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys);
448 402
449 QVERIFY(result); 403 QVERIFY(result);
450 QCOMPARE(result->subject()->asUnicodeString(), subject); 404 QCOMPARE(result->subject()->asUnicodeString(), subject);