CppunitTest_xmlsecurity_signing2: inherit from UnoApiXmlTest
for some reason, if xmlsecurity/qa/unit/signing/signing2.cxx is executed with CppunitTest_xmlsecurity_signing, it makes testPreserveMacroTemplateSignature10::TestBody to crash, which is weird. Split them in two Change-Id: If43085dac60f197205d70294ec22ddfc86990784 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143527 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
@@ -13,7 +13,6 @@ $(eval $(call gb_CppunitTest_CppunitTest,xmlsecurity_signing))
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_exception_objects,xmlsecurity_signing, \
|
||||
xmlsecurity/qa/unit/signing/signing \
|
||||
xmlsecurity/qa/unit/signing/signing2 \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_libraries,xmlsecurity_signing, \
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#*************************************************************************
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
$(eval $(call gb_CppunitTest_CppunitTest,xmlsecurity_signing2))
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_exception_objects,xmlsecurity_signing2, \
|
||||
xmlsecurity/qa/unit/signing/signing2 \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_libraries,xmlsecurity_signing2, \
|
||||
comphelper \
|
||||
cppuhelper \
|
||||
cppu \
|
||||
sal \
|
||||
sax \
|
||||
sfx \
|
||||
svx \
|
||||
subsequenttest \
|
||||
test \
|
||||
tl \
|
||||
unotest \
|
||||
utl \
|
||||
vcl \
|
||||
xmlsecurity \
|
||||
xsec_xmlsec \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_externals,xmlsecurity_signing2,\
|
||||
boost_headers \
|
||||
libxml2 \
|
||||
))
|
||||
|
||||
ifneq ($(OS),WNT)
|
||||
ifneq (,$(ENABLE_NSS))
|
||||
$(eval $(call gb_CppunitTest_use_externals,xmlsecurity_signing2,\
|
||||
nssutil3 \
|
||||
))
|
||||
endif
|
||||
endif
|
||||
|
||||
$(eval $(call gb_CppunitTest_set_include,xmlsecurity_signing2,\
|
||||
-I$(SRCDIR)/xmlsecurity/inc \
|
||||
$$(INCLUDE) \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_sdk_api,xmlsecurity_signing2))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_ure,xmlsecurity_signing2))
|
||||
$(eval $(call gb_CppunitTest_use_vcl,xmlsecurity_signing2))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_uiconfigs,xmlsecurity_signing2, \
|
||||
svt \
|
||||
))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_rdb,xmlsecurity_signing2,services))
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_configuration,xmlsecurity_signing2))
|
||||
|
||||
ifeq ($(ENABLE_POPPLER),TRUE)
|
||||
$(eval $(call gb_CppunitTest_use_executable,xmlsecurity_signing2,xpdfimport))
|
||||
endif
|
||||
|
||||
# various hacks to make unit test work on Linux more often
|
||||
ifeq ($(OS),LINUX)
|
||||
# reset the LD_LIBRARY_PATH for spawned GPG processes
|
||||
$(call gb_CppunitTest_get_target,xmlsecurity_signing2): \
|
||||
EXTRA_ENV_VARS += \
|
||||
LIBO_LD_PATH=$$LD_LIBRARY_PATH
|
||||
endif
|
||||
|
||||
$(eval $(call gb_CppunitTest_use_custom_headers,xmlsecurity_signing2,\
|
||||
officecfg/registry \
|
||||
))
|
||||
|
||||
ifeq ($(OS),WNT)
|
||||
# Initializing DocumentSignatureManager will require gpgme-w32spawn.exe in workdir/LinkTarget/Executable
|
||||
$(eval $(call gb_CppunitTest_use_packages,xmlsecurity_signing2,\
|
||||
$(call gb_Helper_optional,GPGMEPP,gpgmepp)\
|
||||
))
|
||||
endif
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_arguments,xmlsecurity_signing2, \
|
||||
-env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
@@ -21,6 +21,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,xmlsecurity,\
|
||||
|
||||
$(eval $(call gb_Module_add_subsequentcheck_targets,xmlsecurity,\
|
||||
CppunitTest_xmlsecurity_signing \
|
||||
CppunitTest_xmlsecurity_signing2 \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Module_add_l10n_targets,xmlsecurity,\
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
|
||||
#include <sal/config.h>
|
||||
|
||||
#include <test/bootstrapfixture.hxx>
|
||||
#include <unotest/macros_test.hxx>
|
||||
#include <test/xmltesttools.hxx>
|
||||
#include <test/unoapixml_test.hxx>
|
||||
|
||||
#include <com/sun/star/embed/XStorage.hpp>
|
||||
#include <com/sun/star/frame/Desktop.hpp>
|
||||
@@ -29,78 +27,31 @@
|
||||
|
||||
using namespace css;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr OUStringLiteral DATA_DIRECTORY = u"/xmlsecurity/qa/unit/signing/data/";
|
||||
}
|
||||
|
||||
/// Testsuite for the document signing feature.
|
||||
class SigningTest2 : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
|
||||
class SigningTest2 : public UnoApiXmlTest
|
||||
{
|
||||
protected:
|
||||
uno::Reference<lang::XComponent> mxComponent;
|
||||
uno::Reference<xml::crypto::XSEInitializer> mxSEInitializer;
|
||||
uno::Reference<xml::crypto::XXMLSecurityContext> mxSecurityContext;
|
||||
|
||||
public:
|
||||
SigningTest2();
|
||||
virtual void setUp() override;
|
||||
virtual void tearDown() override;
|
||||
void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override;
|
||||
};
|
||||
|
||||
SigningTest2::SigningTest2() {}
|
||||
|
||||
void SigningTest2::setUp()
|
||||
SigningTest2::SigningTest2()
|
||||
: UnoApiXmlTest("/xmlsecurity/qa/unit/signing/data/")
|
||||
{
|
||||
test::BootstrapFixture::setUp();
|
||||
|
||||
// Initialize crypto after setting up the environment variables.
|
||||
mxDesktop.set(frame::Desktop::create(mxComponentContext));
|
||||
}
|
||||
|
||||
void SigningTest2::tearDown()
|
||||
{
|
||||
if (mxComponent.is())
|
||||
{
|
||||
css::uno::Reference<css::util::XCloseable> closer(mxComponent, css::uno::UNO_QUERY);
|
||||
if (closer.is())
|
||||
{
|
||||
closer->close(true);
|
||||
}
|
||||
mxComponent->dispose();
|
||||
}
|
||||
|
||||
test::BootstrapFixture::tearDown();
|
||||
}
|
||||
|
||||
/// Test if a macro signature from a ODF Database is preserved when saving
|
||||
CPPUNIT_TEST_FIXTURE(SigningTest2, testPreserveMacroSignatureODB)
|
||||
{
|
||||
const OUString aURL(m_directories.getURLFromSrc(DATA_DIRECTORY) + "odb_signed_macros.odb");
|
||||
|
||||
// load the file
|
||||
mxComponent = loadFromDesktop(aURL, "com.sun.star.sdb.OfficeDatabaseDocument");
|
||||
loadFromURL(u"odb_signed_macros.odb");
|
||||
|
||||
// save as ODB
|
||||
utl::TempFileNamed aTempFileSaveAsODB;
|
||||
aTempFileSaveAsODB.EnableKillingFile();
|
||||
try
|
||||
{
|
||||
uno::Reference<frame::XStorable> xDocStorable(mxComponent, uno::UNO_QUERY);
|
||||
uno::Sequence<beans::PropertyValue> descSaveAs(comphelper::InitPropertySequence(
|
||||
{ { "FilterName", uno::Any(OUString("StarOffice XML (Base)")) } }));
|
||||
xDocStorable->storeAsURL(aTempFileSaveAsODB.GetURL(), descSaveAs);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CPPUNIT_FAIL("Failed to save ODB file");
|
||||
}
|
||||
save("StarOffice XML (Base)");
|
||||
|
||||
// Parse the resulting XML.
|
||||
uno::Reference<embed::XStorage> xStorage
|
||||
= comphelper::OStorageHelper::GetStorageOfFormatFromURL(
|
||||
ZIP_STORAGE_FORMAT_STRING, aTempFileSaveAsODB.GetURL(), embed::ElementModes::READ);
|
||||
ZIP_STORAGE_FORMAT_STRING, maTempFile.GetURL(), embed::ElementModes::READ);
|
||||
CPPUNIT_ASSERT(xStorage.is());
|
||||
uno::Reference<embed::XStorage> xMetaInf
|
||||
= xStorage->openStorageElement("META-INF", embed::ElementModes::READ);
|
||||
@@ -124,4 +75,6 @@ void SigningTest2::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx)
|
||||
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xd"), BAD_CAST("http://uri.etsi.org/01903/v1.3.2#"));
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user