diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-19 17:56:54 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-19 22:32:16 +0200 |
commit | 81c0b6410ae7a604a97994c7f31113f24665167f (patch) | |
tree | 42f7a82f22a3d32765b91484c2f1d8013d71156f /xmlsecurity | |
parent | ed7ae218dd51ad80c03645b9c43b42d8b8e90400 (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/.
Change-Id: If5ce8269bb72f503263727d8255fe856742dfa60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96745
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
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 | 21 | ||||
-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, 11 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 7e61e7dc2c87..0936897d6b5d 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: /** @@ -54,6 +55,7 @@ protected: public: PDFSigningTest(); void setUp() override; + void tearDown() override; }; PDFSigningTest::PDFSigningTest() {} @@ -61,18 +63,13 @@ PDFSigningTest::PDFSigningTest() {} void PDFSigningTest::setUp() { test::BootstrapFixture::setUp(); + MacrosTest::setUpNssGpg(m_directories, "xmlsecurity_pdfsigning"); +} -#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 +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 4373a5a5bb26..0f03befea47d 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -78,10 +78,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; @@ -106,48 +102,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. mxDesktop.set(frame::Desktop::create(mxComponentContext)); @@ -160,14 +115,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(); } |