xmlsecurity: add unit test with docx that can only be opened with repair
Change-Id: I4f705dd2124383a90b69d04d8b2de0e37f83a495 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170053 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
@@ -26,6 +26,7 @@ $(eval $(call gb_CppunitTest_use_libraries,xmlsecurity_signing, \
|
||||
subsequenttest \
|
||||
test \
|
||||
tl \
|
||||
ucbhelper \
|
||||
unotest \
|
||||
utl \
|
||||
vcl \
|
||||
|
BIN
xmlsecurity/qa/unit/signing/data/signature-forgery-cdh-lfh.docx
Normal file
BIN
xmlsecurity/qa/unit/signing/data/signature-forgery-cdh-lfh.docx
Normal file
Binary file not shown.
@@ -20,6 +20,7 @@
|
||||
#include <test/unoapixml_test.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/document/BrokenPackageRequest.hpp>
|
||||
#include <com/sun/star/embed/XStorage.hpp>
|
||||
#include <com/sun/star/embed/XTransactedObject.hpp>
|
||||
#include <com/sun/star/security/CertificateValidity.hpp>
|
||||
@@ -46,6 +47,7 @@
|
||||
#include <biginteger.hxx>
|
||||
#include <certificate.hxx>
|
||||
#include <xsecctl.hxx>
|
||||
#include <ucbhelper/interceptedinteraction.hxx>
|
||||
#include <sfx2/docfile.hxx>
|
||||
#include <sfx2/docfilt.hxx>
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
@@ -1243,6 +1245,31 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testODFUntrustedGoodGPG)
|
||||
SignatureState::NOTVALIDATED, nActual);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SigningTest, testInvalidZIP)
|
||||
{
|
||||
// set RepairPackage via interaction handler, same as soffice does
|
||||
// - if it's passed to load the behavior is different, oddly enough.
|
||||
std::vector<::ucbhelper::InterceptedInteraction::InterceptedRequest> interceptions{
|
||||
{ css::uno::Any(css::document::BrokenPackageRequest()),
|
||||
cppu::UnoType<css::task::XInteractionApprove>::get(), 0 },
|
||||
};
|
||||
::rtl::Reference<ucbhelper::InterceptedInteraction> pIH(new ucbhelper::InterceptedInteraction);
|
||||
pIH->setInterceptions(std::move(interceptions));
|
||||
|
||||
uno::Sequence<beans::PropertyValue> args = { comphelper::makePropertyValue(
|
||||
u"InteractionHandler"_ustr, uno::Reference<task::XInteractionHandler>(pIH)) };
|
||||
loadWithParams(createFileURL(u"signature-forgery-cdh-lfh.docx"), args);
|
||||
SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
|
||||
CPPUNIT_ASSERT(pBaseModel);
|
||||
SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
|
||||
CPPUNIT_ASSERT(pObjectShell);
|
||||
// the problem was that the document Zip structure is interpreted
|
||||
// misleadingly in RepairPackage case, but signature was still returned
|
||||
// as partially valid.
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<int>(SignatureState::BROKEN),
|
||||
static_cast<int>(pObjectShell->GetDocumentSignatureState()));
|
||||
}
|
||||
|
||||
/// Test a typical broken ODF signature where one stream is corrupted.
|
||||
CPPUNIT_TEST_FIXTURE(SigningTest, testODFBrokenStreamGPG)
|
||||
{
|
||||
|
Reference in New Issue
Block a user