qt: Add test for setting tofu policy
* lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.
This commit is contained in:
parent
77aecfb5c9
commit
a8ff34fc30
@ -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("bravo@example.net"),
|
||||
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("bravo@example.net"),
|
||||
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("bravo@example.net"),
|
||||
false, keys);
|
||||
key = keys[0];
|
||||
Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
|
||||
delete tofuJob;
|
||||
delete job;
|
||||
}
|
||||
|
||||
void initTestCase()
|
||||
{
|
||||
QGpgMETest::initTestCase();
|
||||
|
Loading…
Reference in New Issue
Block a user