summaryrefslogtreecommitdiff
path: root/lang/qt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lang/qt/tests')
-rw-r--r--lang/qt/tests/Makefile.am7
-rw-r--r--lang/qt/tests/Makefile.in23
-rw-r--r--lang/qt/tests/run-keyformailboxjob.cpp4
-rw-r--r--lang/qt/tests/t-encrypt.cpp36
-rw-r--r--lang/qt/tests/t-keylist.cpp4
-rw-r--r--lang/qt/tests/t-keylocate.cpp4
-rw-r--r--lang/qt/tests/t-ownertrust.cpp4
-rw-r--r--lang/qt/tests/t-support.cpp4
-rw-r--r--lang/qt/tests/t-support.h4
-rw-r--r--lang/qt/tests/t-tofuinfo.cpp4
-rw-r--r--lang/qt/tests/t-verify.cpp93
-rw-r--r--lang/qt/tests/t-wkspublish.cpp20
12 files changed, 186 insertions, 21 deletions
diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am
index f243a55..ad08ad4 100644
--- a/lang/qt/tests/Makefile.am
+++ b/lang/qt/tests/Makefile.am
@@ -25,10 +25,10 @@ TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir)
EXTRA_DIST = initial.test
TESTS = initial.test t-keylist t-keylocate t-ownertrust t-tofuinfo \
- t-encrypt t-wkspublish
+ t-encrypt t-verify
moc_files = t-keylist.moc t-keylocate.moc t-ownertrust.moc t-tofuinfo.moc \
- t-encrypt.moc t-support.hmoc t-wkspublish.moc
+ t-encrypt.moc t-support.hmoc t-wkspublish.moc t-verify.moc
AM_LDFLAGS = -no-install
@@ -56,6 +56,7 @@ t_ownertrust_SOURCES = t-ownertrust.cpp $(support_src)
t_tofuinfo_SOURCES = t-tofuinfo.cpp $(support_src)
t_encrypt_SOURCES = t-encrypt.cpp $(support_src)
t_wkspublish_SOURCES = t-wkspublish.cpp $(support_src)
+t_verify_SOURCES = t-verify.cpp $(support_src)
run_keyformailboxjob_SOURCES = run-keyformailboxjob.cpp
nodist_t_keylist_SOURCES = $(moc_files)
@@ -63,7 +64,7 @@ nodist_t_keylist_SOURCES = $(moc_files)
BUILT_SOURCES = $(moc_files)
noinst_PROGRAMS = t-keylist t-keylocate t-ownertrust t-tofuinfo t-encrypt \
- run-keyformailboxjob t-wkspublish
+ run-keyformailboxjob t-wkspublish t-verify
CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \
gpg-agent.conf pubring.kbx~ S.gpg-agent gpg.conf pubring.gpg~ \
diff --git a/lang/qt/tests/Makefile.in b/lang/qt/tests/Makefile.in
index 45d4c76..5149a08 100644
--- a/lang/qt/tests/Makefile.in
+++ b/lang/qt/tests/Makefile.in
@@ -98,10 +98,11 @@ build_triplet = @build@
host_triplet = @host@
TESTS = initial.test t-keylist$(EXEEXT) t-keylocate$(EXEEXT) \
t-ownertrust$(EXEEXT) t-tofuinfo$(EXEEXT) t-encrypt$(EXEEXT) \
- t-wkspublish$(EXEEXT)
+ t-verify$(EXEEXT)
noinst_PROGRAMS = t-keylist$(EXEEXT) t-keylocate$(EXEEXT) \
t-ownertrust$(EXEEXT) t-tofuinfo$(EXEEXT) t-encrypt$(EXEEXT) \
- run-keyformailboxjob$(EXEEXT) t-wkspublish$(EXEEXT)
+ run-keyformailboxjob$(EXEEXT) t-wkspublish$(EXEEXT) \
+ t-verify$(EXEEXT)
subdir = lang/qt/tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/build-aux/mkinstalldirs \
@@ -163,6 +164,11 @@ t_tofuinfo_OBJECTS = $(am_t_tofuinfo_OBJECTS)
t_tofuinfo_LDADD = $(LDADD)
t_tofuinfo_DEPENDENCIES = ../../cpp/src/libgpgmepp.la \
../src/libqgpgme.la ../../../src/libgpgme.la
+am_t_verify_OBJECTS = t-verify.$(OBJEXT) $(am__objects_1)
+t_verify_OBJECTS = $(am_t_verify_OBJECTS)
+t_verify_LDADD = $(LDADD)
+t_verify_DEPENDENCIES = ../../cpp/src/libgpgmepp.la \
+ ../src/libqgpgme.la ../../../src/libgpgme.la
am_t_wkspublish_OBJECTS = t-wkspublish.$(OBJEXT) $(am__objects_1)
t_wkspublish_OBJECTS = $(am_t_wkspublish_OBJECTS)
t_wkspublish_LDADD = $(LDADD)
@@ -223,11 +229,12 @@ am__v_CCLD_1 =
SOURCES = $(run_keyformailboxjob_SOURCES) $(t_encrypt_SOURCES) \
$(t_keylist_SOURCES) $(nodist_t_keylist_SOURCES) \
$(t_keylocate_SOURCES) $(t_ownertrust_SOURCES) \
- $(t_tofuinfo_SOURCES) $(t_wkspublish_SOURCES)
+ $(t_tofuinfo_SOURCES) $(t_verify_SOURCES) \
+ $(t_wkspublish_SOURCES)
DIST_SOURCES = $(run_keyformailboxjob_SOURCES) $(t_encrypt_SOURCES) \
$(t_keylist_SOURCES) $(t_keylocate_SOURCES) \
$(t_ownertrust_SOURCES) $(t_tofuinfo_SOURCES) \
- $(t_wkspublish_SOURCES)
+ $(t_verify_SOURCES) $(t_wkspublish_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -471,7 +478,7 @@ GPG = gpg
TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir)
EXTRA_DIST = initial.test
moc_files = t-keylist.moc t-keylocate.moc t-ownertrust.moc t-tofuinfo.moc \
- t-encrypt.moc t-support.hmoc t-wkspublish.moc
+ t-encrypt.moc t-support.hmoc t-wkspublish.moc t-verify.moc
AM_LDFLAGS = -no-install
LDADD = ../../cpp/src/libgpgmepp.la ../src/libqgpgme.la \
@@ -491,6 +498,7 @@ t_ownertrust_SOURCES = t-ownertrust.cpp $(support_src)
t_tofuinfo_SOURCES = t-tofuinfo.cpp $(support_src)
t_encrypt_SOURCES = t-encrypt.cpp $(support_src)
t_wkspublish_SOURCES = t-wkspublish.cpp $(support_src)
+t_verify_SOURCES = t-verify.cpp $(support_src)
run_keyformailboxjob_SOURCES = run-keyformailboxjob.cpp
nodist_t_keylist_SOURCES = $(moc_files)
BUILT_SOURCES = $(moc_files)
@@ -568,6 +576,10 @@ t-tofuinfo$(EXEEXT): $(t_tofuinfo_OBJECTS) $(t_tofuinfo_DEPENDENCIES) $(EXTRA_t_
@rm -f t-tofuinfo$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(t_tofuinfo_OBJECTS) $(t_tofuinfo_LDADD) $(LIBS)
+t-verify$(EXEEXT): $(t_verify_OBJECTS) $(t_verify_DEPENDENCIES) $(EXTRA_t_verify_DEPENDENCIES)
+ @rm -f t-verify$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(t_verify_OBJECTS) $(t_verify_LDADD) $(LIBS)
+
t-wkspublish$(EXEEXT): $(t_wkspublish_OBJECTS) $(t_wkspublish_DEPENDENCIES) $(EXTRA_t_wkspublish_DEPENDENCIES)
@rm -f t-wkspublish$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(t_wkspublish_OBJECTS) $(t_wkspublish_LDADD) $(LIBS)
@@ -585,6 +597,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-ownertrust.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-support.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-tofuinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-verify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-wkspublish.Po@am__quote@
.cpp.o:
diff --git a/lang/qt/tests/run-keyformailboxjob.cpp b/lang/qt/tests/run-keyformailboxjob.cpp
index 9ac7668..73bedbd 100644
--- a/lang/qt/tests/run-keyformailboxjob.cpp
+++ b/lang/qt/tests/run-keyformailboxjob.cpp
@@ -29,6 +29,10 @@
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include "keyformailboxjob.h"
#include "keylistjob.h"
#include "protocol.h"
diff --git a/lang/qt/tests/t-encrypt.cpp b/lang/qt/tests/t-encrypt.cpp
index 3d4cfa9..4d65dc7 100644
--- a/lang/qt/tests/t-encrypt.cpp
+++ b/lang/qt/tests/t-encrypt.cpp
@@ -28,6 +28,10 @@
you do not wish to do so, delete this exception statement from
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QTemporaryDir>
@@ -49,6 +53,23 @@
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
{
Q_OBJECT
@@ -78,6 +99,9 @@ private Q_SLOTS:
Q_ASSERT(cipherString.startsWith("-----BEGIN PGP MESSAGE-----"));
/* Now decrypt */
+ if (!decryptSupported()) {
+ return;
+ }
auto ctx = Context::createForProtocol(OpenPGP);
TestPassphraseProvider provider;
ctx->setPassphraseProvider(&provider);
@@ -113,7 +137,7 @@ private Q_SLOTS:
bool initSeen = false;
bool finishSeen = false;
- connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString& what, int current, int total) {
+ connect(job, &Job::progress, this, [this, &initSeen, &finishSeen] (const QString&, int current, int total) {
// We only check for progress 0 and max progress as the other progress
// lines depend on the system speed and are as such unreliable to test.
Q_ASSERT(total == PROGRESS_TEST_SIZE);
@@ -125,8 +149,8 @@ private Q_SLOTS:
}
Q_ASSERT(current >= 0 && current <= total);
});
- connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &result,
- const QByteArray &cipherText,
+ connect(job, &EncryptJob::result, this, [this, &initSeen, &finishSeen] (const GpgME::EncryptionResult &,
+ const QByteArray &,
const QString,
const GpgME::Error) {
Q_ASSERT(initSeen);
@@ -146,6 +170,9 @@ private Q_SLOTS:
void testSymmetricEncryptDecrypt()
{
+ if (!decryptSupported()) {
+ return;
+ }
auto ctx = Context::createForProtocol(OpenPGP);
TestPassphraseProvider provider;
ctx->setPassphraseProvider(&provider);
@@ -178,6 +205,9 @@ private:
* So this test is disabled until gnupg(?) is fixed for this. */
void testMixedEncryptDecrypt()
{
+ if (!decryptSupported()) {
+ return;
+ }
auto listjob = openpgp()->keyListJob(false, false, false);
std::vector<Key> keys;
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp
index 767c96b..2578576 100644
--- a/lang/qt/tests/t-keylist.cpp
+++ b/lang/qt/tests/t-keylist.cpp
@@ -29,6 +29,10 @@
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
diff --git a/lang/qt/tests/t-keylocate.cpp b/lang/qt/tests/t-keylocate.cpp
index e75f24d..63cb836 100644
--- a/lang/qt/tests/t-keylocate.cpp
+++ b/lang/qt/tests/t-keylocate.cpp
@@ -28,6 +28,10 @@
you do not wish to do so, delete this exception statement from
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
diff --git a/lang/qt/tests/t-ownertrust.cpp b/lang/qt/tests/t-ownertrust.cpp
index b9efffd..db863b2 100644
--- a/lang/qt/tests/t-ownertrust.cpp
+++ b/lang/qt/tests/t-ownertrust.cpp
@@ -29,6 +29,10 @@
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
diff --git a/lang/qt/tests/t-support.cpp b/lang/qt/tests/t-support.cpp
index 86372f7..857d0a3 100644
--- a/lang/qt/tests/t-support.cpp
+++ b/lang/qt/tests/t-support.cpp
@@ -29,6 +29,10 @@
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include "t-support.h"
#include <QTest>
diff --git a/lang/qt/tests/t-support.h b/lang/qt/tests/t-support.h
index 59d9a4d..704fab4 100644
--- a/lang/qt/tests/t-support.h
+++ b/lang/qt/tests/t-support.h
@@ -39,8 +39,8 @@ namespace GpgME
class TestPassphraseProvider : public PassphraseProvider
{
public:
- char *getPassphrase(const char *useridHint, const char *description,
- bool previousWasBad, bool &canceled) Q_DECL_OVERRIDE
+ char *getPassphrase(const char * /*useridHint*/, const char * /*description*/,
+ bool /*previousWasBad*/, bool &/*canceled*/) Q_DECL_OVERRIDE
{
return strdup("abc");
}
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index d76ff7b..2c87e4a 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -28,6 +28,10 @@
you do not wish to do so, delete this exception statement from
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QTemporaryDir>
diff --git a/lang/qt/tests/t-verify.cpp b/lang/qt/tests/t-verify.cpp
new file mode 100644
index 0000000..aedfc19
--- /dev/null
+++ b/lang/qt/tests/t-verify.cpp
@@ -0,0 +1,93 @@
+/* t-verifiy.cpp
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2016 Intevation GmbH
+
+ QGpgME is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ QGpgME is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <QDebug>
+#include <QTest>
+
+
+#include "protocol.h"
+
+#include "verifyopaquejob.h"
+#include "verificationresult.h"
+#include "key.h"
+#include "t-support.h"
+
+using namespace QGpgME;
+using namespace GpgME;
+
+static const char testMsg1[] =
+"-----BEGIN PGP MESSAGE-----\n"
+"\n"
+"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n"
+"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n"
+"y1kvP4y+8D5a11ang0udywsA\n"
+"=Crq6\n"
+"-----END PGP MESSAGE-----\n";
+
+
+class VerifyTest: public QGpgMETest
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+
+ /* Check that a signature always has a key. */
+ void testSignatureKey()
+ {
+ const QByteArray signedData(testMsg1);
+ auto verifyJob = openpgp()->verifyOpaqueJob(true);
+ QByteArray verified;
+
+ auto result = verifyJob->exec(signedData, verified);
+ Q_ASSERT(!result.error());
+ delete verifyJob;
+
+ Q_ASSERT(result.numSignatures() == 1);
+ auto sig = result.signatures()[0];
+
+ const auto key = sig.key(true, false);
+ Q_ASSERT(!key.isNull());
+
+ bool found = false;
+ for (const auto subkey: key.subkeys()) {
+ if (!strcmp (subkey.fingerprint(), sig.fingerprint())) {
+ found = true;
+ }
+ }
+ Q_ASSERT(found);
+ }
+};
+
+QTEST_MAIN(VerifyTest)
+#include "t-verify.moc"
diff --git a/lang/qt/tests/t-wkspublish.cpp b/lang/qt/tests/t-wkspublish.cpp
index 17d3447..326ecaa 100644
--- a/lang/qt/tests/t-wkspublish.cpp
+++ b/lang/qt/tests/t-wkspublish.cpp
@@ -28,6 +28,10 @@
you do not wish to do so, delete this exception statement from
your version.
*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
#include <QDebug>
#include <QTest>
#include <QSignalSpy>
@@ -122,7 +126,7 @@ private Q_SLOTS:
// First check if it is supported
auto job = openpgp()->wksPublishJob();
connect(job, &WKSPublishJob::result, this,
- [this] (Error err, QByteArray out, QByteArray errout, QString, Error) {
+ [this] (Error err, QByteArray, QByteArray, QString, Error) {
Q_ASSERT(err);
Q_EMIT asyncDone();
});
@@ -140,7 +144,7 @@ private:
// First check if it is supported
auto job = openpgp()->wksPublishJob();
connect(job, &WKSPublishJob::result, this,
- [this] (Error err, QByteArray out, QByteArray errout, QString, Error) {
+ [this] (Error err, QByteArray, QByteArray, QString, Error) {
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") {
std::cout << err;
Q_ASSERT(err);
@@ -161,7 +165,7 @@ private:
}
auto job = openpgp()->wksPublishJob();
connect(job, &WKSPublishJob::result, this,
- [this] (Error err, QByteArray out, QByteArray errout, QString, Error) {
+ [this] (Error err, QByteArray, QByteArray, QString, Error) {
Q_ASSERT(err);
Q_EMIT asyncDone();
});
@@ -193,7 +197,7 @@ private:
auto keygenjob = openpgp()->keyGenerationJob();
QByteArray fpr;
connect(keygenjob, &KeyGenerationJob::result, this,
- [this, &fpr](KeyGenerationResult result, QByteArray pubkeyData, QString, Error)
+ [this, &fpr](KeyGenerationResult result, QByteArray, QString, Error)
{
Q_ASSERT(!result.error());
fpr = QByteArray(result.fingerprint());
@@ -207,7 +211,7 @@ private:
/* Then try to create a request. */
auto job = openpgp()->wksPublishJob();
connect(job, &WKSPublishJob::result, this,
- [this] (Error err, QByteArray out, QByteArray errout, QString, Error) {
+ [this] (Error err, QByteArray out, QByteArray, QString, Error) {
Q_ASSERT(!err);
Q_EMIT asyncDone();
const QString outstr = QString(out);
@@ -222,7 +226,7 @@ private:
Q_ASSERT(spy.wait());
}
- void testWKSPublishRecieve() {
+ void testWKSPublishReceive() {
if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.0.16") {
/* Not supported */
return;
@@ -243,7 +247,7 @@ private:
/* Get a response. */
auto job = openpgp()->wksPublishJob();
connect(job, &WKSPublishJob::result, this,
- [this] (Error err, QByteArray out, QByteArray errout, QString, Error) {
+ [this] (Error err, QByteArray out, QByteArray, QString, Error) {
Q_ASSERT(!err);
Q_EMIT asyncDone();
const QString outstr = QString(out);
@@ -254,7 +258,7 @@ private:
Q_ASSERT(outstr.contains(
QStringLiteral("From: " TEST_ADDRESS)));
});
- job->startRecieve(QByteArray(testResponse));
+ job->startReceive(QByteArray(testResponse));
Q_ASSERT(spy.wait());
}