[Pkg-gnupg-commit] [gpgme] 52/132: qt: Add test for tofu conflict
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Apr 26 01:01:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gpgme.
commit 43160a39f27f6c3507447620666c85af00b3499c
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Thu Feb 2 17:16:27 2017 +0100
qt: Add test for tofu conflict
* lang/qt/tests/t-tofuinfo.cpp (TofuInfoTest::testTofuConflict): New.
---
lang/qt/tests/t-tofuinfo.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 133 insertions(+)
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index d88861c..e16b1fd 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -35,12 +35,16 @@
#include <QDebug>
#include <QTest>
#include <QTemporaryDir>
+#include <QSignalSpy>
+
#include "protocol.h"
#include "tofuinfo.h"
#include "tofupolicyjob.h"
#include "verifyopaquejob.h"
#include "verificationresult.h"
#include "signingresult.h"
+#include "importjob.h"
+#include "importresult.h"
#include "keylistjob.h"
#include "keylistresult.h"
#include "qgpgmesignjob.h"
@@ -61,10 +65,57 @@ static const char testMsg1[] =
"=Crq6\n"
"-----END PGP MESSAGE-----\n";
+static const char conflictKey1[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+"\n"
+"mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n"
+"K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n"
+"DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
+"Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n"
+"cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n"
+"CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n"
+"CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n"
+"wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n"
+"0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n"
+"=p2Oj\n"
+"-----END PGP PUBLIC KEY BLOCK-----\n";
+
+static const char conflictKey2[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+"\n"
+"mDMEWG+xShYJKwYBBAHaRw8BAQdA567gPEPJRpqKnZjlFJMRNUqruRviYMyygfF6\n"
+"6Ok+ygu0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBJ5kRh7E\n"
+"I98w8kgUcmkAfYFvqqHsBQJYb7FKAhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
+"Ah4BAheAAAoJEGkAfYFvqqHsYR0BAOz8JjYB4VvGkt6noLS3F5TLfsedGwQkBCw5\n"
+"znw/vGZsAQD9DSX+ekwdrN56mNO8ISt5uVS7B1ZQtouNBF+nzcwbDbg4BFhvsUoS\n"
+"CisGAQQBl1UBBQEBB0BFupW8+Xc1ikab8TJqANjQhvFVh6uLsgcK4g9lZgbGXAMB\n"
+"CAeIeAQYFggAIBYhBJ5kRh7EI98w8kgUcmkAfYFvqqHsBQJYb7FKAhsMAAoJEGkA\n"
+"fYFvqqHs15ABALdN3uiV/07cJ3RkNb3WPcijGsto+lECDS11dKEwTMFeAQDx+V36\n"
+"ocbYC/xEuwi3w45oNqGieazzcD/GBbt8OBk3BA==\n"
+"=45IR\n"
+"-----END PGP PUBLIC KEY BLOCK-----\n";
+
+static const char conflictMsg1[] = "-----BEGIN PGP MESSAGE-----\n"
+"\n"
+"owGbwMvMwCG2z/HA4aX/5W0YT3MlMUTkb2xPSizi6ihlYRDjYJAVU2Sp4mTZNpV3\n"
+"5QwmLqkrMLWsTCCFDFycAjCR1vcMf4U0Qrs6qzqfHJ9puGOFduLN2nVmhsumxjBE\n"
+"mdw4lr1ehIWR4QdLuNBpe86PGx1PtNXfVAzm/hu+vfjCp5BVNjPTM9L0eAA=\n"
+"=MfBD\n"
+"-----END PGP MESSAGE-----\n";
+
+static const char conflictMsg2[] = "-----BEGIN PGP MESSAGE-----\n"
+"\n"
+"owGbwMvMwCGWyVDbmL9q4RvG01xJDBH5GyvS8vO5OkpZGMQ4GGTFFFnmpbjJHVG+\n"
+"b/DJQ6QIppaVCaSQgYtTACaySZHhr/SOPrdFJ89KrcwKY5i1XnflXYf2PK76SafK\n"
+"tkxXuXzvJAvDX4kCybuqFk3HXCexz2+IrnZ+5X5EqOnuo3ens2cte+uzlhMA\n"
+"=BIAi\n"
+"-----END PGP MESSAGE-----\n";
+
class TofuInfoTest: public QGpgMETest
{
Q_OBJECT
+Q_SIGNALS:
+ void asyncDone();
+private:
bool testSupported()
{
return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16");
@@ -349,6 +400,88 @@ private Q_SLOTS:
delete job;
}
+ void testTofuConflict()
+ {
+ if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") {
+ return;
+ }
+
+ // Import key 1
+ auto importjob = openpgp()->importJob();
+ connect(importjob, &ImportJob::result, this,
+ [this](ImportResult result, QString, Error)
+ {
+ QVERIFY(!result.error());
+ QVERIFY(!result.imports().empty());
+ QVERIFY(result.numImported());
+ Q_EMIT asyncDone();
+ });
+ importjob->start(QByteArray(conflictKey1));
+ QSignalSpy spy (this, SIGNAL(asyncDone()));
+ QVERIFY(spy.wait());
+
+ // Verify Message 1
+ const QByteArray signedData(conflictMsg1);
+ auto verifyJob = openpgp()->verifyOpaqueJob(true);
+ QByteArray verified;
+ auto result = verifyJob->exec(signedData, verified);
+ delete verifyJob;
+
+ QVERIFY(!result.isNull());
+ QVERIFY(!result.error());
+
+ QVERIFY(result.numSignatures() == 1);
+ auto sig = result.signatures()[0];
+ QVERIFY(sig.validity() == Signature::Marginal);
+
+ auto stats = sig.key().userID(0).tofuInfo();
+ QVERIFY(!stats.isNull());
+ QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
+ QVERIFY(stats.signFirst() == stats.signLast());
+ QVERIFY(stats.signCount() == 1);
+ QVERIFY(stats.policy() == TofuInfo::PolicyAuto);
+ QVERIFY(stats.validity() == TofuInfo::LittleHistory);
+
+ // Import key 2
+ importjob = openpgp()->importJob();
+ connect(importjob, &ImportJob::result, this,
+ [this](ImportResult result, QString, Error)
+ {
+ QVERIFY(!result.error());
+ QVERIFY(!result.imports().empty());
+ QVERIFY(result.numImported());
+ Q_EMIT asyncDone();
+ });
+ importjob->start(QByteArray(conflictKey2));
+ QSignalSpy spy2 (this, SIGNAL(asyncDone()));
+ QVERIFY(spy2.wait());
+
+ // Verify Message 2
+ const QByteArray signedData2(conflictMsg2);
+ QByteArray verified2;
+ verifyJob = openpgp()->verifyOpaqueJob(true);
+ result = verifyJob->exec(signedData2, verified2);
+ delete verifyJob;
+
+ QVERIFY(!result.isNull());
+ QVERIFY(!result.error());
+
+ QVERIFY(result.numSignatures() == 1);
+ sig = result.signatures()[0];
+ QVERIFY(sig.validity() == Signature::Unknown);
+ // TODO activate when implemented
+ // QVERIFY(sig.summary() == Signature::TofuConflict);
+
+ stats = sig.key().userID(0).tofuInfo();
+ QVERIFY(!stats.isNull());
+ QVERIFY(!strcmp(sig.key().primaryFingerprint(), sig.fingerprint()));
+ QVERIFY(stats.signFirst() == stats.signLast());
+ QVERIFY(stats.signCount() == 1);
+ QVERIFY(stats.policy() == TofuInfo::PolicyAsk);
+ QVERIFY(stats.validity() == TofuInfo::Conflict);
+ }
+
+
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