summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-01-06 22:17:58 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-01-06 22:17:58 (GMT)
commit37094502d4f3ada3b23adf4f6081f9b85d2be7c4 (patch)
tree7754714efc8ba2ddbac41f5e7859ba155f1456ad /tests
parent9cc21c043238dc7576a465c9d236e8968fd8c549 (diff)
parent273cc18e59af6b495462cbe101652a444a2cc8f4 (diff)
downloadQt-37094502d4f3ada3b23adf4f6081f9b85d2be7c4.zip
Qt-37094502d4f3ada3b23adf4f6081f9b85d2be7c4.tar.gz
Qt-37094502d4f3ada3b23adf4f6081f9b85d2be7c4.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: licensing: exclude generated cookie jar table from license check fix include path fix build with namespaces in new cookie jar table cookie jar code: enhance security by keeping track of effective TLDs Add support for QMetaType::QVariant in ActiveQt Fix QNetworkReply autotest cases for QT-3494 Add compiler optimization for QtScript/JSC on Symbian improve performance of QTextEngine, esp. setBoundary by using non-detaching operator[] Improve docs for QTEST_MAIN macro. Work around an apparent GCC optimiser bug accessing arrays beyond end Do not crash in case a future version of libdbus has a new kind of message. Docs: QTBUG-9150 Incorrect snippet in class doc. tst_headers: make failure more detailed when failing to open a file Fix number of chapters in qtestlib tutorial. Fixed QStatusBar not to repaint itself too early QNAM HTTP: Fix missing error() signal Make it clear which security updates are needed for Visual Studio 2005.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/headers/tst_headers.cpp10
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp104
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp22
3 files changed, 123 insertions, 13 deletions
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 7ccf058..b889a37 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -176,7 +176,9 @@ void tst_Headers::allSourceFilesData()
|| sourceFile.endsWith(".ui.h")
|| sourceFile.endsWith("/src/corelib/global/qconfig.h")
|| sourceFile.endsWith("/src/corelib/global/qconfig.cpp")
- || sourceFile.endsWith("/src/tools/uic/qclass_lib_map.h"))
+ || sourceFile.endsWith("/src/tools/uic/qclass_lib_map.h")
+ || sourceFile.endsWith("src/network/access/qnetworkcookiejartlds_p.h")
+ )
continue;
QTest::newRow(qPrintable(sourceFile)) << sourceFile;
@@ -203,7 +205,7 @@ void tst_Headers::licenseCheck()
QFETCH(QString, sourceFile);
QFile f(sourceFile);
- QVERIFY(f.open(QIODevice::ReadOnly));
+ QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString()));
QByteArray data = f.readAll();
data.replace("\r\n", "\n"); // Windows
data.replace('\r', '\n'); // Mac OS9
@@ -264,7 +266,7 @@ void tst_Headers::privateSlots()
return;
QFile f(header);
- QVERIFY(f.open(QIODevice::ReadOnly));
+ QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString()));
QStringList content = QString::fromLocal8Bit(f.readAll()).split("\n");
foreach (QString line, content) {
@@ -286,7 +288,7 @@ void tst_Headers::macros()
return;
QFile f(header);
- QVERIFY(f.open(QIODevice::ReadOnly));
+ QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString()));
QByteArray data = f.readAll();
QStringList content = QString::fromLocal8Bit(data.replace('\r', "")).split("\n");
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 01b9c0c..6548158 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -42,6 +42,7 @@
#include <QtTest/QtTest>
#include <QtNetwork/QNetworkCookieJar>
+#include "private/qnetworkcookiejar_p.h"
class tst_QNetworkCookieJar: public QObject
{
@@ -53,6 +54,8 @@ private slots:
void setCookiesFromUrl();
void cookiesForUrl_data();
void cookiesForUrl();
+ void effectiveTLDs_data();
+ void effectiveTLDs();
};
QT_BEGIN_NAMESPACE
@@ -174,6 +177,31 @@ void tst_QNetworkCookieJar::setCookiesFromUrl_data()
result += cookie;
QTest::newRow("security-path-1") << preset << cookie << "http://www.foo.tld" << result << true;
+ // check effective TLDs
+ // 1. co.uk is an effective TLD, should be denied
+ result.clear();
+ preset.clear();
+ cookie.setPath("/");
+ cookie.setDomain(".co.uk");
+ QTest::newRow("effective-tld1-denied") << preset << cookie << "http://something.co.uk" << result << false;
+ cookie.setDomain("co.uk");
+ QTest::newRow("effective-tld1-denied2") << preset << cookie << "http://something.co.uk" << result << false;
+ cookie.setDomain(".something.co.uk");
+ result += cookie;
+ QTest::newRow("effective-tld1-accepted") << preset << cookie << "http://something.co.uk" << result << true;
+
+ // 2. anything .ar is an effective TLD ('*.ar'), but 'gobiernoelectronico.ar' is an exception
+ result.clear();
+ preset.clear();
+ cookie.setDomain(".farmacia.ar");
+ QTest::newRow("effective-tld2-denied") << preset << cookie << "http://farmacia.ar" << result << false;
+ QTest::newRow("effective-tld2-denied2") << preset << cookie << "http://www.farmacia.ar" << result << false;
+ QTest::newRow("effective-tld2-denied3") << preset << cookie << "http://www.anything.farmacia.ar" << result << false;
+ cookie.setDomain(".gobiernoelectronico.ar");
+ result += cookie;
+ QTest::newRow("effective-tld2-accepted") << preset << cookie << "http://www.gobiernoelectronico.ar" << result << true;
+
+
// setting the defaults:
finalCookie = cookie;
finalCookie.setPath("/something/");
@@ -334,6 +362,82 @@ void tst_QNetworkCookieJar::cookiesForUrl()
QCOMPARE(result, expectedResult);
}
+void tst_QNetworkCookieJar::effectiveTLDs_data()
+{
+ QTest::addColumn<QString>("domain");
+ QTest::addColumn<bool>("isTLD");
+
+ QTest::newRow("yes1") << "com" << true;
+ QTest::newRow("yes2") << "de" << true;
+ QTest::newRow("yes3") << "ulm.museum" << true;
+ QTest::newRow("yes4") << "krodsherad.no" << true;
+ QTest::newRow("yes5") << "1.bg" << true;
+ QTest::newRow("yes6") << "com.cn" << true;
+ QTest::newRow("yes7") << "org.ws" << true;
+ QTest::newRow("yes8") << "co.uk" << true;
+ QTest::newRow("yes9") << "wallonie.museum" << true;
+
+ QTest::newRow("no1") << "anything.com" << false;
+ QTest::newRow("no2") << "anything.de" << false;
+ QTest::newRow("no3") << "eselsberg.ulm.museum" << false;
+ QTest::newRow("no4") << "noe.krodsherad.no" << false;
+ QTest::newRow("no5") << "2.1.bg" << false;
+ QTest::newRow("no6") << "foo.com.cn" << false;
+ QTest::newRow("no7") << "something.org.ws" << false;
+ QTest::newRow("no8") << "teatime.co.uk" << false;
+ QTest::newRow("no9") << "bla" << false;
+ QTest::newRow("no10") << "bla.bla" << false;
+
+ const ushort s1[] = {0x74, 0x72, 0x61, 0x6e, 0xf8, 0x79, 0x2e, 0x6e, 0x6f, 0x00}; // xn--trany-yua.no
+ const ushort s2[] = {0x5d9, 0x5e8, 0x5d5, 0x5e9, 0x5dc, 0x5d9, 0x5dd, 0x2e, 0x6d, 0x75, 0x73, 0x65, 0x75, 0x6d, 0x00}; // xn--9dbhblg6di.museum
+ const ushort s3[] = {0x7ec4, 0x7e54, 0x2e, 0x68, 0x6b, 0x00}; // xn--mk0axi.hk
+ const ushort s4[] = {0x7f51, 0x7edc, 0x2e, 0x63, 0x6e, 0x00}; // xn--io0a7i.cn
+ const ushort s5[] = {0x72, 0xe1, 0x68, 0x6b, 0x6b, 0x65, 0x72, 0xe1, 0x76, 0x6a, 0x75, 0x2e, 0x6e, 0x6f, 0x00}; // xn--rhkkervju-01af.no
+ const ushort s6[] = {0xb9a, 0xbbf, 0xb99, 0xbcd, 0xb95, 0xbaa, 0xbcd, 0xbaa, 0xbc2, 0xbb0, 0xbcd, 0x00}; // xn--clchc0ea0b2g2a9gcd
+ const ushort s7[] = {0x627, 0x644, 0x627, 0x631, 0x62f, 0x646, 0x00}; // xn--mgbayh7gpa
+ const ushort s8[] = {0x63, 0x6f, 0x72, 0x72, 0x65, 0x69, 0x6f, 0x73, 0x2d, 0x65, 0x2d, 0x74, 0x65, 0x6c, 0x65,
+ 0x63, 0x6f, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, 0xe7, 0xf5, 0x65, 0x73, 0x2e, 0x6d, 0x75,
+ 0x73, 0x65, 0x75, 0x6d, 0x00}; // xn--correios-e-telecomunicaes-ghc29a.museum
+ QTest::newRow("yes-specialchars1") << QString::fromUtf16(s1) << true;
+ QTest::newRow("yes-specialchars2") << QString::fromUtf16(s2) << true;
+ QTest::newRow("yes-specialchars3") << QString::fromUtf16(s3) << true;
+ QTest::newRow("yes-specialchars4") << QString::fromUtf16(s4) << true;
+ QTest::newRow("yes-specialchars5") << QString::fromUtf16(s5) << true;
+ QTest::newRow("yes-specialchars6") << QString::fromUtf16(s6) << true;
+ QTest::newRow("yes-specialchars7") << QString::fromUtf16(s7) << true;
+ QTest::newRow("yes-specialchars8") << QString::fromUtf16(s8) << true;
+
+ QTest::newRow("no-specialchars1") << QString::fromUtf16(s1).prepend("something") << false;
+ QTest::newRow("no-specialchars2") << QString::fromUtf16(s2).prepend(QString::fromUtf16(s2)) << false;
+ QTest::newRow("no-specialchars2.5") << QString::fromUtf16(s2).prepend("whatever") << false;
+ QTest::newRow("no-specialchars3") << QString::fromUtf16(s3).prepend("foo") << false;
+ QTest::newRow("no-specialchars4") << QString::fromUtf16(s4).prepend("bar") << false;
+ QTest::newRow("no-specialchars5") << QString::fromUtf16(s5).prepend(QString::fromUtf16(s2)) << false;
+ QTest::newRow("no-specialchars6") << QString::fromUtf16(s6).prepend(QLatin1Char('.') + QString::fromUtf16(s6)) << false;
+ QTest::newRow("no-specialchars7") << QString::fromUtf16(s7).prepend("bla") << false;
+ QTest::newRow("no-specialchars8") << QString::fromUtf16(s8).append("foo") << false;
+
+ QTest::newRow("exception1") << "pref.iwate.jp" << false;
+ QTest::newRow("exception2") << "omanpost.om" << false;
+ QTest::newRow("exception3") << "omantel.om" << false;
+ QTest::newRow("exception4") << "gobiernoelectronico.ar" << false;
+ QTest::newRow("exception5") << "pref.ishikawa.jp" << false;
+
+ QTest::newRow("yes-wildcard1") << "*.jm" << true;
+ QTest::newRow("yes-wildcard1.5") << "anything.jm" << true;
+ QTest::newRow("yes-wildcard2") << "something.kh" << true;
+ QTest::newRow("yes-wildcard3") << "whatever.uk" << true;
+ QTest::newRow("yes-wildcard4") << "anything.shizuoka.jp" << true;
+ QTest::newRow("yes-wildcard5") << "foo.sch.uk" << true;
+}
+
+void tst_QNetworkCookieJar::effectiveTLDs()
+{
+ QFETCH(QString, domain);
+ QFETCH(bool, isTLD);
+ QCOMPARE(QNetworkCookieJarPrivate::isEffectiveTLD(domain), isTLD);
+}
+
QTEST_MAIN(tst_QNetworkCookieJar)
#include "tst_qnetworkcookiejar.moc"
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index cff0ae9..6cd9d3c 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -2585,17 +2585,19 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
void tst_QNetworkReply::ioGetFromHttpStatus100_data()
{
QTest::addColumn<QByteArray>("dataToSend");
- QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n");
- QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n");
- QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
- QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ QTest::addColumn<QNetworkReply::NetworkError>("expectedError");
+ QTest::newRow("normal") << QByteArray("HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << QNetworkReply::NoError;
+ QTest::newRow("minimal") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << QNetworkReply::NoError;
+ QTest::newRow("minimal2") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\r\n\r\n") << QNetworkReply::RemoteHostClosedError;
+ QTest::newRow("minimal3") << QByteArray("HTTP/1.1 100 Continue\n\nHTTP/1.0 200 OK\n\n") << QNetworkReply::RemoteHostClosedError;
+ QTest::newRow("with_headers") << QByteArray("HTTP/1.1 100 Continue\r\nBla: x\r\n\r\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << QNetworkReply::NoError;
+ QTest::newRow("with_headers2") << QByteArray("HTTP/1.1 100 Continue\nBla: x\n\nHTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n") << QNetworkReply::NoError;
}
void tst_QNetworkReply::ioGetFromHttpStatus100()
{
QFETCH(QByteArray, dataToSend);
+ QFETCH(QNetworkReply::NetworkError, expectedError);
MiniHttpServer server(dataToSend);
server.doClose = true;
@@ -2607,7 +2609,7 @@ void tst_QNetworkReply::ioGetFromHttpStatus100()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->url(), request.url());
- QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->error(), expectedError);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QVERIFY(reply->rawHeader("bla").isNull());
}
@@ -2615,12 +2617,14 @@ void tst_QNetworkReply::ioGetFromHttpStatus100()
void tst_QNetworkReply::ioGetFromHttpNoHeaders_data()
{
QTest::addColumn<QByteArray>("dataToSend");
- QTest::newRow("justStatus+noheaders+disconnect") << QByteArray("HTTP/1.0 200 OK\r\n\r\n");
+ QTest::addColumn<QNetworkReply::NetworkError>("expectedError");
+ QTest::newRow("justStatus+noheaders+disconnect") << QByteArray("HTTP/1.0 200 OK\r\n\r\n") << QNetworkReply::RemoteHostClosedError;
}
void tst_QNetworkReply::ioGetFromHttpNoHeaders()
{
QFETCH(QByteArray, dataToSend);
+ QFETCH(QNetworkReply::NetworkError, expectedError);
MiniHttpServer server(dataToSend);
server.doClose = true;
@@ -2632,7 +2636,7 @@ void tst_QNetworkReply::ioGetFromHttpNoHeaders()
QVERIFY(!QTestEventLoop::instance().timeout());
QCOMPARE(reply->url(), request.url());
- QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->error(), expectedError);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
}