summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2021-06-08 12:36:20 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2021-06-08 16:17:23 +0200
commit096b1860047194765d9be4d44e48c12150969013 (patch)
tree7cbc92e41e2dc3ebd4a7a3737958784a96d67bdf /tests
parentf6fa4b39ee32ba4a5c6a3db5581dd50b3afc7a47 (diff)
tst_QNetworkReply::ignoreSslErrorsList, use the right error
The error that the actual runtime will encounter, and not the one that compile-time ifdefs will (potentially) erroneously select. Change-Id: I8ef4c34bcb8b3e568bc39f8c8ea6bfb7732f9e27 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index a9c6b2d6ec..287b6d90bd 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -92,14 +92,6 @@ 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*)
#if QT_CONFIG(networkproxy)
Q_DECLARE_METATYPE(QNetworkProxyQuery)
@@ -527,6 +519,9 @@ private:
bool notEnoughDataForFastSender;
bool ftpSupported = false;
+#if QT_CONFIG(ssl)
+ QSslError::SslError flukeCertTlsError = QSslError::CertificateUntrusted;
+#endif
};
const QByteArray tst_QNetworkReply::httpEmpty200Response =
@@ -1589,6 +1584,9 @@ void tst_QNetworkReply::initTestCase()
cleanupTestData();
#if QT_CONFIG(ssl)
QT_PREPEND_NAMESPACE(qt_ForceTlsSecurityLevel)();
+
+ if (QSslSocket::activeBackend() == QStringLiteral("openssl"))
+ flukeCertTlsError = QSslError::SelfSignedCertificate;
#endif
}
@@ -6408,8 +6406,8 @@ void tst_QNetworkReply::ignoreSslErrorsList_data()
QList<QSslError> expectedSslErrors;
QList<QSslCertificate> certs = QSslCertificate::fromPath(testDataDir + certsFilePath);
- QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
- QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
+ QSslError rightError(flukeCertTlsError, certs.at(0));
+ QSslError wrongError(flukeCertTlsError);
QTest::newRow("SSL-failure-empty-list") << expectedSslErrors << QNetworkReply::SslHandshakeFailedError;
expectedSslErrors.append(wrongError);