QSslCipher - improve its code coverage and auto-tests
tst_qsslcipher was quite useless - now we test that default constructed QSslCipher reports expected values. Test the non-default from the different auto-test, where we are sure we have really useful ciphersuites (with different parameters obtained from a TLS backend, where it's possible). Pick-to: 6.0 Pick-to: 5.15 Change-Id: Iff14a0580fed889cf9e0873bee01d968773626db Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
b119b17717
commit
1a2e2921d2
@ -30,9 +30,6 @@
|
|||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <qsslcipher.h>
|
#include <qsslcipher.h>
|
||||||
|
|
||||||
#include <QtNetwork/qhostaddress.h>
|
|
||||||
#include <QtNetwork/qnetworkproxy.h>
|
|
||||||
|
|
||||||
class tst_QSslCipher : public QObject
|
class tst_QSslCipher : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -50,6 +47,15 @@ private slots:
|
|||||||
void tst_QSslCipher::constructing()
|
void tst_QSslCipher::constructing()
|
||||||
{
|
{
|
||||||
QSslCipher cipher;
|
QSslCipher cipher;
|
||||||
|
|
||||||
|
QVERIFY(cipher.isNull());
|
||||||
|
QCOMPARE(cipher.name(), QString());
|
||||||
|
QCOMPARE(cipher.supportedBits(), 0);
|
||||||
|
QCOMPARE(cipher.usedBits(), 0);
|
||||||
|
QCOMPARE(cipher.keyExchangeMethod(), QString());
|
||||||
|
QCOMPARE(cipher.authenticationMethod(), QString());
|
||||||
|
QCOMPARE(cipher.protocolString(), QString());
|
||||||
|
QCOMPARE(cipher.protocol(), QSsl::UnknownProtocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QT_NO_SSL
|
#endif // QT_NO_SSL
|
||||||
|
@ -164,9 +164,6 @@ private slots:
|
|||||||
// API tests
|
// API tests
|
||||||
void sslErrors_data();
|
void sslErrors_data();
|
||||||
void sslErrors();
|
void sslErrors();
|
||||||
void addCaCertificate();
|
|
||||||
void addCaCertificates();
|
|
||||||
void addCaCertificates2();
|
|
||||||
void ciphers();
|
void ciphers();
|
||||||
void connectToHostEncrypted();
|
void connectToHostEncrypted();
|
||||||
void connectToHostEncryptedWithVerificationPeerName();
|
void connectToHostEncryptedWithVerificationPeerName();
|
||||||
@ -796,29 +793,18 @@ void tst_QSslSocket::sslErrors()
|
|||||||
QCOMPARE(sslErrors, peerErrors);
|
QCOMPARE(sslErrors, peerErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSslSocket::addCaCertificate()
|
|
||||||
{
|
|
||||||
if (!QSslSocket::supportsSsl())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QSslSocket::addCaCertificates()
|
|
||||||
{
|
|
||||||
if (!QSslSocket::supportsSsl())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QSslSocket::addCaCertificates2()
|
|
||||||
{
|
|
||||||
if (!QSslSocket::supportsSsl())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QSslSocket::ciphers()
|
void tst_QSslSocket::ciphers()
|
||||||
{
|
{
|
||||||
if (!QSslSocket::supportsSsl())
|
if (!QSslSocket::supportsSsl())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QFETCH_GLOBAL(const bool, setProxy);
|
||||||
|
if (setProxy) {
|
||||||
|
// KISS(mart), we don't connect, no need to test the same thing
|
||||||
|
// many times!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QSslSocket socket;
|
QSslSocket socket;
|
||||||
QCOMPARE(socket.sslConfiguration().ciphers(), QSslConfiguration::defaultConfiguration().ciphers());
|
QCOMPARE(socket.sslConfiguration().ciphers(), QSslConfiguration::defaultConfiguration().ciphers());
|
||||||
|
|
||||||
@ -863,6 +849,16 @@ void tst_QSslSocket::ciphers()
|
|||||||
sslConfig.setCiphers(ciphers);
|
sslConfig.setCiphers(ciphers);
|
||||||
socket.setSslConfiguration(sslConfig);
|
socket.setSslConfiguration(sslConfig);
|
||||||
QCOMPARE(ciphers, socket.sslConfiguration().ciphers());
|
QCOMPARE(ciphers, socket.sslConfiguration().ciphers());
|
||||||
|
|
||||||
|
#ifndef QT_NO_OPENSSL
|
||||||
|
for (const auto &cipher : ciphers) {
|
||||||
|
if (cipher.name().size() && cipher.protocol() != QSsl::UnknownProtocol) {
|
||||||
|
const QSslCipher aCopy(cipher.name(), cipher.protocol());
|
||||||
|
QCOMPARE(aCopy, cipher);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // QT_NO_OPENSSL
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSslSocket::connectToHostEncrypted()
|
void tst_QSslSocket::connectToHostEncrypted()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user