summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsslsocket
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-10-20 13:03:56 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-10-20 13:54:49 (GMT)
commit58574ea3590fbb28da5be73b983d83f0a8824d00 (patch)
tree2b6eacecf0726195cd375dc19f8aa673a81c320f /tests/auto/qsslsocket
parentf779d9f7e317ff3e10f015a05d349e1fa3e7ab84 (diff)
downloadQt-58574ea3590fbb28da5be73b983d83f0a8824d00.zip
Qt-58574ea3590fbb28da5be73b983d83f0a8824d00.tar.gz
Qt-58574ea3590fbb28da5be73b983d83f0a8824d00.tar.bz2
tst_qsslsocket: new bigChunk testcase
This new test is to find out if the BIO size of OpenSSL is limited or not. The test passes on my Linux, however the OpenSSL docu suggests that the BIO size is limited. From http://www.openssl.org/docs/crypto/BIO_s_bio.html "This is currently 17K". Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qsslsocket')
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 6b330e1..2f1c2e2 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -173,6 +173,7 @@ private slots:
void disconnectFromHostWhenConnected();
void resetProxy();
void readFromClosedSocket();
+ void writeBigChunk();
static void exitLoop()
{
@@ -1537,6 +1538,50 @@ void tst_QSslSocket::readFromClosedSocket()
QVERIFY(!socket->bytesToWrite());
}
+void tst_QSslSocket::writeBigChunk()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ this->socket = socket;
+
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+ QByteArray data;
+ data.resize(1024*1024*10); // 10 MB
+ // init with garbage. needed so ssl cannot compress it in an efficient way.
+ for (int i = 0; i < data.size() / sizeof(int); i++) {
+ int r = qrand();
+ data.data()[i*sizeof(int)] = r;
+ }
+
+ QVERIFY(socket->waitForEncrypted(10000));
+ QString errorBefore = socket->errorString();
+
+ int ret = socket->write(data.constData(), data.size());
+ QVERIFY(data.size() == ret);
+
+ // spin the event loop once so QSslSocket::transmit() gets called
+ QCoreApplication::processEvents();
+ QString errorAfter = socket->errorString();
+
+ // no better way to do this right now since the error is the same as the default error.
+ if (socket->errorString().startsWith(QLatin1String("Unable to write data")))
+ {
+ qWarning() << socket->error() << socket->errorString();
+ QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!");
+ }
+ // also check the error string. If another error (than UnknownError) occured, it should be different than before
+ QVERIFY(errorBefore == errorAfter);
+
+ // check that everything has been written to OpenSSL
+ QVERIFY(socket->bytesToWrite() == 0);
+
+ socket->close();
+}
+
#endif // QT_NO_OPENSSL
QTEST_MAIN(tst_QSslSocket)