summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-03-01 11:50:29 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-03-01 15:17:55 +0100
commit9888bb3dbb7ca558e0b440314bdb24bc60843bb0 (patch)
treea903a99f3e87084baf8082daa11c46163b21cdb5 /unotest
parentc8ce8980b35edf394d72848fa777de49c37513e1 (diff)
Fix the test failing when invalid certificate is in cert store
testSigningMultipleTimes_ODT was failing for me locally because of an expired certificate present in my store. Change-Id: Ie3dfb9ee1a110259ba747a03fc28c205df2eea91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130743 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/cpp/macros_test.cxx12
1 files changed, 7 insertions, 5 deletions
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 {};
}