Commit 744e209a authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Fix testKey() helper

We need to look up the keys by the addr-spec of the full user ids

GnuPG-bug-id: 5283
parent 3581d779
...@@ -95,8 +95,9 @@ GpgME::Key createTestKey(const char *uid, GpgME::Protocol protocol = GpgME::Unkn ...@@ -95,8 +95,9 @@ GpgME::Key createTestKey(const char *uid, GpgME::Protocol protocol = GpgME::Unkn
return GpgME::Key(key, false); return GpgME::Key(key, false);
} }
auto testKey(const char *email, GpgME::Protocol protocol = GpgME::UnknownProtocol) auto testKey(const char *address, GpgME::Protocol protocol = GpgME::UnknownProtocol)
{ {
const auto email = GpgME::UserID::addrSpecFromString(address);
const auto keys = KeyCache::instance()->findByEMailAddress(email); const auto keys = KeyCache::instance()->findByEMailAddress(email);
for (const auto &key: keys) { for (const auto &key: keys) {
if (protocol == GpgME::UnknownProtocol || key.protocol() == protocol) { if (protocol == GpgME::UnknownProtocol || key.protocol() == protocol) {
...@@ -209,6 +210,15 @@ private Q_SLOTS: ...@@ -209,6 +210,15 @@ private Q_SLOTS:
mKeyCache.reset(); mKeyCache.reset();
} }
void test__verify_test_keys()
{
QVERIFY(!testKey("sender@example.net", GpgME::OpenPGP).isNull());
QVERIFY(!testKey("sender@example.net", GpgME::CMS).isNull());
QVERIFY(!testKey("Full Trust <prefer-openpgp@example.net>", GpgME::OpenPGP).isNull());
QVERIFY(!testKey("Trusted S/MIME <prefer-smime@example.net>", GpgME::CMS).isNull());
QVERIFY(!testKey("Marginal Validity <marginal-openpgp@example.net>", GpgME::OpenPGP).isNull());
}
void test__both_protocols_allowed__mixed_not_allowed__openpgp_preferred() void test__both_protocols_allowed__mixed_not_allowed__openpgp_preferred()
{ {
const GpgME::Protocol forcedProtocol = GpgME::UnknownProtocol; const GpgME::Protocol forcedProtocol = GpgME::UnknownProtocol;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment