Commit 441ccde8 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Ignore null keys when checking for de-vs compliance

Previously, in mixed mode, if both protocols were enabled, null keys
were not ignored resulting in non-compliance. If only one protocol
was allowed/enabled, then null keys were ignored by the protocol check
(because null keys have UnknownProtocol).

GnuPG-bug-id: 5283
parent 02c7ddc3
Pipeline #59049 canceled with stage
......@@ -903,6 +903,37 @@ private Q_SLOTS:
QVERIFY(complianceLabel->text().contains(" not "));
}
void test__vs_de_compliance__null_keys_are_ignored()
{
const GpgME::Protocol forcedProtocol = GpgME::UnknownProtocol;
const bool allowMixed = true;
const QString sender = QStringLiteral("sender@example.net");
const KeyResolver::Solution preferredSolution = {
GpgME::UnknownProtocol,
{testKey("sender@example.net", GpgME::OpenPGP), testKey("sender@example.net", GpgME::CMS)},
{
{QStringLiteral("unknown@example.net"), {}},
{QStringLiteral("sender@example.net"), {testKey("sender@example.net", GpgME::OpenPGP), testKey("sender@example.net", GpgME::CMS)}}
}
};
const KeyResolver::Solution alternativeSolution = {};
Tests::FakeCryptoConfigStringValue fakeCompliance{"gpg", "compliance", QStringLiteral("de-vs")};
const auto dialog = std::make_unique<NewKeyApprovalDialog>(true,
true,
sender,
preferredSolution,
alternativeSolution,
allowMixed,
forcedProtocol);
dialog->show();
waitForKeySelectionCombosBeingInitialized(dialog.get());
const auto complianceLabel = dialog->findChild<QLabel *>("compliance label");
verifyWidgetVisibility(complianceLabel, IsVisible);
QVERIFY(!complianceLabel->text().contains(" not "));
}
private:
std::shared_ptr<const KeyCache> mKeyCache;
};
......
......@@ -820,10 +820,13 @@ public:
const Protocol protocol = currentProtocol();
for (const auto combo: qAsConst(mAllCombos)) {
const auto &key = combo->currentKey();
if (!combo->isVisible()) {
continue;
}
const auto key = combo->currentKey();
if (key.isNull()) {
continue;
}
if (protocol != UnknownProtocol && key.protocol() != protocol) {
continue;
}
......
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