summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-08-12 13:05:02 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-08-12 13:05:02 +0200
commitca524e5b70ccfeb6386cf0c5df83ffb86a8771fe (patch)
tree245c471373516ccda2b0c91943a42cd74674f2da /tests/manual
parentb08cc0ec6f096d0e6764486c81264c24a406bee1 (diff)
parentc2badc7423b63824902d1f44a4b804de3335c20b (diff)
Merge remote-tracking branch 'origin/5.3' into 5.4
Manually included changes from 3a347a4e70e5a10ee92dd2578316c926a399e894 in src/opengl/qgl.cpp. Conflicts: src/opengl/qgl_qpa.cpp src/plugins/platforms/android/androidjnimain.cpp Change-Id: Ic26b58ee587d4884c9d0fba45c5a94b5a45ee929
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/qnetworkreply/main.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp
index ff96f2598d..3618828f80 100644
--- a/tests/manual/qnetworkreply/main.cpp
+++ b/tests/manual/qnetworkreply/main.cpp
@@ -49,6 +49,7 @@
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtNetwork/qsslconfiguration.h>
#include <QtNetwork/qhttpmultipart.h>
+#include <QtNetwork/qauthenticator.h>
#include <QtCore/QJsonDocument>
#include "../../auto/network-settings.h"
@@ -73,9 +74,13 @@ private slots:
void spdy_data();
void spdy();
void spdyMultipleRequestsPerHost();
+ void proxyAuthentication_data();
+ void proxyAuthentication();
+ void authentication();
protected slots:
void spdyReplyFinished(); // only used by spdyMultipleRequestsPerHost test
+ void authenticationRequiredSlot(QNetworkReply *, QAuthenticator *authenticator);
private:
QHttpMultiPart *createFacebookMultiPart(const QByteArray &accessToken);
@@ -504,6 +509,83 @@ void tst_qnetworkreply::spdyMultipleRequestsPerHost()
#endif // defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) ...
}
+void tst_qnetworkreply::proxyAuthentication_data()
+{
+ QTest::addColumn<QUrl>("url");
+
+ QTest::newRow("http://www.google.com") << QUrl("http://www.google.com");
+ QTest::newRow("https://www.google.com") << QUrl("https://www.google.com");
+}
+
+void tst_qnetworkreply::proxyAuthentication()
+{
+ QFETCH(QUrl, url);
+ QNetworkRequest request(url);
+ QNetworkAccessManager manager;
+
+ QByteArray proxyHostName = qgetenv("QT_PROXY_HOST");
+ QByteArray proxyPort = qgetenv("QT_PROXY_PORT");
+ QByteArray proxyUser = qgetenv("QT_PROXY_USER");
+ QByteArray proxyPassword = qgetenv("QT_PROXY_PASSWORD");
+ if (proxyHostName.isEmpty() || proxyPort.isEmpty() || proxyUser.isEmpty()
+ || proxyPassword.isEmpty())
+ QSKIP("This test requires the QT_PROXY_* environment variables to be set. "
+ "Do something like:\n"
+ "export QT_PROXY_HOST=myNTLMHost\n"
+ "export QT_PROXY_PORT=8080\n"
+ "export QT_PROXY_USER='myDomain\\myUser'\n"
+ "export QT_PROXY_PASSWORD=myPassword\n");
+
+ QNetworkProxy proxy(QNetworkProxy::HttpProxy);
+ proxy.setHostName(proxyHostName);
+ proxy.setPort(proxyPort.toInt());
+ proxy.setUser(proxyUser);
+ proxy.setPassword(proxyPassword);
+
+ manager.setProxy(proxy);
+
+ reply = manager.get(request);
+ QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(15);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+ int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ QVERIFY(statusCode >= 200 && statusCode < 400);
+}
+
+void tst_qnetworkreply::authenticationRequiredSlot(QNetworkReply *,
+ QAuthenticator *authenticator)
+{
+ QString authUser = QString::fromLocal8Bit(qgetenv("QT_AUTH_USER"));
+ QString authPassword = QString::fromLocal8Bit(qgetenv("QT_AUTH_PASSWORD"));
+ authenticator->setUser(authUser);
+ authenticator->setPassword(authPassword);
+}
+
+void tst_qnetworkreply::authentication()
+{
+ QByteArray authUrl = qgetenv("QT_AUTH_URL");
+ if (authUrl.isEmpty())
+ QSKIP("This test requires the QT_AUTH_* environment variables to be set. "
+ "Do something like:\n"
+ "export QT_AUTH_URL='http://myUrl.com/myPath'\n"
+ "export QT_AUTH_USER='myDomain\\myUser'\n"
+ "export QT_AUTH_PASSWORD=myPassword\n");
+
+ QUrl url(QString::fromLocal8Bit(authUrl));
+ QNetworkRequest request(url);
+ QNetworkAccessManager manager;
+ QObject::connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
+ this, SLOT(authenticationRequiredSlot(QNetworkReply*,QAuthenticator*)));
+ reply = manager.get(request);
+ QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(15);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY2(reply->error() == QNetworkReply::NoError, reply->errorString().toLocal8Bit());
+ int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ QVERIFY(statusCode >= 200 && statusCode < 400);
+}
+
QTEST_MAIN(tst_qnetworkreply)
#include "main.moc"