[Pkg-gnupg-commit] [gpgme] 318/412: qt: Fix and extend TofuInfo test.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:27:11 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 9fc72e928bf2cf239bd3b0facdf33ceb1acc975b
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Aug 25 16:25:49 2016 +0200

    qt: Fix and extend TofuInfo test.
    
    * lang/qt/tests/t-tofuinfo.cpp: Delete executed jobs.
    (testTofuKeyList): New.
    (testSupported): Activate for 2.1.16
    (signAndVerify): Disable sigcount tests.
---
 lang/qt/tests/t-tofuinfo.cpp | 61 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index d306167..30f7bea 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -62,10 +62,7 @@ class TofuInfoTest: public QGpgMETest
 
     bool testSupported()
     {
-        /* GnuPG currently returns different values for different uid's
-         * on the first verify. This breaks this test. so its disabled
-         * for now. See GnuPG-Bug 2405 */
-        return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "3.0.0");
+        return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16");
     }
 
     void testTofuCopy(TofuInfo other, const TofuInfo &orig)
@@ -90,9 +87,12 @@ class TofuInfoTest: public QGpgMETest
         keys.push_back(key);
         QByteArray signedData;
         auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData);
+        delete job;
 
         auto info = keys[0].userID(0).tofuInfo();
-        Q_ASSERT(info.signCount() == expected - 1);
+        if (expected != -1) {
+            Q_ASSERT(info.signCount() == expected - 1);
+        }
 
         Q_ASSERT(!sigResult.error());
 
@@ -100,6 +100,7 @@ class TofuInfoTest: public QGpgMETest
         QByteArray verified;
 
         auto result = verifyJob->exec(signedData, verified);
+        delete verifyJob;
 
         Q_ASSERT(!result.error());
         Q_ASSERT(verified == what.toUtf8());
@@ -113,7 +114,9 @@ class TofuInfoTest: public QGpgMETest
         Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint()));
         auto stats = key2.userID(0).tofuInfo();
         Q_ASSERT(!stats.isNull());
-        Q_ASSERT(stats.signCount() == expected);
+        if (expected != -1) {
+            Q_ASSERT(stats.signCount() == expected);
+        }
     }
 
 private Q_SLOTS:
@@ -142,6 +145,7 @@ private Q_SLOTS:
         QByteArray plaintext;
 
         auto result = job->exec(data1, plaintext);
+        delete job;
 
         Q_ASSERT(!result.isNull());
         Q_ASSERT(!result.error());
@@ -168,6 +172,7 @@ private Q_SLOTS:
 
         job = openpgp()->verifyOpaqueJob(true);
         result = job->exec(data1, plaintext);
+        delete job;
 
         Q_ASSERT(!result.isNull());
         Q_ASSERT(!result.error());
@@ -188,6 +193,7 @@ private Q_SLOTS:
         /* Verify that another call yields the same result */
         job = openpgp()->verifyOpaqueJob(true);
         result = job->exec(data1, plaintext);
+        delete job;
 
         Q_ASSERT(!result.isNull());
         Q_ASSERT(!result.error());
@@ -215,14 +221,49 @@ private Q_SLOTS:
         std::vector<GpgME::Key> keys;
         GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
                                                 true, keys);
+        delete job;
         Q_ASSERT(!keys.empty());
         Key key = keys[0];
         Q_ASSERT(!key.isNull());
 
-        signAndVerify(QStringLiteral("Hello"), key, 1);
-        signAndVerify(QStringLiteral("Hello2"), key, 2);
-        signAndVerify(QStringLiteral("Hello3"), key, 3);
-        signAndVerify(QStringLiteral("Hello4"), key, 4);
+        signAndVerify(QStringLiteral("Hello"), key, -1);
+        signAndVerify(QStringLiteral("Hello2"), key, -1);
+        signAndVerify(QStringLiteral("Hello3"), key, -1);
+        signAndVerify(QStringLiteral("Hello4"), key, -1);
+    }
+
+    void testTofuKeyList()
+    {
+        if (!testSupported()) {
+            return;
+        }
+
+        /* First check that the key has no tofu info. */
+        auto *job = openpgp()->keyListJob(false, false, false);
+        std::vector<GpgME::Key> keys;
+        auto result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
+                                                 true, keys);
+        delete job;
+        Q_ASSERT(!keys.empty());
+        auto key = keys[0];
+        Q_ASSERT(!key.isNull());
+        Q_ASSERT(key.userID(0).tofuInfo().isNull());
+        signAndVerify(QStringLiteral("Hello"), key, -1);
+        signAndVerify(QStringLiteral("Hello"), key, -1);
+
+        /* Now another one but with tofu */
+        job = openpgp()->keyListJob(false, false, false);
+        job->addMode(GpgME::WithTofu);
+        result = job->exec(QStringList() << QStringLiteral("zulu at example.net"),
+                           true, keys);
+        delete job;
+        Q_ASSERT(!result.error());
+        Q_ASSERT(!keys.empty());
+        auto key2 = keys[0];
+        Q_ASSERT(!key2.isNull());
+        auto info = key2.userID(0).tofuInfo();
+        Q_ASSERT(!info.isNull());
+        Q_ASSERT(info.signCount());
     }
 
     void 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