[Pkg-gnupg-commit] [gpgme] 379/412: qt: Add test for setting tofu policy
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:27:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit a8ff34fc3025af4079cede7f8f9fdf40189b8638
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Sep 16 16:58:00 2016 +0200
qt: Add test for setting tofu policy
* lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.
---
lang/qt/tests/t-tofuinfo.cpp | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 2e1f1f8..f40bf21 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("bravo at 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 at 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 at example.net"),
+ false, keys);
+ key = keys[0];
+ Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
+ delete tofuJob;
+ delete job;
+ }
+
void initTestCase()
{
QGpgMETest::initTestCase();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list