/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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/.
*/
void MacrosTest::setUpX509(const test::Directories& rDirectories, const OUString& rTestName)
{ staticbool isDone{ false }; if (isDone) // must only be done once on MacOSX - see below!
{ return;
}
isDone = true;
#ifdef _WIN32 // CryptoAPI test certificates
osl::File::copy(aSourceDir + "test.p7b", aTargetDir + "/test.p7b");
OUString caVar("LIBO_TEST_CRYPTOAPI_PKCS7");
osl_setEnvironment(caVar.pData, aTargetPath.pData); #else // Set up NSS database in workdir/CppunitTest/ // WARNING: on MacOSX, this *must only be done once* - once NSS has opened // the files, SQLite will *stop using them* if they are overwritten or renamed!
osl::File::copy(aSourceDir + "cert9.db", aTargetDir + "/cert9.db");
osl::File::copy(aSourceDir + "key4.db", aTargetDir + "/key4.db");
osl::File::copy(aSourceDir + "pkcs11.txt", aTargetDir + "/pkcs11.txt");
OUString mozCertVar(u"MOZILLA_CERTIFICATE_FOLDER"_ustr); // explicit prefix with "sql:" needed for CentOS7 system NSS 3.67
osl_setEnvironment(mozCertVar.pData, OUString("sql:" + aTargetPath).pData); #endif
}
#if HAVE_GPGCONF_SOCKETDIR // mutable global should be tolerable in test lib static OString g_gpgconfCommandPrefix; #endif
// note: this doesn't work for UITest because "os.environ" is a copy :(
OUString gpgHomeVar(u"GNUPGHOME"_ustr);
osl_setEnvironment(gpgHomeVar.pData, aTargetPath.pData);
#if HAVE_GPGCONF_SOCKETDIR autoconst ldPath = std::getenv("LIBO_LD_PATH");
g_gpgconfCommandPrefix
= ldPath == nullptr ? OString() : OString::Concat("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 if (!ok)
{
SAL_WARN("test", "converting path failed, aborting: " << aTargetPath);
abort();
}
g_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 = g_gpgconfCommandPrefix + " --create-socketdir"; int res = std::system(cmd.getStr()); if (res != 0)
{
SAL_WARN("test", "invoking gpgconf failed, aborting: " << cmd);
abort();
} #else
(void)rTargetDir; #endif
}
SAL_DLLPUBLIC_EXPORT void test_deinit_gpg()
{ #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:
CPPUNIT_ASSERT(!g_gpgconfCommandPrefix.isEmpty());
OString cmd = g_gpgconfCommandPrefix + " --remove-socketdir"; int res = std::system(cmd.getStr());
CPPUNIT_ASSERT_EQUAL_MESSAGE(cmd.getStr(), 0, res);
g_gpgconfCommandPrefix.clear(); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.