summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@gnupg.org>2019-11-06 09:21:02 +0100
committerAndre Heinecke <aheinecke@gnupg.org>2019-11-06 09:21:02 +0100
commite7b5c6405da515101f62acce2837e6c0cc115b76 (patch)
tree5e6c416793ed3ef6a7af7496596b2088faa79b54
parent024edbbd3c0059654e13c1c6acf78456450469ab (diff)
downloadgpgme-e7b5c6405da515101f62acce2837e6c0cc115b76.tar.gz
qt, tests: Add check for supported versions
* lang/qt/tests/t-encrypt.cpp (decryptSupported): Moved to t-support as loopbackSupported. * lang/qt/tests/t-remarks.cpp: Check for loopbackSupported. * lang/qt/tests/t-support.cpp, lang/qt/tests/t-support.h (loopbackSupported): New. -- This ensures that the tests do not fail with GnuPG 2.0.x
-rw-r--r--lang/qt/tests/t-encrypt.cpp27
-rw-r--r--lang/qt/tests/t-remarks.cpp15
-rw-r--r--lang/qt/tests/t-support.cpp18
-rw-r--r--lang/qt/tests/t-support.h2
4 files changed, 41 insertions, 21 deletions
diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp
index f25da317..9ad10331 100644
--- a/lang/qt/tests/t-encrypt.cpp
+++ b/lang/qt/tests/t-encrypt.cpp
@@ -57,22 +57,7 @@
using namespace QGpgME;
using namespace GpgME;
-static bool decryptSupported()
-{
- /* With GnuPG 2.0.x (at least 2.0.26 by default on jessie)
- * the passphrase_cb does not work. So the test popped up
- * a pinentry. So tests requiring decryption don't work. */
- static auto version = GpgME::engineInfo(GpgME::GpgEngine).engineVersion();
- if (version < "2.0.0") {
- /* With 1.4 it just works */
- return true;
- }
- if (version < "2.1.0") {
- /* With 2.1 it works with loopback mode */
- return false;
- }
- return true;
-}
+
class EncryptionTest : public QGpgMETest
{
@@ -103,7 +88,7 @@ private Q_SLOTS:
QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
/* Now decrypt */
- if (!decryptSupported()) {
+ if (!loopbackSupported()) {
return;
}
auto decJob = openpgp()->decryptJob();
@@ -174,7 +159,7 @@ private Q_SLOTS:
void testSymmetricEncryptDecrypt()
{
- if (!decryptSupported()) {
+ if (!loopbackSupported()) {
return;
}
auto job = openpgp()->encryptJob();
@@ -207,7 +192,7 @@ private Q_SLOTS:
void testEncryptDecryptNowrap()
{
/* Now decrypt */
- if (!decryptSupported()) {
+ if (!loopbackSupported()) {
return;
}
auto listjob = openpgp()->keyListJob(false, false, false);
@@ -235,7 +220,7 @@ private Q_SLOTS:
QVERIFY(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
/* Now decrypt */
- if (!decryptSupported()) {
+ if (!loopbackSupported()) {
return;
}
@@ -272,7 +257,7 @@ private:
* So this test is disabled until gnupg(?) is fixed for this. */
void testMixedEncryptDecrypt()
{
- if (!decryptSupported()) {
+ if (!loopbackSupported()) {
return;
}
auto listjob = openpgp()->keyListJob(false, false, false);
diff --git a/lang/qt/tests/t-remarks.cpp b/lang/qt/tests/t-remarks.cpp
index f6227d15..c39c430b 100644
--- a/lang/qt/tests/t-remarks.cpp
+++ b/lang/qt/tests/t-remarks.cpp
@@ -62,6 +62,9 @@ public:
// case in the UI
void testRemarkOwnKey()
{
+ if (!loopbackSupported()) {
+ return;
+ }
// Get the signing key (alfa)
auto ctx = Context::create(OpenPGP);
QVERIFY (ctx);
@@ -109,6 +112,9 @@ private Q_SLOTS:
void testRemarkReplaceSingleUIDExportable()
{
+ if (!loopbackSupported()) {
+ return;
+ }
// Get the signing key (alfa)
auto ctx = Context::create(OpenPGP);
QVERIFY (ctx);
@@ -197,6 +203,9 @@ private Q_SLOTS:
void testMultipleRemarks()
{
+ if (!loopbackSupported()) {
+ return;
+ }
// Get the signing key1 (alfa)
auto ctx = Context::create(OpenPGP);
QVERIFY (ctx);
@@ -285,6 +294,9 @@ private Q_SLOTS:
void testRemarkReplaceSingleUID()
{
+ if (!loopbackSupported()) {
+ return;
+ }
// Get the signing key (alfa)
auto ctx = Context::create(OpenPGP);
QVERIFY (ctx);
@@ -372,6 +384,9 @@ private Q_SLOTS:
void testRemarkReplaceMultiUID()
{
+ if (!loopbackSupported()) {
+ return;
+ }
// Get the signing key (alfa)
auto ctx = Context::create(OpenPGP);
QVERIFY (ctx);
diff --git a/lang/qt/tests/t-support.cpp b/lang/qt/tests/t-support.cpp
index 2444c70f..7b16ccc3 100644
--- a/lang/qt/tests/t-support.cpp
+++ b/lang/qt/tests/t-support.cpp
@@ -44,6 +44,8 @@
#include <QObject>
#include <QDir>
+#include "engineinfo.h"
+
void QGpgMETest::initTestCase()
{
GpgME::initializeLibrary();
@@ -98,5 +100,21 @@ void killAgent(const QString& dir)
proc.waitForFinished();
}
+bool loopbackSupported()
+{
+ /* With GnuPG 2.0.x (at least 2.0.26 by default on jessie)
+ * the passphrase_cb does not work. So the test popped up
+ * a pinentry. So tests requiring decryption don't work. */
+ static auto version = GpgME::engineInfo(GpgME::GpgEngine).engineVersion();
+ if (version < "2.0.0") {
+ /* With 1.4 it just works */
+ return true;
+ }
+ if (version < "2.1.0") {
+ /* With 2.1 it works with loopback mode */
+ return false;
+ }
+ return true;
+}
#include "t-support.hmoc"
diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h
index 81775cad..77bef56d 100644
--- a/lang/qt/tests/t-support.h
+++ b/lang/qt/tests/t-support.h
@@ -53,6 +53,8 @@ public:
} // namespace GpgME
void killAgent(const QString &dir = qgetenv("GNUPGHOME"));
+/* Is the passphrase Provider / loopback Supported */
+bool loopbackSupported();
class QGpgMETest : public QObject
{