diff options
Diffstat (limited to 'lang/qt/tests')
-rw-r--r-- | lang/qt/tests/Makefile.am | 17 | ||||
-rw-r--r-- | lang/qt/tests/Makefile.in | 46 | ||||
-rw-r--r-- | lang/qt/tests/run-keyformailboxjob.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-config.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-encrypt.cpp | 34 | ||||
-rw-r--r-- | lang/qt/tests/t-keylist.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-keylocate.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-ownertrust.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-support.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-support.h | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-tofuinfo.cpp | 33 | ||||
-rw-r--r-- | lang/qt/tests/t-various.cpp | 16 | ||||
-rw-r--r-- | lang/qt/tests/t-verify.cpp | 3 | ||||
-rw-r--r-- | lang/qt/tests/t-wkspublish.cpp | 3 |
14 files changed, 106 insertions, 67 deletions
diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am index 93dce07..a662b4c 100644 --- a/lang/qt/tests/Makefile.am +++ b/lang/qt/tests/Makefile.am @@ -1,5 +1,6 @@ # Makefile.am - Makefile for GPGME Qt tests. -# Copyright (C) 2016 Intevation GmbH +# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik +# Software engineering by Intevation GmbH # # This file is part of GPGME. # @@ -43,12 +44,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \ -I$(top_srcdir)/lang/qt/src \ -DTOP_SRCDIR="$(top_srcdir)" -check-local: ./pubring-stamp - -# To guarantee that check-local is run before any tests we -# add this dependency: -initial.test : check-local - support_src = t-support.h t-support.cpp t_keylist_SOURCES = t-keylist.cpp $(support_src) @@ -64,7 +59,7 @@ run_keyformailboxjob_SOURCES = run-keyformailboxjob.cpp nodist_t_keylist_SOURCES = $(moc_files) -BUILT_SOURCES = $(moc_files) +BUILT_SOURCES = $(moc_files) pubring-stamp noinst_PROGRAMS = t-keylist t-keylocate t-ownertrust t-tofuinfo t-encrypt \ run-keyformailboxjob t-wkspublish t-verify t-various t-config @@ -75,12 +70,14 @@ CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \ gpg.conf tofu.db clean-local: + -$(top_srcdir)/tests/start-stop-agent --stop -rm -fR private-keys-v1.d crls.d export GNUPGHOME := $(abs_builddir) -./pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \ +pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \ $(top_srcdir)/tests/gpg/secdemo.asc + -gpgconf --kill all echo "ignore-invalid-option allow-loopback-pinentry" > $(abs_builddir)/gpg-agent.conf echo "allow-loopback-pinentry" >> gpg-agent.conf echo "ignore-invalid-option pinentry-mode" > gpg.conf @@ -90,7 +87,7 @@ export GNUPGHOME := $(abs_builddir) $(GPG) --no-permission-warning \ --passphrase "abc" \ --import $(top_srcdir)/tests/gpg/secdemo.asc - touch ./pubring-stamp + touch pubring-stamp .cpp.moc: $(MOC) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ diff --git a/lang/qt/tests/Makefile.in b/lang/qt/tests/Makefile.in index f370058..adf9bb1 100644 --- a/lang/qt/tests/Makefile.in +++ b/lang/qt/tests/Makefile.in @@ -15,7 +15,8 @@ @SET_MAKE@ # Makefile.am - Makefile for GPGME Qt tests. -# Copyright (C) 2016 Intevation GmbH +# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik +# Software engineering by Intevation GmbH # # This file is part of GPGME. # @@ -413,7 +414,6 @@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ -PYTHON_VERSIONS = @PYTHON_VERSIONS@ QTCHOOSER = @QTCHOOSER@ RANLIB = @RANLIB@ RC = @RC@ @@ -519,7 +519,7 @@ t_various_SOURCES = t-various.cpp $(support_src) t_config_SOURCES = t-config.cpp $(support_src) run_keyformailboxjob_SOURCES = run-keyformailboxjob.cpp nodist_t_keylist_SOURCES = $(moc_files) -BUILT_SOURCES = $(moc_files) +BUILT_SOURCES = $(moc_files) pubring-stamp CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \ gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \ random_seed S.gpg-agent .gpg-v21-migrated pubring-stamp $(moc_files) \ @@ -831,7 +831,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) @@ -942,34 +942,30 @@ uninstall-am: .MAKE: all check check-am install install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am \ - check-local clean clean-generic clean-libtool clean-local \ - clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ + clean-generic clean-libtool clean-local clean-noinstPROGRAMS \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am -check-local: ./pubring-stamp - -# To guarantee that check-local is run before any tests we -# add this dependency: -initial.test : check-local - clean-local: + -$(top_srcdir)/tests/start-stop-agent --stop -rm -fR private-keys-v1.d crls.d export GNUPGHOME := $(abs_builddir) -./pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \ +pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \ $(top_srcdir)/tests/gpg/secdemo.asc + -gpgconf --kill all echo "ignore-invalid-option allow-loopback-pinentry" > $(abs_builddir)/gpg-agent.conf echo "allow-loopback-pinentry" >> gpg-agent.conf echo "ignore-invalid-option pinentry-mode" > gpg.conf @@ -979,7 +975,7 @@ export GNUPGHOME := $(abs_builddir) $(GPG) --no-permission-warning \ --passphrase "abc" \ --import $(top_srcdir)/tests/gpg/secdemo.asc - touch ./pubring-stamp + touch pubring-stamp .cpp.moc: $(MOC) `test -f '$<' || echo '$(srcdir)/'`$< -o $@ diff --git a/lang/qt/tests/run-keyformailboxjob.cpp b/lang/qt/tests/run-keyformailboxjob.cpp index 73bedbd..dc3f967 100644 --- a/lang/qt/tests/run-keyformailboxjob.cpp +++ b/lang/qt/tests/run-keyformailboxjob.cpp @@ -2,7 +2,8 @@ run-keyformailbox.cpp This file is part of QGpgME's test suite. - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, diff --git a/lang/qt/tests/t-config.cpp b/lang/qt/tests/t-config.cpp index 0a7df22..e04a6bb 100644 --- a/lang/qt/tests/t-config.cpp +++ b/lang/qt/tests/t-config.cpp @@ -1,7 +1,8 @@ /* t-config.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp index a2d8dc4..5bd472a 100644 --- a/lang/qt/tests/t-encrypt.cpp +++ b/lang/qt/tests/t-encrypt.cpp @@ -1,7 +1,8 @@ /* t-encrypt.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -41,10 +42,10 @@ #include "encryptjob.h" #include "signencryptjob.h" #include "signingresult.h" -#include "qgpgmeencryptjob.h" +#include "encryptjob.h" #include "encryptionresult.h" #include "decryptionresult.h" -#include "qgpgmedecryptjob.h" +#include "decryptjob.h" #include "qgpgmebackend.h" #include "keylistresult.h" #include "engineinfo.h" @@ -105,11 +106,11 @@ private Q_SLOTS: if (!decryptSupported()) { return; } - auto ctx = Context::createForProtocol(OpenPGP); + auto decJob = openpgp()->decryptJob(); + auto ctx = Job::context(decJob); TestPassphraseProvider provider; ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); - auto decJob = new QGpgMEDecryptJob(ctx); QByteArray plainText; auto decResult = decJob->exec(cipherText, plainText); QVERIFY(!decResult.error()); @@ -176,13 +177,13 @@ private Q_SLOTS: if (!decryptSupported()) { return; } - auto ctx = Context::createForProtocol(OpenPGP); + auto job = openpgp()->encryptJob(); + auto ctx = Job::context(job); TestPassphraseProvider provider; ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); ctx->setArmor(true); ctx->setTextMode(true); - auto job = new QGpgMEEncryptJob(ctx); QByteArray cipherText; auto result = job->exec(std::vector<Key>(), QStringLiteral("Hello symmetric World").toUtf8(), Context::AlwaysTrust, cipherText); delete job; @@ -192,10 +193,10 @@ private Q_SLOTS: killAgent(mDir.path()); - auto ctx2 = Context::createForProtocol(OpenPGP); + auto decJob = openpgp()->decryptJob(); + auto ctx2 = Job::context(decJob); ctx2->setPassphraseProvider(&provider); ctx2->setPinentryMode(Context::PinentryLoopback); - auto decJob = new QGpgMEDecryptJob(ctx2); QByteArray plainText; auto decResult = decJob->exec(cipherText, plainText); QVERIFY(!result.error()); @@ -203,8 +204,6 @@ private Q_SLOTS: delete decJob; } -private: - /* This apparently does not work under ASAN currently. TODO fix and reeanble */ void testEncryptDecryptNowrap() { /* Now decrypt */ @@ -239,13 +238,14 @@ private: if (!decryptSupported()) { return; } - auto ctx = Context::createForProtocol(OpenPGP); + + auto decJob = openpgp()->decryptJob(); + auto ctx = Job::context(decJob); TestPassphraseProvider provider; ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); ctx->setDecryptionFlags(Context::DecryptUnwrap); - auto decJob = new QGpgMEDecryptJob(ctx); QByteArray plainText; auto decResult = decJob->exec(cipherText, plainText); @@ -283,12 +283,12 @@ private: QVERIFY(keys.size() == 1); delete listjob; - auto ctx = Context::createForProtocol(OpenPGP); + auto job = openpgp()->encryptJob(); + auto ctx = Job::context(job); ctx->setPassphraseProvider(new TestPassphraseProvider); ctx->setPinentryMode(Context::PinentryLoopback); ctx->setArmor(true); ctx->setTextMode(true); - auto job = new QGpgMEEncryptJob(ctx); QByteArray cipherText; printf("Before exec, flags: %x\n", Context::Symmetric | Context::AlwaysTrust); auto result = job->exec(keys, QStringLiteral("Hello symmetric World").toUtf8(), @@ -311,11 +311,11 @@ private: agentConf.write("allow-loopback-pinentry"); agentConf.close(); - auto ctx2 = Context::createForProtocol(OpenPGP); + auto decJob = openpgp()->decryptJob(); + auto ctx2 = Job::context(decJob); ctx2->setPassphraseProvider(new TestPassphraseProvider); ctx2->setPinentryMode(Context::PinentryLoopback); ctx2->setTextMode(true); - auto decJob = new QGpgMEDecryptJob(ctx2); QByteArray plainText; auto decResult = decJob->exec(cipherText, plainText); QVERIFY(!decResult.error()); diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp index a140236..bf57ba7 100644 --- a/lang/qt/tests/t-keylist.cpp +++ b/lang/qt/tests/t-keylist.cpp @@ -1,7 +1,8 @@ /* t-keylist.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-keylocate.cpp b/lang/qt/tests/t-keylocate.cpp index 8c99c8b..6d00da3 100644 --- a/lang/qt/tests/t-keylocate.cpp +++ b/lang/qt/tests/t-keylocate.cpp @@ -1,7 +1,8 @@ /* t-keylocate.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-ownertrust.cpp b/lang/qt/tests/t-ownertrust.cpp index e9a4378..093c21e 100644 --- a/lang/qt/tests/t-ownertrust.cpp +++ b/lang/qt/tests/t-ownertrust.cpp @@ -1,7 +1,8 @@ /* t-ownertrust.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-support.cpp b/lang/qt/tests/t-support.cpp index b3a7a70..2444c70 100644 --- a/lang/qt/tests/t-support.cpp +++ b/lang/qt/tests/t-support.cpp @@ -1,7 +1,8 @@ /* t-support.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h index b03b05d..81775ca 100644 --- a/lang/qt/tests/t-support.h +++ b/lang/qt/tests/t-support.h @@ -1,7 +1,8 @@ /* t-support.h This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index e16b1fd..b716102 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -1,7 +1,8 @@ /* t-tofuinfo.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -47,10 +48,11 @@ #include "importresult.h" #include "keylistjob.h" #include "keylistresult.h" -#include "qgpgmesignjob.h" +#include "signjob.h" #include "key.h" #include "t-support.h" #include "engineinfo.h" +#include "context.h" #include <iostream> using namespace QGpgME; @@ -118,7 +120,24 @@ Q_SIGNALS: private: bool testSupported() { - return !(GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16"); + static bool initialized, supported; + if (initialized) { + return supported; + } + initialized = true; + if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.16") { + return false; + } + // If the keylist fails here this means that gnupg does not + // support tofu at all. It can be disabled at compile time. So no + // tests. + auto *job = openpgp()->keyListJob(false, false, false); + job->addMode(GpgME::WithTofu); + std::vector<GpgME::Key> keys; + job->exec(QStringList() << QStringLiteral("zulu@example.net"), true, keys); + delete job; + supported = !keys.empty(); + return supported; } void testTofuCopy(TofuInfo other, const TofuInfo &orig) @@ -133,11 +152,11 @@ private: void signAndVerify(const QString &what, const GpgME::Key &key, int expected) { - Context *ctx = Context::createForProtocol(OpenPGP); + auto job = openpgp()->signJob(); + auto ctx = Job::context(job); TestPassphraseProvider provider; ctx->setPassphraseProvider(&provider); ctx->setPinentryMode(Context::PinentryLoopback); - auto *job = new QGpgMESignJob(ctx); std::vector<Key> keys; keys.push_back(key); @@ -402,6 +421,10 @@ private Q_SLOTS: void testTofuConflict() { + if (!testSupported()) { + return; + } + if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.19") { return; } diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index 35d8da9..7545628 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -1,7 +1,8 @@ /* t-various.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2017 Intevation GmbH + Copyright (c) 2017 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -150,6 +151,19 @@ private Q_SLOTS: QVERIFY(id_revoked); } + void testVersion() + { + QVERIFY(EngineInfo::Version("2.1.0") < EngineInfo::Version("2.1.1")); + QVERIFY(EngineInfo::Version("2.1.10") < EngineInfo::Version("2.1.11")); + QVERIFY(EngineInfo::Version("2.2.0") > EngineInfo::Version("2.1.19")); + QVERIFY(EngineInfo::Version("1.0.0") < EngineInfo::Version("2.0.0")); + QVERIFY(EngineInfo::Version("0.1.0") < EngineInfo::Version("1.0.0")); + QVERIFY(!(EngineInfo::Version("2.0.0") < EngineInfo::Version("2.0.0"))); + QVERIFY(EngineInfo::Version("3.0.0") > EngineInfo::Version("2.3.20")); + QVERIFY(EngineInfo::Version("3.0.1") > EngineInfo::Version("3.0.0")); + QVERIFY(EngineInfo::Version("3.1.0") > EngineInfo::Version("3.0.20")); + } + void initTestCase() { QGpgMETest::initTestCase(); diff --git a/lang/qt/tests/t-verify.cpp b/lang/qt/tests/t-verify.cpp index 7caed28..e6b0c8a 100644 --- a/lang/qt/tests/t-verify.cpp +++ b/lang/qt/tests/t-verify.cpp @@ -1,7 +1,8 @@ /* t-verifiy.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff --git a/lang/qt/tests/t-wkspublish.cpp b/lang/qt/tests/t-wkspublish.cpp index c51e8f9..b389194 100644 --- a/lang/qt/tests/t-wkspublish.cpp +++ b/lang/qt/tests/t-wkspublish.cpp @@ -1,7 +1,8 @@ /* t-wkspublish.cpp This file is part of qgpgme, the Qt API binding for gpgme - Copyright (c) 2016 Intevation GmbH + Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik + Software engineering by Intevation GmbH QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as |