diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp index bf57ba75..21349c1c 100644 --- a/lang/qt/tests/t-keylist.cpp +++ b/lang/qt/tests/t-keylist.cpp @@ -42,6 +42,10 @@ #include "qgpgmebackend.h" #include "keylistresult.h" +#include "context.h" + +#include + #include "t-support.h" using namespace QGpgME; @@ -72,6 +76,35 @@ private Q_SLOTS: QVERIFY (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E); } + // This test can help with valgrind to check for memleaks when handling + // keys + void testGetKey() + { + GpgME::Key key; + { + auto ctx = std::unique_ptr (GpgME::Context::createForProtocol(GpgME::OpenPGP)); + ctx->setKeyListMode (GpgME::KeyListMode::Local | + GpgME::KeyListMode::Signatures | + GpgME::KeyListMode::Validate | + GpgME::KeyListMode::WithTofu); + GpgME::Error err; + key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); + } + QVERIFY(key.primaryFingerprint()); + QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); + { + auto ctx = std::unique_ptr (GpgME::Context::createForProtocol(GpgME::OpenPGP)); + ctx->setKeyListMode (GpgME::KeyListMode::Local | + GpgME::KeyListMode::Signatures | + GpgME::KeyListMode::Validate | + GpgME::KeyListMode::WithTofu); + GpgME::Error err; + key = ctx->key ("A0FF4590BB6122EDEF6E3C542D727CC768697734", err, false); + } + QVERIFY(key.primaryFingerprint()); + QVERIFY(!strcmp(key.primaryFingerprint(), "A0FF4590BB6122EDEF6E3C542D727CC768697734")); + } + void testPubkeyAlgoAsString() { static const QMap expected {