TARGET = tst_qsslkey
-win32 {
- CONFIG(debug, debug|release) {
- DESTDIR = debug
-} else {
- DESTDIR = release
- }
-}
-
-wince* {
- keyFiles.files = keys
- keyFiles.path = .
-
- passphraseFiles.files = rsa-without-passphrase.pem rsa-with-passphrase.pem
- passphraseFiles.path = .
-
- DEPLOYMENT += keyFiles passphraseFiles
- DEFINES += SRCDIR=\\\".\\\"
-} else {
- DEFINES+= SRCDIR=\\\"$$PWD\\\"
-}
+TESTDATA += keys/* rsa-without-passphrase.pem rsa-with-passphrase.pem
void createPlainTestRows();
-public:
- tst_QSslKey();
- virtual ~tst_QSslKey();
-
public slots:
- void initTestCase_data();
- void init();
- void cleanup();
+ void initTestCase();
#ifndef QT_NO_OPENSSL
void passphraseChecks();
#endif
+private:
+ QString testDataDir;
};
-tst_QSslKey::tst_QSslKey()
+void tst_QSslKey::initTestCase()
{
-#ifdef Q_OS_MAC
- // applicationDirPath() points to a path inside the app bundle on Mac.
- QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys"));
-#else
- QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds?
-#endif
+ testDataDir = QFileInfo(QFINDTESTDATA("rsa-without-passphrase.pem")).absolutePath();
+ if (testDataDir.isEmpty())
+ testDataDir = QCoreApplication::applicationDirPath();
+
+ QDir dir(testDataDir + "/keys");
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
QRegExp rx(QLatin1String("^(rsa|dsa)-(pub|pri)-(\\d+)\\.(pem|der)$"));
foreach (QFileInfo fileInfo, fileInfoList) {
}
}
-tst_QSslKey::~tst_QSslKey()
-{
-}
-
-void tst_QSslKey::initTestCase_data()
-{
-}
-
-void tst_QSslKey::init()
-{
-}
-
-void tst_QSslKey::cleanup()
-{
-}
-
static QByteArray readFile(const QString &absFilePath)
{
QFile file(absFilePath);
void tst_QSslKey::passphraseChecks()
{
{
- QString fileName(SRCDIR "/rsa-with-passphrase.pem");
+ QString fileName(testDataDir + "/rsa-with-passphrase.pem");
QFile keyFile(fileName);
QVERIFY(keyFile.exists());
{
{
// be sure and check a key without passphrase too
- QString fileName(SRCDIR "/rsa-without-passphrase.pem");
+ QString fileName(testDataDir + "/rsa-without-passphrase.pem");
QFile keyFile(fileName);
{
if (!keyFile.isOpen())