diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-19 17:56:54 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-29 09:10:45 +0200 |
commit | bd9bb7c4f1d64404743d42b813fe59fff5ec9abd (patch) | |
tree | 818f10606bf1450aa8d2bc3896a39885bf943393 /xmlsecurity | |
parent | 5b7b7731a2d1941d39cd10c0b12dab427d2cea07 (diff) |
Move data for signing tests to test/
This was duplicated under xmlsecurity and made it hard to have test code
outside xmlsecurity, even if the core of the pdf signing is nowadays
under svl/.
(cherry picked from commit 81c0b6410ae7a604a97994c7f31113f24665167f)
Conflicts:
include/unotest/macros_test.hxx
unotest/source/cpp/macros_test.cxx
xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
Change-Id: If5ce8269bb72f503263727d8255fe856742dfa60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97253
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/qa/unit/pdfsigning/data/cert8.db | bin | 65536 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/pdfsigning/data/key3.db | bin | 16384 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx | 22 | ||||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/cert8.db | bin | 65536 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/key3.db | bin | 16384 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/pubring.gpg | bin | 3060 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/random_seed | 2 | ||||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/secring.gpg | bin | 3832 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/data/trustdb.gpg | bin | 1360 -> 0 bytes | |||
-rw-r--r-- | xmlsecurity/qa/unit/signing/signing.cxx | 56 |
10 files changed, 12 insertions, 68 deletions
diff --git a/xmlsecurity/qa/unit/pdfsigning/data/cert8.db b/xmlsecurity/qa/unit/pdfsigning/data/cert8.db Binary files differdeleted file mode 100644 index 8354fd309e3a..000000000000 --- a/xmlsecurity/qa/unit/pdfsigning/data/cert8.db +++ /dev/null diff --git a/xmlsecurity/qa/unit/pdfsigning/data/key3.db b/xmlsecurity/qa/unit/pdfsigning/data/key3.db Binary files differdeleted file mode 100644 index 8ab32c28d584..000000000000 --- a/xmlsecurity/qa/unit/pdfsigning/data/key3.db +++ /dev/null diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx index 97e0b7d28f97..dc037f47b33f 100644 --- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx +++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx @@ -14,6 +14,7 @@ #include <osl/file.hxx> #include <sal/log.hxx> #include <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> #include <tools/datetime.hxx> #include <unotools/streamwrap.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -36,7 +37,7 @@ char const DATA_DIRECTORY[] = "/xmlsecurity/qa/unit/pdfsigning/data/"; } /// Testsuite for the PDF signing feature. -class PDFSigningTest : public test::BootstrapFixture +class PDFSigningTest : public test::BootstrapFixture, public unotest::MacrosTest { protected: uno::Reference<uno::XComponentContext> mxComponentContext; @@ -56,6 +57,7 @@ protected: public: PDFSigningTest(); void setUp() override; + void tearDown() override; }; PDFSigningTest::PDFSigningTest() {} @@ -66,17 +68,13 @@ void PDFSigningTest::setUp() mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); -#ifndef _WIN32 - // Set up cert8.db and key3.db in workdir/CppunitTest/ - OUString aSourceDir = m_directories.getURLFromSrc(DATA_DIRECTORY); - OUString aTargetDir - = m_directories.getURLFromWorkdir("/CppunitTest/xmlsecurity_pdfsigning.test.user/"); - osl::File::copy(aSourceDir + "cert8.db", aTargetDir + "cert8.db"); - osl::File::copy(aSourceDir + "key3.db", aTargetDir + "key3.db"); - OUString aTargetPath; - osl::FileBase::getSystemPathFromFileURL(aTargetDir, aTargetPath); - setenv("MOZILLA_CERTIFICATE_FOLDER", aTargetPath.toUtf8().getStr(), 1); -#endif + MacrosTest::setUpNssGpg(m_directories, "xmlsecurity_pdfsigning"); +} + +void PDFSigningTest::tearDown() +{ + MacrosTest::tearDownNssGpg(); + test::BootstrapFixture::tearDown(); } std::vector<SignatureInformation> PDFSigningTest::verify(const OUString& rURL, size_t nCount, diff --git a/xmlsecurity/qa/unit/signing/data/cert8.db b/xmlsecurity/qa/unit/signing/data/cert8.db Binary files differdeleted file mode 100644 index 95e58ffe5b92..000000000000 --- a/xmlsecurity/qa/unit/signing/data/cert8.db +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/data/key3.db b/xmlsecurity/qa/unit/signing/data/key3.db Binary files differdeleted file mode 100644 index f449e60a667f..000000000000 --- a/xmlsecurity/qa/unit/signing/data/key3.db +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/data/pubring.gpg b/xmlsecurity/qa/unit/signing/data/pubring.gpg Binary files differdeleted file mode 100644 index 007ea98afd55..000000000000 --- a/xmlsecurity/qa/unit/signing/data/pubring.gpg +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/data/random_seed b/xmlsecurity/qa/unit/signing/data/random_seed deleted file mode 100644 index 8e68109a880e..000000000000 --- a/xmlsecurity/qa/unit/signing/data/random_seed +++ /dev/null @@ -1,2 +0,0 @@ -,A? pj`\GkVfeT*;^hF֙3}isAr9BhoWF! !7(;9x*LzY8=#63Y&](^4nZ?l.؋}ֵ]5w6!?l'%k.^,IfVV'_R!QUiDUZ" Z$R^Mf)_~wo6c3/ C*E;BzQ"MֶQC-'ݕy$_
ӛϟ!^s2zhtLN;\ū0m冑G9M_'m(KH|zU;0Az|8X=aHX>c4&6k/TCýs_O`%M{UD {;[cV9]!f@(p^[hysTotf("(qNcr ӽaܟ
ۛ*?>YC6œa%']i=glR -/R?u7[F(
\ No newline at end of file diff --git a/xmlsecurity/qa/unit/signing/data/secring.gpg b/xmlsecurity/qa/unit/signing/data/secring.gpg Binary files differdeleted file mode 100644 index f7626df5aee3..000000000000 --- a/xmlsecurity/qa/unit/signing/data/secring.gpg +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/data/trustdb.gpg b/xmlsecurity/qa/unit/signing/data/trustdb.gpg Binary files differdeleted file mode 100644 index 1966b5374cfb..000000000000 --- a/xmlsecurity/qa/unit/signing/data/trustdb.gpg +++ /dev/null diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index 04eb91e8822b..8c124a18fc23 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -80,10 +80,6 @@ protected: uno::Reference<xml::crypto::XSEInitializer> mxSEInitializer; uno::Reference<xml::crypto::XXMLSecurityContext> mxSecurityContext; -#if HAVE_GPGCONF_SOCKETDIR - OString m_gpgconfCommandPrefix; -#endif - public: SigningTest(); virtual void setUp() override; @@ -108,48 +104,7 @@ SigningTest::SigningTest() {} void SigningTest::setUp() { test::BootstrapFixture::setUp(); - - OUString aSourceDir = m_directories.getURLFromSrc(DATA_DIRECTORY); - OUString aTargetDir - = m_directories.getURLFromWorkdir("CppunitTest/xmlsecurity_signing.test.user"); - - // Set up cert8.db in workdir/CppunitTest/ - osl::File::copy(aSourceDir + "cert8.db", aTargetDir + "/cert8.db"); - osl::File::copy(aSourceDir + "key3.db", aTargetDir + "/key3.db"); - - // Make gpg use our own defined setup & keys - osl::File::copy(aSourceDir + "pubring.gpg", aTargetDir + "/pubring.gpg"); - osl::File::copy(aSourceDir + "random_seed", aTargetDir + "/random_seed"); - osl::File::copy(aSourceDir + "secring.gpg", aTargetDir + "/secring.gpg"); - osl::File::copy(aSourceDir + "trustdb.gpg", aTargetDir + "/trustdb.gpg"); - - OUString aTargetPath; - osl::FileBase::getSystemPathFromFileURL(aTargetDir, aTargetPath); - - OUString mozCertVar("MOZILLA_CERTIFICATE_FOLDER"); - osl_setEnvironment(mozCertVar.pData, aTargetPath.pData); - OUString gpgHomeVar("GNUPGHOME"); - osl_setEnvironment(gpgHomeVar.pData, aTargetPath.pData); - -#if HAVE_GPGCONF_SOCKETDIR - auto const ldPath = std::getenv("LIBO_LD_PATH"); - m_gpgconfCommandPrefix - = ldPath == nullptr ? OString() : OStringLiteral("LD_LIBRARY_PATH=") + ldPath + " "; - OString path; - bool ok = aTargetPath.convertToString(&path, osl_getThreadTextEncoding(), - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR - | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR); - // if conversion fails, at least provide a best-effort conversion in the message here, for - // context - CPPUNIT_ASSERT_MESSAGE(OUStringToOString(aTargetPath, RTL_TEXTENCODING_UTF8).getStr(), ok); - m_gpgconfCommandPrefix += "GNUPGHOME=" + path + " " GPGME_GPGCONF; - // HAVE_GPGCONF_SOCKETDIR is only defined in configure.ac for Linux for now, so (a) std::system - // behavior will conform to POSIX (and the relevant env var to set is named LD_LIBRARY_PATH), and - // (b) gpgconf --create-socketdir should return zero: - OString cmd = m_gpgconfCommandPrefix + " --create-socketdir"; - int res = std::system(cmd.getStr()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(cmd.getStr(), 0, res); -#endif + MacrosTest::setUpNssGpg(m_directories, "xmlsecurity_signing"); // Initialize crypto after setting up the environment variables. mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory())); @@ -163,14 +118,7 @@ void SigningTest::tearDown() if (mxComponent.is()) mxComponent->dispose(); -#if HAVE_GPGCONF_SOCKETDIR - // HAVE_GPGCONF_SOCKETDIR is only defined in configure.ac for Linux for now, so (a) std::system - // behavior will conform to POSIX, and (b) gpgconf --remove-socketdir should return zero: - OString cmd = m_gpgconfCommandPrefix + " --remove-socketdir"; - int res = std::system(cmd.getStr()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(cmd.getStr(), 0, res); -#endif - + MacrosTest::tearDownNssGpg(); test::BootstrapFixture::tearDown(); } |