summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-11-05 14:03:06 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-11-05 14:03:06 (GMT)
commit74d593de47d264e2bfa77f01df4af540f9462c19 (patch)
tree3af92387f3052bb0d10d4aa8cdd4009b26f9cc40 /tests/auto/qnetworkreply
parentd4cad3c2f3fdbf6a1bda926582fb8ad4b6f08666 (diff)
downloadQt-74d593de47d264e2bfa77f01df4af540f9462c19.zip
Qt-74d593de47d264e2bfa77f01df4af540f9462c19.tar.gz
Qt-74d593de47d264e2bfa77f01df4af540f9462c19.tar.bz2
tst_qnetworkreply: New HTTP test with AuthenticationReuseAttribute
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index bef1e7e6..a986438 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -299,6 +299,8 @@ private Q_SLOTS:
void qtbug13431replyThrottling();
+ void httpWithNoCredentialUsage();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@@ -4695,6 +4697,33 @@ void tst_QNetworkReply::qtbug13431replyThrottling()
QCOMPARE(helper.m_reply->error(), QNetworkReply::NoError);
}
+void tst_QNetworkReply::httpWithNoCredentialUsage()
+{
+ QNetworkRequest request(QUrl("http://httptest:httptest@" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi"));
+ // Do not use credentials
+ request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Manual);
+ QNetworkAccessManager manager;
+ QNetworkReplyPtr reply = manager.get(request);
+
+ qRegisterMetaType<QNetworkReply*>("QNetworkReply*");
+ qRegisterMetaType<QAuthenticator*>("QAuthenticator*");
+ QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
+ QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*)));
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
+ QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ // We check if authenticationRequired was emitted, however we do not anything in it so it should be 401
+ QCOMPARE(authSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 1);
+ QCOMPARE(errorSpy.count(), 1);
+
+ QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
+}
+
// NOTE: This test must be last testcase in tst_qnetworkreply!