summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@nokia.com>2011-03-24 10:50:15 (GMT)
committerPeter Hartmann <peter.hartmann@nokia.com>2011-03-28 15:18:31 (GMT)
commitaa144f7e11547549414a977f6e72ff8b92f95d30 (patch)
tree948a21247da2697a756497dba4079347642743db /tests/auto/qnetworkreply
parentd92c3ca977c62bdc0cc6d0961d4e2ae91cd5fc48 (diff)
downloadQt-aa144f7e11547549414a977f6e72ff8b92f95d30.zip
Qt-aa144f7e11547549414a977f6e72ff8b92f95d30.tar.gz
Qt-aa144f7e11547549414a977f6e72ff8b92f95d30.tar.bz2
QSslConfiguration: do not lazily construct the d-pointer
...the private class is cheap anyway; and lazy construction lead to problems like setting an empty default configuration would crash etc. Reviewed-by: Markus Goetz Task-number: QTBUG-17550
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 6ed8f16..650526e 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -87,6 +87,7 @@ Q_DECLARE_METATYPE(QNetworkReply::NetworkError)
Q_DECLARE_METATYPE(QBuffer*)
Q_DECLARE_METATYPE(QHttpMultiPart *)
Q_DECLARE_METATYPE(QList<QFile*>) // for multiparts
+Q_DECLARE_METATYPE(QSslConfiguration)
class QNetworkReplyPtr: public QSharedPointer<QNetworkReply>
{
@@ -319,6 +320,8 @@ private Q_SLOTS:
void ignoreSslErrorsList();
void ignoreSslErrorsListWithSlot_data();
void ignoreSslErrorsListWithSlot();
+ void sslConfiguration_data();
+ void sslConfiguration();
#endif
void getAndThenDeleteObject_data();
@@ -5370,6 +5373,37 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
QCOMPARE(reply->error(), expectedNetworkError);
}
+void tst_QNetworkReply::sslConfiguration_data()
+{
+ QTest::addColumn<QSslConfiguration>("configuration");
+ QTest::addColumn<bool>("works");
+
+ QTest::newRow("empty") << QSslConfiguration() << false;
+ QSslConfiguration conf = QSslConfiguration::defaultConfiguration();
+ QTest::newRow("default") << conf << false; // does not contain test server cert
+ QList<QSslCertificate> testServerCert = QSslCertificate::fromPath(SRCDIR "/certs/qt-test-server-cacert.pem");
+ conf.setCaCertificates(testServerCert);
+ QTest::newRow("set-root-cert") << conf << true;
+ conf.setProtocol(QSsl::SecureProtocols);
+ QTest::newRow("secure") << conf << true;
+}
+
+void tst_QNetworkReply::sslConfiguration()
+{
+ QNetworkRequest request(QUrl("https://" + QtNetworkSettings::serverName() + "/index.html"));
+ QFETCH(QSslConfiguration, configuration);
+ request.setSslConfiguration(configuration);
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QFETCH(bool, works);
+ QNetworkReply::NetworkError expectedError = works ? QNetworkReply::NoError : QNetworkReply::SslHandshakeFailedError;
+ QCOMPARE(reply->error(), expectedError);
+}
+
#endif // QT_NO_OPENSSL
void tst_QNetworkReply::getAndThenDeleteObject_data()