diff options
author | Richard Moore <rich@kde.org> | 2011-11-15 21:58:05 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-17 13:22:56 +0100 |
commit | bf7364f0aa9878015f93b5c6b6b06cb8cb3c17c1 (patch) | |
tree | 3ad92e0257997fb6d4c51079ac8c2d813a45dc41 /tests/auto/network/ssl/qsslsocket | |
parent | 944b7999442db2a711a5e7740bfdd1d1b7aa0445 (diff) |
Improve the testability of QSslOptions.
The handling of QSslOptions is complicated not only by the subject, but
also by the fact that some of the openssl directives are negatives. This
commit tries to separate the inherent complexity from the complexity of
the api by allowing us to test them independently.
Change-Id: Ieb9386c69dd9b0b49dc42e26b2878a301f26ded1
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
Diffstat (limited to 'tests/auto/network/ssl/qsslsocket')
-rw-r--r-- | tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index d9ea400d0a..27bfeb7933 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -192,6 +192,7 @@ private slots: void blacklistedCertificates(); void setEmptyDefaultConfiguration(); void versionAccessors(); + void sslOptions(); static void exitLoop() { @@ -2052,6 +2053,48 @@ void tst_QSslSocket::versionAccessors() qDebug() << QString::number(QSslSocket::sslLibraryVersionNumber(), 16); } +void tst_QSslSocket::sslOptions() +{ + if (!QSslSocket::supportsSsl()) + return; + + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSsl::SslOptionDisableEmptyFragments + |QSsl::SslOptionDisableLegacyRenegotiation), + long(SSL_OP_ALL|SSL_OP_NO_SSLv2)); + +#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSsl::SslOptionDisableEmptyFragments), + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION))); +#endif + +#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSsl::SslOptionDisableLegacyRenegotiation), + long((SSL_OP_ALL|SSL_OP_NO_SSLv2) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)); +#endif + +#ifdef SSL_OP_NO_TICKET + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSsl::SslOptionDisableEmptyFragments + |QSsl::SslOptionDisableLegacyRenegotiation + |QSsl::SslOptionDisableSessionTickets), + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET))); +#endif + +#ifdef SSL_OP_NO_TICKET +#ifdef SSL_OP_NO_COMPRESSION + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSsl::SslOptionDisableEmptyFragments + |QSsl::SslOptionDisableLegacyRenegotiation + |QSsl::SslOptionDisableSessionTickets + |QSsl::SslOptionDisableCompression), + long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION))); +#endif +#endif +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) |