diff options
Diffstat (limited to 'lang/qt/tests/t-tofuinfo.cpp')
| -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(); | 
