diff options
author | Andre Heinecke <[email protected]> | 2016-09-16 14:58:00 +0000 |
---|---|---|
committer | Andre Heinecke <[email protected]> | 2016-09-16 14:58:39 +0000 |
commit | a8ff34fc3025af4079cede7f8f9fdf40189b8638 (patch) | |
tree | 2d76584bec049c986909bf31d74d9999a54988b0 | |
parent | qt: Add job for tofupolicy (diff) | |
download | gpgme-a8ff34fc3025af4079cede7f8f9fdf40189b8638.tar.gz gpgme-a8ff34fc3025af4079cede7f8f9fdf40189b8638.zip |
qt: Add test for setting tofu policy
* lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.
-rw-r--r-- | lang/qt/tests/t-tofuinfo.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index 2e1f1f88..f40bf21d 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -33,6 +33,7 @@ #include <QTemporaryDir> #include "protocol.h" #include "tofuinfo.h" +#include "tofupolicyjob.h" #include "verifyopaquejob.h" #include "verificationresult.h" #include "signingresult.h" @@ -285,6 +286,41 @@ private Q_SLOTS: Q_ASSERT(info.signCount()); } + void testTofuPolicy() + { + if (!testSupported()) { + return; + } + + /* First check that the key has no tofu info. */ + auto *job = openpgp()->keyListJob(false, false, false); + std::vector<GpgME::Key> keys; + job->addMode(GpgME::WithTofu); + auto result = job->exec(QStringList() << QStringLiteral("[email protected]"), + false, keys); + + Q_ASSERT(!keys.empty()); + auto key = keys[0]; + Q_ASSERT(!key.isNull()); + Q_ASSERT(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad); + auto *tofuJob = openpgp()->tofuPolicyJob(); + auto err = tofuJob->exec(key, TofuInfo::PolicyBad); + Q_ASSERT(!err); + result = job->exec(QStringList() << QStringLiteral("[email protected]"), + false, keys); + Q_ASSERT(!keys.empty()); + key = keys[0]; + Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad); + err = tofuJob->exec(key, TofuInfo::PolicyGood); + + result = job->exec(QStringList() << QStringLiteral("[email protected]"), + false, keys); + key = keys[0]; + Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood); + delete tofuJob; + delete job; + } + void initTestCase() { QGpgMETest::initTestCase(); |