summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsslsocket
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@trolltech.com>2009-05-20 09:57:52 (GMT)
committerPeter Hartmann <peter.hartmann@trolltech.com>2009-05-20 10:00:21 (GMT)
commita9722dffb48559c27f2f4cd99ebc082f717a9e60 (patch)
tree591f5459b603a04e1a30268e38e6d0c286021ec6 /tests/auto/qsslsocket
parent4a8c7e432931b27e7a5440a6d15bde999e962f35 (diff)
downloadQt-a9722dffb48559c27f2f4cd99ebc082f717a9e60.zip
Qt-a9722dffb48559c27f2f4cd99ebc082f717a9e60.tar.gz
Qt-a9722dffb48559c27f2f4cd99ebc082f717a9e60.tar.bz2
make QSslSocket test work also for shadow builds
... by being able to load the certificates also in a shadow build directory Reviewed-by: Thiago
Diffstat (limited to 'tests/auto/qsslsocket')
-rw-r--r--tests/auto/qsslsocket/qsslsocket.pro6
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp30
2 files changed, 21 insertions, 15 deletions
diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro
index 147b40d..c29fc68 100644
--- a/tests/auto/qsslsocket/qsslsocket.pro
+++ b/tests/auto/qsslsocket/qsslsocket.pro
@@ -7,6 +7,12 @@ QT -= gui
TARGET = tst_qsslsocket
+!wince* {
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+} else {
+DEFINES += SRCDIR=\\\"./\\\"
+}
+
win32 {
CONFIG(debug, debug|release) {
DESTDIR = debug
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 5c99164..0aa93fe 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -577,7 +577,7 @@ void tst_QSslSocket::connectToHostEncrypted()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")));
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(untrustedWorkaroundSlot(QList<QSslError>)));
@@ -648,7 +648,7 @@ void tst_QSslSocket::peerCertificateChain()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String("certs/qt-test-server-cacert.pem"));
+ QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
QVERIFY(caCertificates.count() == 1);
socket->addCaCertificates(caCertificates);
@@ -709,7 +709,7 @@ void tst_QSslSocket::protocol()
QSslSocketPtr socket = newSocket();
this->socket = socket;
- QList<QSslCertificate> certs = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem");
+ QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
// qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName);
socket->setCaCertificates(certs);
@@ -792,7 +792,7 @@ void tst_QSslSocket::setCaCertificates()
QSslSocket socket;
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
- socket.setCaCertificates(QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"));
+ socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"));
QCOMPARE(socket.caCertificates().size(), 1);
socket.setCaCertificates(socket.defaultCaCertificates());
QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates());
@@ -823,13 +823,13 @@ protected:
socket = new QSslSocket(this);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
- QFile file("certs/fluke.key");
+ QFile file(SRCDIR "certs/fluke.key");
QVERIFY(file.open(QIODevice::ReadOnly));
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
QVERIFY(!key.isNull());
socket->setPrivateKey(key);
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -930,7 +930,7 @@ void tst_QSslSocket::addDefaultCaCertificate()
// Reset the global CA chain
QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates());
- QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem");
+ QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem");
QCOMPARE(flukeCerts.size(), 1);
QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates();
QVERIFY(!globalCerts.contains(flukeCerts.first()));
@@ -1014,7 +1014,7 @@ void tst_QSslSocket::wildcard()
// responds with the wildcard, and QSslSocket should accept that as a
// valid connection. This was broken in 4.3.0.
QSslSocketPtr socket = newSocket();
- socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
this->socket = socket;
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
@@ -1040,7 +1040,7 @@ protected:
socket->ignoreSslErrors();
// Only set the certificate
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -1199,13 +1199,13 @@ protected:
socket = new QSslSocket(this);
connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
- QFile file("certs/fluke.key");
+ QFile file(SRCDIR "certs/fluke.key");
QVERIFY(file.open(QIODevice::ReadOnly));
QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
QVERIFY(!key.isNull());
socket->setPrivateKey(key);
- QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert");
+ QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert");
QVERIFY(!localCert.isEmpty());
QVERIFY(localCert.first().handle());
socket->setLocalCertificate(localCert.first());
@@ -1363,8 +1363,8 @@ protected:
{
socket = new QSslSocket(this);
- socket->setPrivateKey("certs/fluke.key");
- socket->setLocalCertificate("certs/fluke.cert");
+ socket->setPrivateKey(SRCDIR "certs/fluke.key");
+ socket->setLocalCertificate(SRCDIR "certs/fluke.cert");
socket->setSocketDescriptor(socketDescriptor);
socket->startServerEncryption();
}
@@ -1487,7 +1487,7 @@ void tst_QSslSocket::resetProxy()
// make sure the connection works, and then set a nonsense proxy, and then
// make sure it does not work anymore
QSslSocket socket;
- socket.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
socket.setProxy(goodProxy);
socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString()));
@@ -1500,7 +1500,7 @@ void tst_QSslSocket::resetProxy()
// set the nonsense proxy and make sure the connection does not work,
// and then set the right proxy and make sure it works
QSslSocket socket2;
- socket2.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"));
+ socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
socket2.setProxy(badProxy);
socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
QVERIFY(! socket2.waitForConnected(10000));