summaryrefslogtreecommitdiffstats
path: root/tests/manual/qnetworkreply
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@rim.com>2013-01-14 14:43:52 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-04 09:54:44 +0100
commit7d3bae1292ee3adfc4bcba4827d2a456c703627e (patch)
tree7d06479b936b1aba209c5f8623f5eff07657762a /tests/manual/qnetworkreply
parente80d7bb8bb7fcecab8f98a614e34d4e3929d5ec4 (diff)
QSslConfiguration: toggle on demand loading of root certs properly
make sure we keep track of when we can load root certs and when we cannot (we cannot when the developer set the certs explicitly). This is implemented the same way for QSslSocket already, and needs to be duplicated because we have 2 methods for setting CA certificates: one in QSslSocket and one in QSslConfiguration. In addition, adapt the auto test which checks whether setting a default QSslConfiguration works: There is no way to set on demand loading through the API, so it should be enabled by default. Task-number: QTBUG-29103 (backport of commit ce35c0db0d9dd849c736eabaeb57d597186aaa13) Change-Id: Idf15c21092c7727e1080b1c261ce055f30dbcf63 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/manual/qnetworkreply')
-rw-r--r--tests/manual/qnetworkreply/main.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp
index 0226d903a6..9d395eea26 100644
--- a/tests/manual/qnetworkreply/main.cpp
+++ b/tests/manual/qnetworkreply/main.cpp
@@ -46,8 +46,13 @@
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtNetwork/qsslconfiguration.h>
#include "../../auto/network-settings.h"
+#ifdef QT_BUILD_INTERNAL
+#include "private/qsslsocket_p.h"
+#endif
+
#define BANDWIDTH_LIMIT_BYTES (1024*100)
#define TIME_ESTIMATION_SECONDS (97)
@@ -57,7 +62,8 @@ class tst_qnetworkreply : public QObject
private slots:
void limiting_data();
void limiting();
-
+ void setSslConfiguration_data();
+ void setSslConfiguration();
};
QNetworkReply *reply;
@@ -124,6 +130,42 @@ void tst_qnetworkreply::limiting()
QVERIFY(!QTestEventLoop::instance().timeout());
}
+void tst_qnetworkreply::setSslConfiguration_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<bool>("works");
+
+ QTest::newRow("codereview.qt-project.org") << QUrl("https://codereview.qt-project.org") << true;
+ QTest::newRow("test-server") << QUrl("https://" + QtNetworkSettings::serverName() + "/") << false;
+}
+
+void tst_qnetworkreply::setSslConfiguration()
+{
+ QFETCH(QUrl, url);
+ QNetworkRequest request(url);
+ QSslConfiguration conf = request.sslConfiguration();
+ conf.setProtocol(QSsl::TlsV1); // TLS 1.0 will be used anyway, just make sure we change the configuration
+ request.setSslConfiguration(conf);
+ QNetworkAccessManager manager;
+ reply = manager.get(request);
+ QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(15);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+#ifdef QT_BUILD_INTERNAL
+ QFETCH(bool, works);
+ bool rootCertLoadingAllowed = QSslSocketPrivate::rootCertOnDemandLoadingSupported();
+#if defined(Q_OS_LINUX) || defined (Q_OS_BLACKBERRY)
+ QCOMPARE(rootCertLoadingAllowed, true);
+#elif defined(Q_OS_MAC)
+ QCOMPARE(rootCertLoadingAllowed, false);
+#endif // other platforms: undecided (Windows: depends on the version)
+ if (works) {
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ } else {
+ QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError);
+ }
+#endif
+}
QTEST_MAIN(tst_qnetworkreply)