Make the default ssloptions testable.
authorRichard Moore <rich@kde.org>
Sun, 27 Nov 2011 12:45:30 +0000 (12:45 +0000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 29 Nov 2011 13:00:01 +0000 (14:00 +0100)
Centralise the specification of the default ssloptions to make the code
clearer and more testable.

Change-Id: I4f4bae72736dd063ee4cd64c6375e82d0600a105
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
src/network/ssl/qsslconfiguration.cpp
src/network/ssl/qsslconfiguration_p.h
tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp

index 16486c9..0e9eb5d 100644 (file)
@@ -47,6 +47,9 @@
 
 QT_BEGIN_NAMESPACE
 
+const QSsl::SslOptions QSslConfigurationPrivate::defaultSslOptions = QSsl::SslOptionDisableEmptyFragments
+                                                                    |QSsl::SslOptionDisableLegacyRenegotiation;
+
 /*!
     \class QSslConfiguration
     \brief The QSslConfiguration class holds the configuration and state of an SSL connection
@@ -201,7 +204,7 @@ bool QSslConfiguration::isNull() const
             d->privateKey.isNull() &&
             d->peerCertificate.isNull() &&
             d->peerCertificateChain.count() == 0 &&
-            d->sslOptions == (QSsl::SslOptionDisableEmptyFragments|QSsl::SslOptionDisableLegacyRenegotiation));
+            d->sslOptions == QSslConfigurationPrivate::defaultSslOptions);
 }
 
 /*!
index a711eeb..59078ae 100644 (file)
@@ -83,7 +83,7 @@ public:
         : protocol(QSsl::SecureProtocols),
           peerVerifyMode(QSslSocket::AutoVerifyPeer),
           peerVerifyDepth(0),
-          sslOptions(QSsl::SslOptionDisableEmptyFragments|QSsl::SslOptionDisableLegacyRenegotiation)
+          sslOptions(QSslConfigurationPrivate::defaultSslOptions)
     { }
 
     QSslCertificate peerCertificate;
@@ -101,6 +101,8 @@ public:
 
     QSsl::SslOptions sslOptions;
 
+    Q_AUTOTEST_EXPORT static const QSsl::SslOptions defaultSslOptions;
+
     // in qsslsocket.cpp:
     static QSslConfiguration defaultConfiguration();
     static void setDefaultConfiguration(const QSslConfiguration &configuration);
index e742c22..378aff9 100644 (file)
@@ -58,6 +58,7 @@
 #ifndef QT_NO_OPENSSL
 #include "private/qsslsocket_openssl_p.h"
 #include "private/qsslsocket_openssl_symbols_p.h"
+#include "private/qsslconfiguration_p.h"
 #endif
 
 #include "../../../network-settings.h"
@@ -2081,6 +2082,10 @@ void tst_QSslSocket::sslOptions()
         return;
 
     QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
+                                                           QSslConfigurationPrivate::defaultSslOptions),
+             long(SSL_OP_ALL|SSL_OP_NO_SSLv2));
+
+    QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
                                                            QSsl::SslOptionDisableEmptyFragments
                                                            |QSsl::SslOptionDisableLegacyRenegotiation),
              long(SSL_OP_ALL|SSL_OP_NO_SSLv2));