ssl: fix QNAM self-signed certificate test for non-OpenSSL backends

Non-OpenSSL backends are not able to report a specific error code
for self-signed certificates.

Change-Id: I56bf130335b2afa65cf2bd5248a40ac0e32f74c2
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Jeremy Lainé 2015-07-28 07:31:07 -07:00
parent c2406341fc
commit 2d43f8b79b

View File

@ -88,6 +88,14 @@ Q_DECLARE_METATYPE(QSharedPointer<char>)
#include "../../../network-settings.h"
// Non-OpenSSL backends are not able to report a specific error code
// for self-signed certificates.
#ifndef QT_NO_OPENSSL
#define FLUKE_CERTIFICATE_ERROR QSslError::SelfSignedCertificate
#else
#define FLUKE_CERTIFICATE_ERROR QSslError::CertificateUntrusted
#endif
Q_DECLARE_METATYPE(QAuthenticator*)
#ifndef QT_NO_NETWORKPROXY
Q_DECLARE_METATYPE(QNetworkProxyQuery)
@ -6027,8 +6035,8 @@ void tst_QNetworkReply::ignoreSslErrorsList_data()
QList<QSslError> expectedSslErrors;
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + "/certs/qt-test-server-cacert.pem");
QSslError rightError(QSslError::SelfSignedCertificate, certs.at(0));
QSslError wrongError(QSslError::SelfSignedCertificate);
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
QTest::newRow("SSL-failure-empty-list") << "https://" + QtNetworkSettings::serverName() + "/index.html" << expectedSslErrors << QNetworkReply::SslHandshakeFailedError;
expectedSslErrors.append(wrongError);