summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-01-26 16:13:55 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-01-26 16:13:55 (GMT)
commit41de32155e0a862ec7f6aacbcf985f06950bfda9 (patch)
tree9fe6b20d6e0b12fb53a0398f67f0a2702a9ad750 /tests/auto/qnetworkreply
parentb885787eee96f444e73c7a9d6f6b63f65ef2c172 (diff)
parent5498dcd7b10e147734a3414cab824b8b435aa3d9 (diff)
downloadQt-41de32155e0a862ec7f6aacbcf985f06950bfda9.zip
Qt-41de32155e0a862ec7f6aacbcf985f06950bfda9.tar.gz
Qt-41de32155e0a862ec7f6aacbcf985f06950bfda9.tar.bz2
Merge branch 4.7 into qt-master-from-4.7
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 91eff6f..1d2a69f 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -213,6 +213,7 @@ private Q_SLOTS:
void ioGetFromBuiltinHttp();
void ioGetFromHttpWithReuseParallel();
void ioGetFromHttpWithReuseSequential();
+ void ioGetFromHttpWithAuth_data();
void ioGetFromHttpWithAuth();
void ioGetFromHttpWithAuthSynchronous();
void ioGetFromHttpWithProxyAuth();
@@ -2178,15 +2179,27 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseSequential()
}
}
+void tst_QNetworkReply::ioGetFromHttpWithAuth_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QByteArray>("expectedData");
+
+ QFile reference(SRCDIR "/rfc3252.txt");
+ reference.open(QIODevice::ReadOnly);
+ QByteArray referenceData = reference.readAll();
+ QTest::newRow("basic") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt") << referenceData;
+ QTest::newRow("digest") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/auth-digest/") << QByteArray("digest authentication successful\n");
+}
+
void tst_QNetworkReply::ioGetFromHttpWithAuth()
{
// This test sends three requests
// The first two in parallel
// The third after the first two finished
- QFile reference(SRCDIR "/rfc3252.txt");
- QVERIFY(reference.open(QIODevice::ReadOnly));
- QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt"));
+ QFETCH(QUrl, url);
+ QFETCH(QByteArray, expectedData);
+ QNetworkRequest request(url);
{
QNetworkReplyPtr reply1 = manager.get(request);
QNetworkReplyPtr reply2 = manager.get(request);
@@ -2211,14 +2224,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
- QByteArray referenceData = reference.readAll();
- QCOMPARE(reader1.data, referenceData);
- QCOMPARE(reader2.data, referenceData);
+ QCOMPARE(reader1.data, expectedData);
+ QCOMPARE(reader2.data, expectedData);
QCOMPARE(authspy.count(), 1);
}
- reference.seek(0);
// rinse and repeat:
{
QNetworkReplyPtr reply = manager.get(request);
@@ -2234,13 +2245,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
- QCOMPARE(reader.data, reference.readAll());
+ QCOMPARE(reader.data, expectedData);
QCOMPARE(authspy.count(), 0);
}
// now check with synchronous calls:
- reference.seek(0);
{
request.setAttribute(
static_cast<QNetworkRequest::Attribute>(SynchronousRequestAttribute),
@@ -2256,7 +2266,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
// the only thing we check here is that the auth cache was used when using synchronous requests
QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
- QCOMPARE(replySync->readAll(), reference.readAll());
+ QCOMPARE(replySync->readAll(), expectedData);
}
}