diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-20 19:21:38 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-22 07:41:12 (GMT) |
commit | 9da275a24ae0b40ae29292a050c48915ac61099b (patch) | |
tree | 857888ef95ac0e80cc68c0afd9acbd2e49cf1cd6 /tests/auto/networkselftest | |
parent | fbc94a70f2f539d640c3a7785d11e4d6ebe70b16 (diff) | |
download | Qt-9da275a24ae0b40ae29292a050c48915ac61099b.zip Qt-9da275a24ae0b40ae29292a050c48915ac61099b.tar.gz Qt-9da275a24ae0b40ae29292a050c48915ac61099b.tar.bz2 |
[networkselftest] Verify some CGIs on the test server
Diffstat (limited to 'tests/auto/networkselftest')
-rw-r--r-- | tests/auto/networkselftest/tst_networkselftest.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index a4a130a..d25fcb6 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -79,6 +79,8 @@ private slots: void httpServer(); void httpServerFiles_data(); void httpServerFiles(); + void httpServerCGI_data(); + void httpServerCGI(); void httpsServer(); void httpProxy(); void httpProxyBasicAuth(); @@ -678,6 +680,76 @@ void tst_NetworkSelfTest::httpServerFiles() netChat(80, chat); } +void tst_NetworkSelfTest::httpServerCGI_data() +{ + QTest::addColumn<QByteArray>("request"); + QTest::addColumn<QByteArray>("result"); + QTest::addColumn<QByteArray>("additionalHeader"); + + QTest::newRow("echo.cgi") + << QByteArray("GET /qtest/cgi-bin/echo.cgi?Hello+World HTTP/1.0\r\n" + "Connection: close\r\n" + "\r\n") + << QByteArray("Hello+World") + << QByteArray(); + + QTest::newRow("echo.cgi(POST)") + << QByteArray("POST /qtest/cgi-bin/echo.cgi?Hello+World HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("Hello, World!\r\n") + << QByteArray(); + + QTest::newRow("md5sum.cgi") + << QByteArray("POST /qtest/cgi-bin/md5sum.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("29b933a8d9a0fcef0af75f1713f4940e\n") + << QByteArray(); + + QTest::newRow("protected/md5sum.cgi") + << QByteArray("POST /qtest/protected/cgi-bin/md5sum.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("29b933a8d9a0fcef0af75f1713f4940e\n") + << QByteArray(); + + QTest::newRow("set-cookie.cgi") + << QByteArray("POST /qtest/cgi-bin/set-cookie.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 8\r\n" + "\r\n" + "foo=bar\n") + << QByteArray("Success\n") + << QByteArray("\r\nSet-Cookie: foo=bar\r\n"); +} + +void tst_NetworkSelfTest::httpServerCGI() +{ + QFETCH(QByteArray, request); + QFETCH(QByteArray, result); + QFETCH(QByteArray, additionalHeader); + QList<Chat> chat; + chat << Chat::send(request) + << Chat::expect("HTTP/1.") << Chat::skipBytes(1) + << Chat::expect(" 200 "); + + if (!additionalHeader.isEmpty()) + chat << Chat::discardUntil(additionalHeader); + + chat << Chat::discardUntil("\r\n\r\n") + << Chat::expect(result) + << Chat::RemoteDisconnect; + netChat(80, chat); +} + void tst_NetworkSelfTest::httpsServer() { #ifndef QT_NO_OPENSSL |