From 965b842fad6ec6fbd8902f3a32119abcd0728fe4 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 5 Sep 2016 12:58:35 +0200 Subject: [PATCH] qt: Enable signcount checks in tofuinfo test * lang/qt/tests/t-tofuinfo.cpp: Enable checks for signcount. -- Signcount for userIDs works now as expected with gnupg 2.1.16. --- lang/qt/tests/t-tofuinfo.cpp | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index 30f7bea9..f7238f37 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -89,13 +89,12 @@ class TofuInfoTest: public QGpgMETest auto sigResult = job->exec(keys, what.toUtf8(), NormalSignatureMode, signedData); delete job; - auto info = keys[0].userID(0).tofuInfo(); - if (expected != -1) { + Q_ASSERT(!sigResult.error()); + foreach (const auto uid, keys[0].userIDs()) { + auto info = uid.tofuInfo(); Q_ASSERT(info.signCount() == expected - 1); } - Q_ASSERT(!sigResult.error()); - auto verifyJob = openpgp()->verifyOpaqueJob(); QByteArray verified; @@ -114,9 +113,13 @@ class TofuInfoTest: public QGpgMETest Q_ASSERT(!strcmp (key.primaryFingerprint(), sig.fingerprint())); auto stats = key2.userID(0).tofuInfo(); Q_ASSERT(!stats.isNull()); - if (expected != -1) { - Q_ASSERT(stats.signCount() == expected); + if (stats.signCount() != expected) { + std::cout << "################ Key before verify: " + << key + << "################ Key after verify: " + << key2; } + Q_ASSERT(stats.signCount() == expected); } private Q_SLOTS: @@ -218,6 +221,7 @@ private Q_SLOTS: return; } auto *job = openpgp()->keyListJob(false, false, false); + job->addMode(GpgME::WithTofu); std::vector keys; GpgME::KeyListResult result = job->exec(QStringList() << QStringLiteral("zulu@example.net"), true, keys); @@ -226,10 +230,13 @@ private Q_SLOTS: Key key = keys[0]; Q_ASSERT(!key.isNull()); - signAndVerify(QStringLiteral("Hello"), key, -1); - signAndVerify(QStringLiteral("Hello2"), key, -1); - signAndVerify(QStringLiteral("Hello3"), key, -1); - signAndVerify(QStringLiteral("Hello4"), key, -1); + signAndVerify(QStringLiteral("Hello"), key, 1); + key.update(); + signAndVerify(QStringLiteral("Hello2"), key, 2); + key.update(); + signAndVerify(QStringLiteral("Hello3"), key, 3); + key.update(); + signAndVerify(QStringLiteral("Hello4"), key, 4); } void testTofuKeyList() @@ -248,8 +255,16 @@ private Q_SLOTS: 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); + auto keyCopy = key; + keyCopy.update(); + auto sigCnt = keyCopy.userID(0).tofuInfo().signCount(); + signAndVerify(QStringLiteral("Hello"), keyCopy, + sigCnt + 1); + keyCopy.update(); + /* For some reason if you remove the " World" part of + * the next message the test fails. */ + signAndVerify(QStringLiteral("Hello World"), keyCopy, + sigCnt + 2); /* Now another one but with tofu */ job = openpgp()->keyListJob(false, false, false);