xmlsecurity/qa/unit/signing/signing.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 640e1aa6df86cfe61f638b3988fe8cc8a25ce1e5
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Aug 15 15:55:44 2024 +0500
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Aug 20 13:02:15 2024 +0200

    Fix the test failing when invalid certificate is in cert store
    
    testPDFAddVisibleSignature was failing for me locally because of
    an expired certificate present in my store.
    
    Change-Id: I03243f6707b1b5ca94ea87e9f8c809dd47b6a93a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171901
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 2ca75d4133e2388b67d09a9d88969cd20dc68f26)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172078
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/xmlsecurity/qa/unit/signing/signing.cxx 
b/xmlsecurity/qa/unit/signing/signing.cxx
index 5c91c17ffb1c..f8797f4f4e70 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -749,23 +749,23 @@ CPPUNIT_TEST_FIXTURE(SigningTest, 
testPDFAddVisibleSignature)
     uno::Reference<view::XSelectionSupplier> 
xSelectionSupplier(pBaseModel->getCurrentController(),
                                                                 
uno::UNO_QUERY);
     xSelectionSupplier->select(uno::Any(xShape));
-    uno::Sequence<uno::Reference<security::XCertificate>> aCertificates
-        = 
mxSecurityContext->getSecurityEnvironment()->getPersonalCertificates();
-    if (!aCertificates.hasElements())
+    auto xEnv = mxSecurityContext->getSecurityEnvironment();
+    auto xCert = GetValidCertificate(xEnv->getPersonalCertificates(), xEnv);
+    if (!xCert)
     {
         return;
     }
     SfxViewShell* pCurrent = SfxViewShell::Current();
     CPPUNIT_ASSERT(pCurrent);
     SdrView* pView = pCurrent->GetDrawView();
-    svx::SignatureLineHelper::setShapeCertificate(pView, aCertificates[0]);
+    svx::SignatureLineHelper::setShapeCertificate(pView, xCert);
 
     // the document is modified now, but Sign function can't show SaveAs dialog
     // in unit test, so just clear the modified
     pObjectShell->SetModified(false);
 
     // When: do the actual signing.
-    pObjectShell->SignDocumentContentUsingCertificate(aCertificates[0]);
+    pObjectShell->SignDocumentContentUsingCertificate(xCert);
 
     // Then: count the # of shapes on the signature widget/annotation.
     std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();

Reply via email to