summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/unotest/macros_test.hxx1
-rw-r--r--unotest/source/cpp/macros_test.cxx12
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx2
3 files changed, 9 insertions, 6 deletions
diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx
index c6c810ad108b..6a476cf0ec40 100644
--- a/include/unotest/macros_test.hxx
+++ b/include/unotest/macros_test.hxx
@@ -93,6 +93,7 @@ public:
void setUpNssGpg(const test::Directories& rDirectories, const OUString& rTestName);
void tearDownNssGpg();
+ static bool IsValid(const css::uno::Reference<css::security::XCertificate>& cert);
static css::uno::Reference<css::security::XCertificate> GetValidCertificate(
const css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>& certs);
diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx
index 81738dc6dafe..f30cbcdac3ea 100644
--- a/unotest/source/cpp/macros_test.cxx
+++ b/unotest/source/cpp/macros_test.cxx
@@ -172,14 +172,16 @@ void MacrosTest::tearDownNssGpg()
#endif
}
+bool MacrosTest::IsValid(const css::uno::Reference<css::security::XCertificate>& cert)
+{
+ return DateTime(DateTime::SYSTEM)
+ .IsBetween(cert->getNotValidBefore(), cert->getNotValidAfter());
+}
+
css::uno::Reference<css::security::XCertificate> MacrosTest::GetValidCertificate(
const css::uno::Sequence<css::uno::Reference<css::security::XCertificate>>& certs)
{
- auto it
- = std::find_if(certs.begin(), certs.end(), [now = DateTime(DateTime::SYSTEM)](auto& xCert) {
- return now.IsBetween(xCert->getNotValidBefore(), xCert->getNotValidAfter());
- });
- if (it != certs.end())
+ if (auto it = std::find_if(certs.begin(), certs.end(), IsValid); it != certs.end())
return *it;
return {};
}
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 38643a0b3098..90d0edf8973e 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -159,7 +159,7 @@ SigningTest::getCertificate(DocumentSignatureManager& rSignatureManager,
{
auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCertificate.get());
CPPUNIT_ASSERT(pCertificate);
- if (pCertificate->getSignatureMethodAlgorithm() == eAlgo)
+ if (pCertificate->getSignatureMethodAlgorithm() == eAlgo && IsValid(xCertificate))
return xCertificate;
}
return uno::Reference<security::XCertificate>();