aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2016-08-25 14:25:49 +0000
committerAndre Heinecke <[email protected]>2016-08-25 14:25:49 +0000
commit9fc72e928bf2cf239bd3b0facdf33ceb1acc975b (patch)
tree18ad2240b92b2da6528e6efb19a30dbe57894a55 /lang/qt
parentqt: Fix keyring copy in tests (diff)
downloadgpgme-9fc72e928bf2cf239bd3b0facdf33ceb1acc975b.tar.gz
gpgme-9fc72e928bf2cf239bd3b0facdf33ceb1acc975b.zip
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.
Diffstat (limited to 'lang/qt')
-rw-r--r--lang/qt/tests/t-tofuinfo.cpp61
1 files changed, 51 insertions, 10 deletions
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index d3061676..30f7bea9 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("[email protected]"),
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("[email protected]"),
+ 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("[email protected]"),
+ 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()