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

Add a self-test checking de-vs compliance of GnuPG

GnuPG-bug-id: 5362
parent 83dbedef
......@@ -108,6 +108,7 @@ set(_kleopatra_SRCS
selftest/gpgconfcheck.cpp
selftest/gpgagentcheck.cpp
selftest/libkleopatrarccheck.cpp
selftest/compliancecheck.cpp
${_kleopatra_extra_SRCS}
......
......@@ -27,6 +27,7 @@
#endif
#include <selftest/gpgagentcheck.h>
#include <selftest/libkleopatrarccheck.h>
#include <selftest/compliancecheck.h>
#include <Libkleo/Stl_Util>
......@@ -133,6 +134,7 @@ private:
#ifndef Q_OS_WIN
tests.push_back(makeGpgAgentConnectivitySelfTest());
#endif
tests.push_back(makeDeVSComplianceCheckSelfTest());
tests.push_back(makeLibKleopatraRcSelfTest());
if (!dialog && std::none_of(tests.cbegin(), tests.cend(),
......
/* -*- mode: c++; c-basic-offset:4 -*-
selftest/compliancecheck.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "compliancecheck.h"
#include "implementation_p.h"
#include <Libkleo/Formatting>
#include <Libkleo/GnuPG>
#include <KLocalizedString>
using namespace Kleo;
using namespace Kleo::_detail;
namespace
{
class DeVsComplianceCheck : public SelfTestImplementation
{
public:
explicit DeVsComplianceCheck()
: SelfTestImplementation(i18nc("@title %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"%1?", Formatting::deVsString()))
{
runTest();
}
void runTest()
{
m_skipped = !gnupgUsesDeVsCompliance();
if (m_skipped) {
m_explanation =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para><application>GnuPG</application> is not configured for %1 communication.</para>", Formatting::deVsString());
return;
}
m_passed = gnupgIsDeVsCompliant();
if (m_passed) {
return;
}
m_error = Formatting::deVsString(m_passed);
m_explanation =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>The <application>GnuPG</application> system used by <application>Kleopatra</application> is not %1.</para>", Formatting::deVsString());
m_proposedFix =
xi18nc("@info %1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant",
"<para>Install a version of <application>GnuPG</application> that is %1.</para>", Formatting::deVsString());
}
};
}
std::shared_ptr<SelfTest> Kleo::makeDeVSComplianceCheckSelfTest()
{
return std::make_shared<DeVsComplianceCheck>();
}
/* -*- mode: c++; c-basic-offset:4 -*-
selftest/compliancecheck.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2021 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <selftest/selftest.h>
#include <memory>
namespace Kleo
{
class SelfTest;
std::shared_ptr<SelfTest> makeDeVSComplianceCheckSelfTest();
}
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