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
This commit is contained in:
Andre Heinecke 2019-11-06 09:21:02 +01:00
parent 024edbbd3c
commit e7b5c6405d
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C
4 changed files with 41 additions and 21 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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"

View File

@ -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
{