sw/qa/core/frmedt/frmedt.cxx            |    2 ++
 xmlsecurity/qa/unit/signing/signing.cxx |   10 +++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 2ca75d4133e2388b67d09a9d88969cd20dc68f26
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Aug 15 15:55:44 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Aug 15 16:24: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 <[email protected]>

diff --git a/xmlsecurity/qa/unit/signing/signing.cxx 
b/xmlsecurity/qa/unit/signing/signing.cxx
index 25da7b3eb334..038bf78ce193 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -747,23 +747,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();
commit 1faf46589626f7e21db4b421a9b5e804fb520630
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Aug 15 12:42:32 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Aug 15 16:24:01 2024 +0200

    Add asserts to a unit test
    
    It helped me to easily see which unit test failed, when working on
    another change, instead of seeing a segfault
    
    Change-Id: Id0345f508eac3c60265cd62b8aa20d895c3a1d01
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171897
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index 438094282c18..bf831fa5466a 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -57,7 +57,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testTextboxReanchor)
 
     // Anchor the shape of the textbox into its own textframe.
     SdrObject* pTextFrameObj = pDrawPage->GetObj(2);
+    CPPUNIT_ASSERT(pTextFrameObj);
     SwFrameFormat* pTextFrameFormat = FindFrameFormat(pTextFrameObj);
+    CPPUNIT_ASSERT(pTextFrameFormat);
     CPPUNIT_ASSERT_EQUAL(u"Frame2"_ustr, pTextFrameFormat->GetName());
     SwFrameFormat* pDrawShapeFormat = FindFrameFormat(pDrawShape);
     SwNodeOffset nOldAnchor = 
pDrawShapeFormat->GetAnchor().GetAnchorNode()->GetIndex();

Reply via email to