From 66c334650bd64fdb72c4bd5975e25b8659d320ec Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 22 Mar 2017 16:41:04 +0100 Subject: [PATCH] qt: Add test for Data::toKeys * lang/qt/tests/t-various.cpp (TestVarious::testKeyFromFile): New. --- lang/qt/tests/t-various.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index 2b51fe6e..35d8da9b 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -43,12 +43,28 @@ #include "context.h" #include "engineinfo.h" #include "dn.h" +#include "data.h" +#include "dataprovider.h" #include "t-support.h" using namespace QGpgME; using namespace GpgME; +static const char aKey[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +"\n" +"mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n" +"K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n" +"DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n" +"Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n" +"cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n" +"CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n" +"CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n" +"wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n" +"0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n" +"=p2Oj\n" +"-----END PGP PUBLIC KEY BLOCK-----\n"; + class TestVarious: public QGpgMETest { Q_OBJECT @@ -67,6 +83,20 @@ private Q_SLOTS: QVERIFY(dn.prettyDN() == QStringLiteral("DC=North America,DC=Fabrikam,DC=COM,OU=Test,CN=Before\rAfter")); } + void testKeyFromFile() + { + if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") { + return; + } + QGpgME::QByteArrayDataProvider dp(aKey); + Data data(&dp); + const auto keys = data.toKeys(); + QVERIFY(keys.size() == 1); + const auto key = keys[0]; + QVERIFY(!key.isNull()); + QVERIFY(key.primaryFingerprint() == QStringLiteral("7A0904B6950DA998020A1AD4BE41C0C3A5FF1F3C")); + } + void testQuickUid() { if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.13") {