summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-02-28 13:59:05 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-02-28 18:44:33 +0100
commitff49a550df626a4b02869b86f1ca9b9a5a421e44 (patch)
tree17e4a59a0c5b95dd5ed494ce95e8b0ceb32cfbf9 /unotest
parent0694a66e8e5ad3c83f28a093add009ecc37d500b (diff)
Fix the tests failing when invalid certificate is in cert store
Change-Id: I72055c814a11a76c4934610bcad9c24aae21164e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130690 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'unotest')
-rw-r--r--unotest/Library_unotest.mk1
-rw-r--r--unotest/source/cpp/macros_test.cxx14
2 files changed, 15 insertions, 0 deletions
diff --git a/unotest/Library_unotest.mk b/unotest/Library_unotest.mk
index 3acfe2f69ed9..1a7f8ba5ab5f 100644
--- a/unotest/Library_unotest.mk
+++ b/unotest/Library_unotest.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_Library_use_libraries,unotest,\
cppuhelper \
sal \
sb \
+ tl \
utl \
))
diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx
index 718c0b1b8954..81738dc6dafe 100644
--- a/unotest/source/cpp/macros_test.cxx
+++ b/unotest/source/cpp/macros_test.cxx
@@ -15,6 +15,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+#include <com/sun/star/security/XCertificate.hpp>
#include <basic/basrdll.hxx>
#include <cppunit/TestAssert.h>
@@ -24,6 +25,7 @@
#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/thread.h>
+#include <tools/datetime.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -169,6 +171,18 @@ void MacrosTest::tearDownNssGpg()
(void)this;
#endif
}
+
+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())
+ return *it;
+ return {};
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */