Fix auto-tests that are fooled by the presence of more than one plugin
It's possible that Qt is built with OpenSSL and some other backend. The ifdefs generated are not mutually exclusive anymore, as it was in the past. So tests should rely on the actual backend they have working at runtime. In the process of fixing the auto-tests, modernized feature #if-ery and some associated compilation issues. Fixes: QTBUG-92875 Change-Id: I2be1b924d506fd36dc4e2c6c9158b5023ff87f32 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>bb10
parent
71d242c6d3
commit
810e755c18
|
|
@ -69,7 +69,7 @@
|
|||
#include <QtNetwork/QHttpPart>
|
||||
#include <QtNetwork/QHttpMultiPart>
|
||||
#include <QtNetwork/QNetworkProxyQuery>
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
#include <QtNetwork/qsslerror.h>
|
||||
#include <QtNetwork/qsslconfiguration.h>
|
||||
#include <QtNetwork/qsslsocket.h>
|
||||
|
|
@ -101,7 +101,7 @@ Q_DECLARE_METATYPE(QSharedPointer<char>)
|
|||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(QAuthenticator*)
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
Q_DECLARE_METATYPE(QNetworkProxyQuery)
|
||||
#endif
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ class tst_QNetworkReply: public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
struct ProxyData
|
||||
{
|
||||
ProxyData(const QNetworkProxy &p, const QByteArray &t, bool auth)
|
||||
|
|
@ -128,7 +128,7 @@ class tst_QNetworkReply: public QObject
|
|||
QNetworkProxy proxy;
|
||||
bool requiresAuthentication;
|
||||
};
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
static bool seedCreated;
|
||||
static QString createUniqueExtension()
|
||||
|
|
@ -161,7 +161,7 @@ class tst_QNetworkReply: public QObject
|
|||
QString wronlyFileName;
|
||||
#endif
|
||||
QString uniqueExtension;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QList<ProxyData> proxies;
|
||||
#endif
|
||||
QNetworkAccessManager manager;
|
||||
|
|
@ -170,10 +170,9 @@ class tst_QNetworkReply: public QObject
|
|||
QSslConfiguration storedSslConfiguration;
|
||||
QList<QSslError> storedExpectedSslErrors;
|
||||
static const QString certsFilePath;
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
bool isSecureTransport = false;
|
||||
bool isSchannel = false;
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
using QObject::connect;
|
||||
static bool connect(const QNetworkReplyPtr &ptr, const char *signal, const QObject *receiver, const char *slot, Qt::ConnectionType ct = Qt::AutoConnection)
|
||||
|
|
@ -201,7 +200,7 @@ public Q_SLOTS:
|
|||
void pipeliningHelperSlot();
|
||||
void emitErrorForAllRepliesSlot();
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void sslErrors(QNetworkReply*,const QList<QSslError> &);
|
||||
void storeSslConfiguration();
|
||||
void ignoreSslErrorListSlot(QNetworkReply *reply, const QList<QSslError> &);
|
||||
|
|
@ -234,10 +233,10 @@ private Q_SLOTS:
|
|||
void getFromHttp();
|
||||
void getErrors_data();
|
||||
void getErrors();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void headFromHttp_data();
|
||||
void headFromHttp();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
void putToFile_data();
|
||||
void putToFile();
|
||||
void putToFtp_data();
|
||||
|
|
@ -256,7 +255,7 @@ private Q_SLOTS:
|
|||
void postToHttpMultipart_data();
|
||||
void postToHttpMultipart();
|
||||
void multipartSkipIndices(); // QTBUG-32534
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void putToHttps_data();
|
||||
void putToHttps();
|
||||
void putToHttpsSynchronous_data();
|
||||
|
|
@ -295,12 +294,12 @@ private Q_SLOTS:
|
|||
void ioGetFromHttpWithAuth_data();
|
||||
void ioGetFromHttpWithAuth();
|
||||
void ioGetFromHttpWithAuthSynchronous();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void ioGetFromHttpWithProxyAuth();
|
||||
void ioGetFromHttpWithProxyAuthSynchronous();
|
||||
void ioGetFromHttpWithSocksProxy();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#ifndef QT_NO_SSL
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
#if QT_CONFIG(ssl)
|
||||
void ioGetFromHttpsWithSslErrors();
|
||||
void ioGetFromHttpsWithIgnoreSslErrors();
|
||||
void ioGetFromHttpsWithSslHandshakeError();
|
||||
|
|
@ -314,10 +313,10 @@ private Q_SLOTS:
|
|||
void ioGetFromHttpWithCache_data();
|
||||
void ioGetFromHttpWithCache();
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void ioGetWithManyProxies_data();
|
||||
void ioGetWithManyProxies();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
void ioPutToFileFromFile_data();
|
||||
void ioPutToFileFromFile();
|
||||
|
|
@ -333,12 +332,12 @@ private Q_SLOTS:
|
|||
void ioPutToHttpFromFile();
|
||||
void ioPostToHttpFromFile_data();
|
||||
void ioPostToHttpFromFile();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void ioPostToHttpFromSocket_data();
|
||||
void ioPostToHttpFromSocket();
|
||||
void ioPostToHttpFromSocketSynchronous();
|
||||
void ioPostToHttpFromSocketSynchronous_data();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
void ioPostToHttpFromMiddleOfFileToEnd();
|
||||
void ioPostToHttpFromMiddleOfFileFiveBytes();
|
||||
void ioPostToHttpFromMiddleOfQBufferFiveBytes();
|
||||
|
|
@ -378,13 +377,13 @@ private Q_SLOTS:
|
|||
|
||||
void nestedEventLoops();
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void httpProxyCommands_data();
|
||||
void httpProxyCommands();
|
||||
void httpProxyCommandsSynchronous_data();
|
||||
void httpProxyCommandsSynchronous();
|
||||
void proxyChange();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
void authorizationError_data();
|
||||
void authorizationError();
|
||||
|
||||
|
|
@ -398,7 +397,7 @@ private Q_SLOTS:
|
|||
|
||||
void httpRecursiveCreation();
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void ioPostToHttpsUploadProgress();
|
||||
void ignoreSslErrorsList_data();
|
||||
void ignoreSslErrorsList();
|
||||
|
|
@ -455,7 +454,7 @@ private Q_SLOTS:
|
|||
|
||||
void synchronousRequest_data();
|
||||
void synchronousRequest();
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void synchronousRequestSslFailure();
|
||||
#endif
|
||||
|
||||
|
|
@ -464,11 +463,11 @@ private Q_SLOTS:
|
|||
void dontInsertPartialContentIntoTheCache();
|
||||
|
||||
void httpUserAgent();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void authenticationCacheAfterCancel_data();
|
||||
void authenticationCacheAfterCancel();
|
||||
void authenticationWithDifferentRealm();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
void synchronousAuthenticationCache();
|
||||
void pipelining();
|
||||
|
||||
|
|
@ -504,7 +503,7 @@ private Q_SLOTS:
|
|||
void ioHttpRedirectCustom();
|
||||
void ioHttpRedirectWithUploadDevice_data();
|
||||
void ioHttpRedirectWithUploadDevice();
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void putWithServerClosingConnectionImmediately();
|
||||
#endif
|
||||
|
||||
|
|
@ -554,7 +553,7 @@ static bool validateRedirectedResponseHeaders(QNetworkReplyPtr reply)
|
|||
&& !reply->header(QNetworkRequest::LocationHeader).isValid();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
static void setupSslServer(QSslSocket* serverSocket)
|
||||
{
|
||||
QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath();
|
||||
|
|
@ -580,7 +579,7 @@ const QString tst_QNetworkReply::certsFilePath = "/certs/qt-test-server-host-net
|
|||
const QString tst_QNetworkReply::certsFilePath = "/certs/qt-test-server-cacert.pem";
|
||||
#endif
|
||||
|
||||
#endif // !QT_NO_SSL
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
// NOTE: MiniHttpServer has a very limited support of PUT/POST requests! Make
|
||||
// sure you understand the server's code before PUTting/POSTing data (and
|
||||
|
|
@ -638,7 +637,7 @@ protected:
|
|||
void incomingConnection(qintptr socketDescriptor) override
|
||||
{
|
||||
//qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6;
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
if (doSsl) {
|
||||
QSslSocket *serverSocket = new QSslSocket(this);
|
||||
if (!serverSocket->setSocketDescriptor(socketDescriptor)) {
|
||||
|
|
@ -699,7 +698,7 @@ private:
|
|||
}
|
||||
|
||||
private slots:
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void slotSslErrors(const QList<QSslError>& errors)
|
||||
{
|
||||
QTcpSocket *currentClient = qobject_cast<QTcpSocket *>(sender());
|
||||
|
|
@ -770,7 +769,7 @@ public:
|
|||
{ QNetworkCookieJar::setAllCookies(cookieList); }
|
||||
};
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
class MyProxyFactory: public QNetworkProxyFactory
|
||||
{
|
||||
public:
|
||||
|
|
@ -793,7 +792,7 @@ public:
|
|||
return toReturn;
|
||||
}
|
||||
};
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
class MyMemoryCache: public QAbstractNetworkCache
|
||||
{
|
||||
|
|
@ -1006,7 +1005,7 @@ public:
|
|||
}
|
||||
virtual void incomingConnection(qintptr socketDescriptor) override
|
||||
{
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
if (doSsl) {
|
||||
QSslSocket *serverSocket = new QSslSocket;
|
||||
serverSocket->setParent(this);
|
||||
|
|
@ -1022,7 +1021,7 @@ public:
|
|||
}
|
||||
private slots:
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void slotSslErrors(const QList<QSslError>& errors)
|
||||
{
|
||||
qDebug() << "slotSslErrors" << sslSocket->errorString() << errors;
|
||||
|
|
@ -1292,7 +1291,7 @@ tst_QNetworkReply::tst_QNetworkReply()
|
|||
{
|
||||
qRegisterMetaType<QNetworkReply *>(); // for QSignalSpy
|
||||
qRegisterMetaType<QAuthenticator *>();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
qRegisterMetaType<QNetworkProxy>();
|
||||
#endif
|
||||
|
||||
|
|
@ -1310,7 +1309,7 @@ tst_QNetworkReply::tst_QNetworkReply()
|
|||
cookieJar = new MyCookieJar;
|
||||
manager.setCookieJar(cookieJar);
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName());
|
||||
|
||||
proxies << ProxyData(QNetworkProxy::NoProxy, "", false);
|
||||
|
|
@ -1329,13 +1328,13 @@ tst_QNetworkReply::tst_QNetworkReply()
|
|||
<< ProxyData(QNetworkProxy(QNetworkProxy::Socks5Proxy, socksProxy, 1081),
|
||||
"+socksauth", true);
|
||||
} else {
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
fprintf(stderr, "==================================================================\n");
|
||||
fprintf(stderr, "Proxy could not be looked up. No proxy will be used while testing!\n");
|
||||
fprintf(stderr, "==================================================================\n");
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
ftpSupported = manager.supportedSchemes().contains("ftp");
|
||||
}
|
||||
|
|
@ -1357,7 +1356,7 @@ void tst_QNetworkReply::proxyAuthenticationRequired(const QNetworkProxy &, QAuth
|
|||
auth->setPassword("password");
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void tst_QNetworkReply::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||
{
|
||||
reply->ignoreSslErrors();
|
||||
|
|
@ -1579,7 +1578,7 @@ void tst_QNetworkReply::initTestCase()
|
|||
#endif
|
||||
|
||||
QDir::setSearchPaths("testdata", QStringList() << testDataDir);
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QSslConfiguration::defaultConfiguration().caCertificates(); //preload certificates
|
||||
#endif
|
||||
|
||||
|
|
@ -1608,7 +1607,7 @@ void tst_QNetworkReply::cleanupTestData()
|
|||
|
||||
// clear the internal cache
|
||||
manager.clearAccessCache();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
manager.setProxy(QNetworkProxy());
|
||||
#endif
|
||||
manager.setCache(0);
|
||||
|
|
@ -1617,7 +1616,7 @@ void tst_QNetworkReply::cleanupTestData()
|
|||
cookieJar->setAllCookies(QList<QNetworkCookie>());
|
||||
|
||||
// disconnect manager signals
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
manager.disconnect(SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
|
||||
|
|
@ -1956,7 +1955,7 @@ void tst_QNetworkReply::getFromHttp()
|
|||
QCOMPARE(reply->readAll(), reference.readAll());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::headFromHttp_data()
|
||||
{
|
||||
QTest::addColumn<qint64>("referenceSize");
|
||||
|
|
@ -2045,7 +2044,7 @@ void tst_QNetworkReply::headFromHttp()
|
|||
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
|
||||
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toString(), contentType);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
void tst_QNetworkReply::getErrors_data()
|
||||
{
|
||||
|
|
@ -2788,7 +2787,7 @@ void tst_QNetworkReply::putToHttpMultipart()
|
|||
QCOMPARE(replyData, expectedReplyData);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void tst_QNetworkReply::putToHttps_data()
|
||||
{
|
||||
if (isSecureTransport)
|
||||
|
|
@ -3005,7 +3004,7 @@ void tst_QNetworkReply::postToHttpsMultipart()
|
|||
QCOMPARE(replyData, expectedReplyData);
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
void tst_QNetworkReply::deleteFromHttp_data()
|
||||
{
|
||||
|
|
@ -3651,7 +3650,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous()
|
|||
QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 401);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
|
||||
{
|
||||
// This test sends three requests
|
||||
|
|
@ -3814,9 +3813,9 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
|
|||
QCOMPARE(authspy.count(), 0);
|
||||
}
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void tst_QNetworkReply::ioGetFromHttpsWithSslErrors()
|
||||
{
|
||||
QFile reference(testDataDir + "/rfc3252.txt");
|
||||
|
|
@ -4203,7 +4202,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache()
|
|||
QCOMPARE(reply->readAll().constData(), qPrintable(body));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::ioGetWithManyProxies_data()
|
||||
{
|
||||
QTest::addColumn<QList<QNetworkProxy> >("proxyList");
|
||||
|
|
@ -4264,7 +4263,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
|
|||
<< QNetworkReply::NoError;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
// HTTPS with HTTP transparent proxy
|
||||
proxyList.clear();
|
||||
proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3129);
|
||||
|
|
@ -4314,7 +4313,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
|
|||
<< QNetworkReply::ProxyNotFoundError;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
// HTTPS with HTTP caching proxy
|
||||
proxyList.clear();
|
||||
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129);
|
||||
|
|
@ -4393,7 +4392,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
|
|||
<< QNetworkReply::NoError;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
// HTTPS request with HTTP Caching + HTTP transparent
|
||||
proxyList.clear();
|
||||
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129)
|
||||
|
|
@ -4437,7 +4436,7 @@ void tst_QNetworkReply::ioGetWithManyProxies()
|
|||
QSignalSpy authspy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
|
||||
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
|
||||
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
|
|
@ -4446,7 +4445,7 @@ void tst_QNetworkReply::ioGetWithManyProxies()
|
|||
|
||||
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
|
||||
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
manager.disconnect(SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
|
|
@ -4478,7 +4477,7 @@ void tst_QNetworkReply::ioGetWithManyProxies()
|
|||
QCOMPARE(authspy.count(), 0);
|
||||
}
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
void tst_QNetworkReply::ioPutToFileFromFile_data()
|
||||
{
|
||||
|
|
@ -4775,7 +4774,7 @@ void tst_QNetworkReply::ioPostToHttpFromFile()
|
|||
QCOMPARE(reply->readAll().trimmed(), md5sum(sourceFile.readAll()).toHex());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::ioPostToHttpFromSocket_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("data");
|
||||
|
|
@ -4926,7 +4925,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous()
|
|||
|
||||
QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex());
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
// this tests checks if rewinding the POST-data to some place in the middle
|
||||
// worked.
|
||||
|
|
@ -5043,7 +5042,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
|
|||
QCOMPARE(reply->error(), QNetworkReply::ContentReSendError);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
class SslServer : public QTcpServer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -5159,7 +5158,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp_data()
|
|||
QTest::addColumn<int>("bufferSize");
|
||||
QTest::newRow("http+unlimited") << false << 0;
|
||||
QTest::newRow("http+limited") << false << 4096;
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QTest::newRow("https+unlimited") << true << 0;
|
||||
QTest::newRow("https+limited") << true << 4096;
|
||||
#endif
|
||||
|
|
@ -5919,7 +5918,7 @@ void tst_QNetworkReply::nestedEventLoops()
|
|||
QCOMPARE(errorspy.count(), 0);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::httpProxyCommands_data()
|
||||
{
|
||||
QTest::addColumn<QUrl>("url");
|
||||
|
|
@ -5930,7 +5929,7 @@ void tst_QNetworkReply::httpProxyCommands_data()
|
|||
<< QUrl("http://0.0.0.0:4443/http-request")
|
||||
<< QByteArray("HTTP/1.0 200 OK\r\nProxy-Connection: close\r\nContent-Length: 1\r\n\r\n1")
|
||||
<< "GET http://0.0.0.0:4443/http-request HTTP/1.";
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QTest::newRow("https")
|
||||
<< QUrl("https://0.0.0.0:4443/https-request")
|
||||
<< QByteArray("HTTP/1.0 200 Connection Established\r\n\r\n")
|
||||
|
|
@ -5992,7 +5991,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous_data()
|
|||
{
|
||||
httpProxyCommands_data();
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
struct QThreadCleanup
|
||||
{
|
||||
|
|
@ -6014,7 +6013,7 @@ struct QDeleteLaterCleanup
|
|||
}
|
||||
};
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::httpProxyCommandsSynchronous()
|
||||
{
|
||||
QFETCH(QUrl, url);
|
||||
|
|
@ -6104,7 +6103,7 @@ void tst_QNetworkReply::proxyChange()
|
|||
|
||||
QVERIFY(int(reply3->error()) > 0);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
void tst_QNetworkReply::authorizationError_data()
|
||||
{
|
||||
|
|
@ -6401,7 +6400,7 @@ void tst_QNetworkReply::httpRecursiveCreation()
|
|||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void tst_QNetworkReply::ignoreSslErrorsList_data()
|
||||
{
|
||||
QTest::addColumn<QList<QSslError> >("expectedSslErrors");
|
||||
|
|
@ -6690,7 +6689,7 @@ void tst_QNetworkReply::sslSessionSharingFromPersistentSession()
|
|||
}
|
||||
|
||||
#endif // QT_BUILD_INTERNAL
|
||||
#endif // QT_NO_SSL
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
void tst_QNetworkReply::getAndThenDeleteObject_data()
|
||||
{
|
||||
|
|
@ -7125,7 +7124,7 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication()
|
|||
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QNetworkReply::authenticationCacheAfterCancel_data()
|
||||
{
|
||||
QTest::addColumn<QNetworkProxy>("proxy");
|
||||
|
|
@ -7136,7 +7135,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel_data()
|
|||
<< proxies.at(i).proxy
|
||||
<< proxies.at(i).requiresAuthentication
|
||||
<< QUrl("http://" + QtNetworkSettings::httpServerName() + "/qtest/rfcs-auth/rfc3252.txt");
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QTest::newRow("https" + proxies.at(i).tag)
|
||||
<< proxies.at(i).proxy
|
||||
<< proxies.at(i).requiresAuthentication
|
||||
|
|
@ -7192,7 +7191,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel()
|
|||
QFETCH(bool, proxyAuth);
|
||||
QFETCH(QUrl, url);
|
||||
QNetworkAccessManager manager;
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
|
|
@ -7319,7 +7318,7 @@ void tst_QNetworkReply::authenticationWithDifferentRealm()
|
|||
{
|
||||
AuthenticationCacheHelper helper;
|
||||
QNetworkAccessManager manager;
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
|
||||
SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
|
||||
#endif
|
||||
|
|
@ -7346,7 +7345,7 @@ void tst_QNetworkReply::authenticationWithDifferentRealm()
|
|||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
QCOMPARE(reply->error(), QNetworkReply::NoError);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
class QtBug13431Helper : public QObject
|
||||
{
|
||||
|
|
@ -7795,7 +7794,7 @@ void tst_QNetworkReply::synchronousRequest()
|
|||
|
||||
QNetworkRequest request(url);
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
// workaround for HTTPS requests: add self-signed server cert to list of CA certs,
|
||||
// since we cannot react to the sslErrors() signal
|
||||
// to fix this properly we would need to have an ignoreSslErrors() method in the
|
||||
|
|
@ -7840,7 +7839,7 @@ void tst_QNetworkReply::synchronousRequest()
|
|||
reply->deleteLater();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void tst_QNetworkReply::synchronousRequestSslFailure()
|
||||
{
|
||||
// test that SSL won't be accepted with self-signed certificate,
|
||||
|
|
@ -8951,7 +8950,7 @@ void tst_QNetworkReply::ioHttpRedirectWithUploadDevice()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
class PutWithServerClosingConnectionImmediatelyHandler: public QObject
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
|
|
@ -47,6 +47,8 @@
|
|||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#include "../shared/tlshelpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -169,6 +171,9 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
void tst_QDtls::initTestCase()
|
||||
{
|
||||
if (!TlsAux::activeBackendSupportsDtls())
|
||||
QSKIP("The active TLS backend does not support DTLS");
|
||||
|
||||
certDirPath = QFileInfo(QFINDTESTDATA("certs")).absolutePath();
|
||||
QVERIFY(certDirPath.size() > 0);
|
||||
certDirPath += QDir::separator() + QStringLiteral("certs") + QDir::separator();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
|
|
@ -29,6 +29,8 @@
|
|||
#include <QTest>
|
||||
#include <QTestEventLoop>
|
||||
|
||||
#include "../shared/tlshelpers.h"
|
||||
|
||||
#include <QtNetwork/qhostaddress.h>
|
||||
#include <QtNetwork/qsslsocket.h>
|
||||
#include <QtNetwork/qudpsocket.h>
|
||||
|
|
@ -139,6 +141,9 @@ QHostAddress tst_QDtlsCookie::toNonAny(const QHostAddress &addr)
|
|||
|
||||
void tst_QDtlsCookie::initTestCase()
|
||||
{
|
||||
if (!TlsAux::activeBackendSupportsDtls())
|
||||
QSKIP("The active TLS backend does not support DTLS");
|
||||
|
||||
QVERIFY(noiseMaker.bind());
|
||||
spammerAddress = toNonAny(noiseMaker.localAddress());
|
||||
spammerPort = noiseMaker.localPort();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include <QTest>
|
||||
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
|
||||
#include <qsslcertificate.h>
|
||||
#include <qsslkey.h>
|
||||
#include <qsslsocket.h>
|
||||
|
|
@ -59,14 +61,14 @@ class tst_QSslCertificate : public QObject
|
|||
QMap<QString, QString> sha1Map;
|
||||
|
||||
void createTestRows();
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
void compareCertificates(const QSslCertificate & cert1, const QSslCertificate & cert2);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
private slots:
|
||||
void hash();
|
||||
void emptyConstructor();
|
||||
|
|
@ -118,7 +120,7 @@ private slots:
|
|||
|
||||
// ### add tests for certificate bundles (multiple certificates concatenated into a single
|
||||
// structure); both PEM and DER formatted
|
||||
#endif
|
||||
#endif // QT_CONFIG(ssl)
|
||||
private:
|
||||
QString testDataDir;
|
||||
bool isNonOpenSslTls = false;
|
||||
|
|
@ -134,7 +136,7 @@ void tst_QSslCertificate::initTestCase()
|
|||
#if QT_CONFIG(opensslv11)
|
||||
// In the presence of 'openssl' backend, QSslSocket will
|
||||
// select 'openssl' as the default one.
|
||||
isNonOpenSslTls = false;
|
||||
isNonOpenSslTls = QSslSocket::activeBackend() != QStringLiteral("openssl");
|
||||
#else
|
||||
isNonOpenSslTls = true;
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
|
@ -164,7 +166,7 @@ void tst_QSslCertificate::initTestCase()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
void tst_QSslCertificate::hash()
|
||||
{
|
||||
|
|
@ -474,10 +476,9 @@ void tst_QSslCertificate::subjectInfoToString()
|
|||
QVERIFY(testInfo(QSslCertificate::StateOrProvinceName, QStringLiteral("Oslo")));
|
||||
QVERIFY(testInfo(QSslCertificate::DistinguishedNameQualifier, QString()));
|
||||
QVERIFY(testInfo(QSslCertificate::SerialNumber, QString()));
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// TODO: check why generic code does not handle this!
|
||||
QVERIFY(testInfo(QSslCertificate::EmailAddress, QStringLiteral("ababic@trolltech.com")));
|
||||
#endif
|
||||
if (!isNonOpenSslTls)
|
||||
QVERIFY(testInfo(QSslCertificate::EmailAddress, QStringLiteral("ababic@trolltech.com")));
|
||||
}
|
||||
|
||||
void tst_QSslCertificate::subjectIssuerDisplayName_data()
|
||||
|
|
@ -983,6 +984,9 @@ void tst_QSslCertificate::selfsignedCertificates()
|
|||
|
||||
void tst_QSslCertificate::toText()
|
||||
{
|
||||
if (isNonOpenSslTls)
|
||||
QSKIP("QSslCertificate::toText is not implemented on platforms which do not use openssl");
|
||||
|
||||
QList<QSslCertificate> certList =
|
||||
QSslCertificate::fromPath(testDataDir + "more-certificates/cert-large-expiration-date.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString);
|
||||
|
||||
|
|
@ -1013,9 +1017,6 @@ void tst_QSslCertificate::toText()
|
|||
|
||||
QString txtcert = cert.toText();
|
||||
|
||||
#ifdef QT_NO_OPENSSL
|
||||
QEXPECT_FAIL("", "QSslCertificate::toText is not implemented on platforms which do not use openssl", Continue);
|
||||
#endif
|
||||
QVERIFY(QString::fromLatin1(txt098) == txtcert ||
|
||||
QString::fromLatin1(txt100) == txtcert ||
|
||||
QString::fromLatin1(txt101) == txtcert ||
|
||||
|
|
@ -1049,7 +1050,8 @@ void tst_QSslCertificate::subjectAndIssuerAttributes()
|
|||
|
||||
QByteArray shortName("1.3.6.1.4.1.311.60.2.1.3");
|
||||
#if !defined(QT_NO_OPENSSL) && defined(SN_jurisdictionCountryName)
|
||||
shortName = SN_jurisdictionCountryName;
|
||||
if (!isNonOpenSslTls)
|
||||
shortName = SN_jurisdictionCountryName;
|
||||
#endif
|
||||
attributes = certList[0].subjectInfoAttributes();
|
||||
QVERIFY(attributes.contains(shortName));
|
||||
|
|
@ -1407,9 +1409,9 @@ void tst_QSslCertificate::pkcs12()
|
|||
QSslCertificate cert;
|
||||
QList<QSslCertificate> caCerts;
|
||||
|
||||
#ifdef QT_NO_OPENSSL
|
||||
QEXPECT_FAIL("", "pkcs12 imports are only supported when openssl is used", Abort); // TODO?
|
||||
#endif
|
||||
if (isNonOpenSslTls)
|
||||
QEXPECT_FAIL("", "pkcs12 imports are only supported when openssl is used", Abort); // TODO?
|
||||
|
||||
ok = QSslCertificate::importPkcs12(&f, &key, &cert, &caCerts);
|
||||
QVERIFY(ok);
|
||||
f.close();
|
||||
|
|
@ -1485,7 +1487,7 @@ void tst_QSslCertificate::invalidDateTime()
|
|||
}
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
QTEST_MAIN(tst_QSslCertificate)
|
||||
#include "tst_qsslcertificate.moc"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
|
||||
#include <QSslDiffieHellmanParameters>
|
||||
#include <QSslSocket>
|
||||
#include <QByteArray>
|
||||
|
|
@ -42,8 +45,9 @@ class tst_QSslDiffieHellmanParameters : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void constructionEmpty();
|
||||
void constructionDefault();
|
||||
void constructionDER();
|
||||
|
|
@ -51,10 +55,16 @@ private Q_SLOTS:
|
|||
void unsafe512Bits();
|
||||
void unsafeNonPrime();
|
||||
void defaultIsValid();
|
||||
#endif
|
||||
#endif // Feature 'ssl'.
|
||||
};
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::initTestCase()
|
||||
{
|
||||
if (QSslSocket::activeBackend() != QStringLiteral("openssl"))
|
||||
QSKIP("The active TLS backend does not support QSslDiffieHellmanParameters");
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::constructionEmpty()
|
||||
{
|
||||
|
|
@ -69,10 +79,8 @@ void tst_QSslDiffieHellmanParameters::constructionDefault()
|
|||
{
|
||||
QSslDiffieHellmanParameters dh = QSslDiffieHellmanParameters::defaultParameters();
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isValid(), true);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::constructionDER()
|
||||
|
|
@ -91,10 +99,8 @@ void tst_QSslDiffieHellmanParameters::constructionDER()
|
|||
"52DcHKlsqDuafQ1XVGmzVIrKtBi2gfLtPqY4v6g6v26l8gbzK67PpWstllHiPb4VMCAQI="
|
||||
)), QSsl::Der);
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isValid(), true);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::constructionPEM()
|
||||
|
|
@ -116,10 +122,8 @@ void tst_QSslDiffieHellmanParameters::constructionPEM()
|
|||
"-----END DH PARAMETERS-----\n"
|
||||
), QSsl::Pem);
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isValid(), true);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::unsafe512Bits()
|
||||
|
|
@ -132,10 +136,8 @@ void tst_QSslDiffieHellmanParameters::unsafe512Bits()
|
|||
"-----END DH PARAMETERS-----\n"
|
||||
), QSsl::Pem);
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isValid(), false);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::UnsafeParametersError);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::unsafeNonPrime()
|
||||
|
|
@ -148,10 +150,8 @@ void tst_QSslDiffieHellmanParameters::unsafeNonPrime()
|
|||
"vholAW9zilkoYkB6sqwxY1Z2dbpTWajCsUAWZQ0AIP4Y5nesAgEC"
|
||||
)), QSsl::Der);
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isValid(), false);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::UnsafeParametersError);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSslDiffieHellmanParameters::defaultIsValid()
|
||||
|
|
@ -173,15 +173,13 @@ void tst_QSslDiffieHellmanParameters::defaultIsValid()
|
|||
|
||||
const auto defaultdh = QSslDiffieHellmanParameters::defaultParameters();
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QCOMPARE(dh.isEmpty(), false);
|
||||
QCOMPARE(dh.isValid(), true);
|
||||
QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError);
|
||||
QCOMPARE(dh, defaultdh);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
#endif // Feature 'ssl'.
|
||||
|
||||
QTEST_MAIN(tst_QSslDiffieHellmanParameters)
|
||||
#include "tst_qssldiffiehellmanparameters.moc"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@
|
|||
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
|
||||
#if QT_CONFIG(ssl)
|
||||
#include <QSslSocket>
|
||||
#endif // ssl
|
||||
|
||||
#include <QSslEllipticCurve>
|
||||
#include <QSslConfiguration>
|
||||
|
||||
|
|
@ -35,18 +42,27 @@ class tst_QSslEllipticCurve : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void constExpr();
|
||||
void construction();
|
||||
void fromShortName_data();
|
||||
void fromShortName();
|
||||
void fromLongName_data();
|
||||
void fromLongName();
|
||||
#endif
|
||||
#endif // Feature 'ssl'.
|
||||
};
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
void tst_QSslEllipticCurve::initTestCase()
|
||||
{
|
||||
// At the moment only OpenSSL backend properly supports
|
||||
// QSslEllipticCurve.
|
||||
if (QSslSocket::activeBackend() != QStringLiteral("openssl"))
|
||||
QSKIP("The active TLS backend does not support QSslEllipticCurve");
|
||||
}
|
||||
|
||||
void tst_QSslEllipticCurve::constExpr()
|
||||
{
|
||||
|
|
@ -127,7 +143,7 @@ void tst_QSslEllipticCurve::fromLongName()
|
|||
QCOMPARE(result.longName(), valid ? longName : QString());
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
#endif // Feature 'ssl'.
|
||||
|
||||
QTEST_MAIN(tst_QSslEllipticCurve)
|
||||
#include "tst_qsslellipticcurve.moc"
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@
|
|||
// TLSTODO: find another solution, for now this code
|
||||
// (OpenSSL specific) is a part of plugin, not in
|
||||
// QtNetwork anymore.
|
||||
//#ifndef QT_NO_OPENSSL
|
||||
// #include "private/qsslsocket_openssl_symbols_p.h"
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(ssl)
|
||||
|
|
@ -244,12 +242,12 @@ void tst_QSslKey::createPlainTestRows(bool pemOnly)
|
|||
continue; // Schannel treats RC2 as 128 bit
|
||||
}
|
||||
|
||||
#if QT_CONFIG(ssl) && defined(QT_NO_OPENSSL) // generic backend
|
||||
if (keyInfo.fileInfo.fileName().contains(QRegularExpression("-aes\\d\\d\\d-")))
|
||||
continue; // No AES support in the generic back-end
|
||||
if (keyInfo.fileInfo.fileName().contains("pkcs8-pkcs12"))
|
||||
continue; // The generic back-end doesn't support PKCS#12 algorithms
|
||||
#endif
|
||||
if (isSchannel || isSecureTransport) {
|
||||
if (keyInfo.fileInfo.fileName().contains(QRegularExpression("-aes\\d\\d\\d-")))
|
||||
continue; // No AES support in the generic back-end
|
||||
if (keyInfo.fileInfo.fileName().contains("pkcs8-pkcs12"))
|
||||
continue; // The generic back-end doesn't support PKCS#12 algorithms
|
||||
}
|
||||
|
||||
QTest::newRow(keyInfo.fileInfo.fileName().toLatin1())
|
||||
<< keyInfo.fileInfo.absoluteFilePath() << keyInfo.algorithm << keyInfo.type
|
||||
|
|
|
|||
|
|
@ -53,18 +53,10 @@
|
|||
#include "private/qiodevice_p.h" // for QIODEVICE_BUFFERSIZE
|
||||
|
||||
#include "../../../network-settings.h"
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#include "../shared/tlshelpers.h"
|
||||
|
||||
#include "private/qtlsbackend_p.h"
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
// TLSTODO:
|
||||
// Disabling tests requiring this - moving OpenSSL code into plugins,
|
||||
// find a workaround if needed.
|
||||
//#include "private/qsslsocket_openssl_symbols_p.h"
|
||||
#endif // QT_NO_OPENSSL
|
||||
|
||||
#include "private/qsslsocket_p.h"
|
||||
#include "private/qsslconfiguration_p.h"
|
||||
|
||||
|
|
@ -77,17 +69,9 @@ Q_DECLARE_METATYPE(QSsl::SslProtocol)
|
|||
Q_DECLARE_METATYPE(QSslSocket::PeerVerifyMode);
|
||||
typedef QSharedPointer<QSslSocket> QSslSocketPtr;
|
||||
|
||||
// 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 // QT_NO_OPENSSL
|
||||
|
||||
#endif // QT_NO_OPENSSL
|
||||
|
||||
// Detect ALPN (Application-Layer Protocol Negotiation) support
|
||||
// AUTOTESTTODO: fix the way we identify ALPN support, it now depends on
|
||||
// what TLS backend we managed to load, not compile time macros.
|
||||
#undef ALPN_SUPPORTED // Undef the variable first to be safe
|
||||
#if defined(OPENSSL_VERSION_NUMBER) && !defined(OPENSSL_NO_TLSEXT)
|
||||
#define ALPN_SUPPORTED 1
|
||||
|
|
@ -106,14 +90,13 @@ typedef QSharedPointer<QSslSocket> QSslSocketPtr;
|
|||
// Use this cipher to force PSK key sharing.
|
||||
// Also, it's a cipher w/o auth, to check that we emit the signals warning
|
||||
// about the identity of the peer.
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
static const QString PSK_CIPHER_WITHOUT_AUTH = QStringLiteral("PSK-AES256-CBC-SHA");
|
||||
static const quint16 PSK_SERVER_PORT = 4433;
|
||||
static const QByteArray PSK_CLIENT_PRESHAREDKEY = QByteArrayLiteral("\x1a\x2b\x3c\x4d\x5e\x6f");
|
||||
static const QByteArray PSK_SERVER_IDENTITY_HINT = QByteArrayLiteral("QtTestServerHint");
|
||||
static const QByteArray PSK_CLIENT_IDENTITY = QByteArrayLiteral("Client_identity");
|
||||
|
||||
#endif // !QT_NO_OPENSSL
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
void qt_ForceTlsSecurityLevel();
|
||||
|
|
@ -139,10 +122,10 @@ public:
|
|||
return QTestEventLoop::instance().timeout();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QSslSocketPtr newSocket();
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
enum PskConnectTestType {
|
||||
PskConnectDoNotHandlePsk,
|
||||
PskConnectEmptyCredentials,
|
||||
|
|
@ -153,19 +136,19 @@ public:
|
|||
PskConnectRightCredentialsVerifyPeer,
|
||||
PskConnectRightCredentialsDoNotVerifyPeer,
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
#endif // QT_CONFIG(openssl)
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
public slots:
|
||||
void initTestCase_data();
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
private slots:
|
||||
void activeBackend();
|
||||
void backends();
|
||||
|
|
@ -188,15 +171,15 @@ private slots:
|
|||
void peerCertificate();
|
||||
void peerCertificateChain();
|
||||
void privateKey();
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void privateKeyOpaque();
|
||||
#endif
|
||||
void protocol();
|
||||
void protocolServerSide_data();
|
||||
void protocolServerSide();
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void serverCipherPreferences();
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif
|
||||
void setCaCertificates();
|
||||
void setLocalCertificate();
|
||||
void localCertificateChain();
|
||||
|
|
@ -228,12 +211,12 @@ private slots:
|
|||
void waitForMinusOne();
|
||||
void verifyMode();
|
||||
void verifyDepth();
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void verifyAndDefaultConfiguration();
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif
|
||||
void disconnectFromHostWhenConnecting();
|
||||
void disconnectFromHostWhenConnected();
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void closeWhileEmittingSocketError();
|
||||
#endif
|
||||
void resetProxy();
|
||||
|
|
@ -252,10 +235,10 @@ private slots:
|
|||
void qtbug18498_peek();
|
||||
void qtbug18498_peek2();
|
||||
void dhServer();
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void dhServerCustomParamsNull();
|
||||
void dhServerCustomParams();
|
||||
#endif
|
||||
#endif // QT_CONFIG(openssl)
|
||||
void ecdhServer();
|
||||
void verifyClientCertificate_data();
|
||||
void verifyClientCertificate();
|
||||
|
|
@ -263,7 +246,7 @@ private slots:
|
|||
|
||||
void allowedProtocolNegotiation();
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void simplePskConnect_data();
|
||||
void simplePskConnect();
|
||||
void ephemeralServerKey_data();
|
||||
|
|
@ -272,7 +255,7 @@ private slots:
|
|||
void forwardReadChannelFinished();
|
||||
void signatureAlgorithm_data();
|
||||
void signatureAlgorithm();
|
||||
#endif
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
void unsupportedProtocols_data();
|
||||
void unsupportedProtocols();
|
||||
|
|
@ -325,7 +308,8 @@ private:
|
|||
bool isTestingOpenSsl = false;
|
||||
bool isTestingSecureTransport = false;
|
||||
bool isTestingSchannel = false;
|
||||
#endif // QT_NO_SSL
|
||||
QSslError::SslError flukeCertificateError = QSslError::CertificateUntrusted;
|
||||
#endif // QT_CONFIG(ssl)
|
||||
private:
|
||||
static int loopLevel;
|
||||
public:
|
||||
|
|
@ -355,11 +339,11 @@ public:
|
|||
};
|
||||
QString tst_QSslSocket::testDataDir;
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(ssl)
|
||||
#if QT_CONFIG(openssl)
|
||||
Q_DECLARE_METATYPE(tst_QSslSocket::PskConnectTestType)
|
||||
#endif
|
||||
#endif
|
||||
#endif // QT_CONFIG(openssl)
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
int tst_QSslSocket::loopLevel = 0;
|
||||
|
||||
|
|
@ -380,17 +364,18 @@ QString httpServerCertChainPath()
|
|||
|
||||
tst_QSslSocket::tst_QSslSocket()
|
||||
{
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
qRegisterMetaType<QList<QSslError> >("QList<QSslError>");
|
||||
qRegisterMetaType<QSslError>("QSslError");
|
||||
qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState");
|
||||
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
qRegisterMetaType<QSslPreSharedKeyAuthenticator *>();
|
||||
qRegisterMetaType<tst_QSslSocket::PskConnectTestType>();
|
||||
#endif
|
||||
#endif
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
#endif // QT_CONFIG(ssl)
|
||||
}
|
||||
|
||||
enum ProxyTests {
|
||||
|
|
@ -434,6 +419,7 @@ void tst_QSslSocket::initTestCase()
|
|||
const auto &tlsBackends = QSslSocket::availableBackends();
|
||||
if (tlsBackends.contains(QTlsBackend::builtinBackendNames[QTlsBackend::nameIndexOpenSSL])) {
|
||||
isTestingOpenSsl = true;
|
||||
flukeCertificateError = QSslError::SelfSignedCertificate;
|
||||
} else if (tlsBackends.contains(QTlsBackend::builtinBackendNames[QTlsBackend::nameIndexSchannel])) {
|
||||
isTestingSchannel = true;
|
||||
} else {
|
||||
|
|
@ -441,7 +427,7 @@ void tst_QSslSocket::initTestCase()
|
|||
isTestingSecureTransport = true;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
qDebug("Using SSL library %s (%ld)",
|
||||
qPrintable(QSslSocket::sslLibraryVersionString()),
|
||||
QSslSocket::sslLibraryVersionNumber());
|
||||
|
|
@ -458,14 +444,14 @@ void tst_QSslSocket::initTestCase()
|
|||
if (!QtNetworkSettings::verifyTestNetworkSettings())
|
||||
QSKIP("No network test server available");
|
||||
#endif // QT_TEST_SERVER
|
||||
#endif // QT_NO_SSL
|
||||
#endif // QT_CONFIG(ssl)
|
||||
}
|
||||
|
||||
void tst_QSslSocket::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
const QString socksProxyAddr = QtNetworkSettings::socksProxyServerIp().toString();
|
||||
const QString httpProxyAddr = QtNetworkSettings::httpProxyServerIp().toString();
|
||||
|
|
@ -493,9 +479,9 @@ void tst_QSslSocket::init()
|
|||
break;
|
||||
}
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
#else
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
}
|
||||
|
||||
QT_PREPEND_NAMESPACE(qt_ForceTlsSecurityLevel)();
|
||||
|
|
@ -505,12 +491,12 @@ void tst_QSslSocket::init()
|
|||
|
||||
void tst_QSslSocket::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
QSslSocketPtr tst_QSslSocket::newSocket()
|
||||
{
|
||||
const auto socket = QSslSocketPtr::create();
|
||||
|
|
@ -522,18 +508,18 @@ QSslSocketPtr tst_QSslSocket::newSocket()
|
|||
|
||||
return socket;
|
||||
}
|
||||
#endif
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
void tst_QSslSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth)
|
||||
{
|
||||
++proxyAuthCalled;
|
||||
auth->setUser("qsockstest");
|
||||
auth->setPassword("password");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
void tst_QSslSocket::activeBackend()
|
||||
{
|
||||
|
|
@ -623,7 +609,7 @@ void tst_QSslSocket::backends()
|
|||
if (setProxy) // Not interesting for backend test.
|
||||
return;
|
||||
|
||||
// We are here, protected by !QT_NO_SSL. Some backend must be pre-existing.
|
||||
// We are here, protected by QT_CONFIG(ssl). Some backend must be pre-existing.
|
||||
// Let's test the 'real' backend:
|
||||
auto backendNames = QTlsBackend::availableBackendNames();
|
||||
const auto sizeBefore = backendNames.size();
|
||||
|
|
@ -765,7 +751,7 @@ void tst_QSslSocket::constructing()
|
|||
QCOMPARE(socket.peerAddress(), QHostAddress());
|
||||
QVERIFY(socket.peerName().isEmpty());
|
||||
QCOMPARE(socket.peerPort(), quint16(0));
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QCOMPARE(socket.proxy().type(), QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
QCOMPARE(socket.readBufferSize(), qint64(0));
|
||||
|
|
@ -971,7 +957,10 @@ void tst_QSslSocket::sslErrors()
|
|||
sslErrors << err.error();
|
||||
std::sort(sslErrors.begin(), sslErrors.end());
|
||||
QVERIFY(sslErrors.contains(QSslError::HostNameMismatch));
|
||||
QVERIFY(sslErrors.contains(FLUKE_CERTIFICATE_ERROR));
|
||||
|
||||
// Non-OpenSSL backends are not able to report a specific error code
|
||||
// for self-signed certificates.
|
||||
QVERIFY(sslErrors.contains(flukeCertificateError));
|
||||
|
||||
// check the same errors were emitted by sslErrors
|
||||
QVERIFY(!sslErrorsSpy.isEmpty());
|
||||
|
|
@ -1272,11 +1261,12 @@ void tst_QSslSocket::privateKey()
|
|||
{
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void tst_QSslSocket::privateKeyOpaque()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
return;
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not support private opaque keys");
|
||||
|
||||
// TLSTODO: OpenSSL symbols are now a part of 'openssl' plugin,
|
||||
// not QtNetwork anymore.
|
||||
#if 0
|
||||
|
|
@ -1309,7 +1299,7 @@ void tst_QSslSocket::privateKeyOpaque()
|
|||
QSKIP("Skipping flaky test - See QTBUG-29941");
|
||||
#endif // if 0
|
||||
}
|
||||
#endif
|
||||
#endif // Feature 'openssl'.
|
||||
|
||||
void tst_QSslSocket::protocol()
|
||||
{
|
||||
|
|
@ -1629,14 +1619,12 @@ void tst_QSslSocket::protocolServerSide()
|
|||
QCOMPARE(client.isEncrypted(), works);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
|
||||
void tst_QSslSocket::serverCipherPreferences()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl()) {
|
||||
qWarning("SSL not supported, skipping test");
|
||||
return;
|
||||
}
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not support server-side cipher preferences");
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy)
|
||||
|
|
@ -1704,7 +1692,7 @@ void tst_QSslSocket::serverCipherPreferences()
|
|||
}
|
||||
}
|
||||
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif // Feature 'openssl'.
|
||||
|
||||
|
||||
void tst_QSslSocket::setCaCertificates()
|
||||
|
|
@ -1799,7 +1787,7 @@ void tst_QSslSocket::tlsConfiguration()
|
|||
QCOMPARE(tlsConfig.sessionProtocol(), QSsl::UnknownProtocol);
|
||||
QSslConfiguration nullConfig;
|
||||
QVERIFY(nullConfig.isNull());
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
nullConfig.setEllipticCurves(tlsConfig.ellipticCurves());
|
||||
QCOMPARE(nullConfig.ellipticCurves(), tlsConfig.ellipticCurves());
|
||||
#endif
|
||||
|
|
@ -2592,7 +2580,7 @@ void tst_QSslSocket::verifyMode()
|
|||
QSKIP("Skipping flaky test - See QTBUG-29941");
|
||||
|
||||
QList<QSslError> expectedErrors = QList<QSslError>()
|
||||
<< QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate());
|
||||
<< QSslError(flukeCertificateError, socket.peerCertificate());
|
||||
QCOMPARE(socket.sslHandshakeErrors(), expectedErrors);
|
||||
socket.abort();
|
||||
|
||||
|
|
@ -2623,7 +2611,7 @@ void tst_QSslSocket::verifyDepth()
|
|||
QCOMPARE(socket.peerVerifyDepth(), 1);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void tst_QSslSocket::verifyAndDefaultConfiguration()
|
||||
{
|
||||
QFETCH_GLOBAL(const bool, setProxy);
|
||||
|
|
@ -2658,7 +2646,7 @@ void tst_QSslSocket::verifyAndDefaultConfiguration()
|
|||
QCOMPARE(QSslConfiguration::defaultConfiguration().caCertificates(), QList{caCert});
|
||||
#endif
|
||||
}
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
void tst_QSslSocket::disconnectFromHostWhenConnecting()
|
||||
{
|
||||
|
|
@ -2704,7 +2692,7 @@ void tst_QSslSocket::disconnectFromHostWhenConnected()
|
|||
QCOMPARE(socket->bytesToWrite(), qint64(0));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
|
||||
class BrokenPskHandshake : public QTcpServer
|
||||
{
|
||||
|
|
@ -2735,6 +2723,9 @@ private:
|
|||
|
||||
void tst_QSslSocket::closeWhileEmittingSocketError()
|
||||
{
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not support this test");
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy)
|
||||
return;
|
||||
|
|
@ -2761,11 +2752,11 @@ void tst_QSslSocket::closeWhileEmittingSocketError()
|
|||
QCOMPARE(socketErrorSpy.count(), 1);
|
||||
}
|
||||
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif // Feature 'openssl'.
|
||||
|
||||
void tst_QSslSocket::resetProxy()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#if QT_CONFIG(networkproxy)
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy)
|
||||
return;
|
||||
|
|
@ -2809,7 +2800,7 @@ void tst_QSslSocket::resetProxy()
|
|||
socket2.setProxy(goodProxy);
|
||||
socket2.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443);
|
||||
QVERIFY2(socket2.waitForConnected(10000), qPrintable(socket.errorString()));
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
#endif // QT_CONFIG(networkproxy)
|
||||
}
|
||||
|
||||
void tst_QSslSocket::ignoreSslErrorsList_data()
|
||||
|
|
@ -2821,8 +2812,8 @@ void tst_QSslSocket::ignoreSslErrorsList_data()
|
|||
QList<QSslError> expectedSslErrors;
|
||||
// fromPath gives us a list of certs, but it actually only contains one
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(httpServerCertChainPath());
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
QSslError rightError(flukeCertificateError, certs.at(0));
|
||||
QSslError wrongError(flukeCertificateError);
|
||||
|
||||
|
||||
QTest::newRow("SSL-failure-empty-list") << expectedSslErrors << 1;
|
||||
|
|
@ -3054,8 +3045,8 @@ void tst_QSslSocket::resume_data()
|
|||
// Note, httpServerCertChainPath() it's ... because we use the same certificate on
|
||||
// different services. We'll be actually connecting to IMAP server.
|
||||
QList<QSslCertificate> certs = QSslCertificate::fromPath(httpServerCertChainPath());
|
||||
QSslError rightError(FLUKE_CERTIFICATE_ERROR, certs.at(0));
|
||||
QSslError wrongError(FLUKE_CERTIFICATE_ERROR);
|
||||
QSslError rightError(flukeCertificateError, certs.at(0));
|
||||
QSslError wrongError(flukeCertificateError);
|
||||
errorsList.append(wrongError);
|
||||
QTest::newRow("ignoreSpecificErrors-Wrong") << true << errorsList << false;
|
||||
errorsList.clear();
|
||||
|
|
@ -3398,11 +3389,11 @@ void tst_QSslSocket::dhServer()
|
|||
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
void tst_QSslSocket::dhServerCustomParamsNull()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
QSKIP("No SSL support");
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("This test requires OpenSSL as the active TLS backend");
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy)
|
||||
|
|
@ -3432,9 +3423,7 @@ void tst_QSslSocket::dhServerCustomParamsNull()
|
|||
|
||||
QVERIFY(client.state() != QAbstractSocket::ConnectedState);
|
||||
}
|
||||
#endif // QT_NO_OPENSSL
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
void tst_QSslSocket::dhServerCustomParams()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
|
|
@ -3477,7 +3466,7 @@ void tst_QSslSocket::dhServerCustomParams()
|
|||
|
||||
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
|
||||
}
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
void tst_QSslSocket::ecdhServer()
|
||||
{
|
||||
|
|
@ -3778,7 +3767,7 @@ void tst_QSslSocket::allowedProtocolNegotiation()
|
|||
QVERIFY(server.socket->sslConfiguration().nextNegotiatedProtocol() == expectedNegotiated);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
#if QT_CONFIG(openssl)
|
||||
class PskProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -3882,8 +3871,12 @@ protected slots:
|
|||
socket->ignoreSslErrors();
|
||||
}
|
||||
};
|
||||
|
||||
void tst_QSslSocket::simplePskConnect_data()
|
||||
{
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does support PSK");
|
||||
|
||||
QTest::addColumn<PskConnectTestType>("pskTestType");
|
||||
QTest::newRow("PskConnectDoNotHandlePsk") << PskConnectDoNotHandlePsk;
|
||||
QTest::newRow("PskConnectEmptyCredentials") << PskConnectEmptyCredentials;
|
||||
|
|
@ -4154,6 +4147,9 @@ void tst_QSslSocket::simplePskConnect()
|
|||
|
||||
void tst_QSslSocket::ephemeralServerKey_data()
|
||||
{
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not support ephemeral keys");
|
||||
|
||||
QTest::addColumn<QString>("cipher");
|
||||
QTest::addColumn<bool>("emptyKey");
|
||||
|
||||
|
|
@ -4275,8 +4271,8 @@ void tst_QSslSocket::pskServer()
|
|||
|
||||
void tst_QSslSocket::signatureAlgorithm_data()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
QSKIP("Signature algorithms cannot be tested without SSL support");
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("Signature algorithms cannot be tested with a non-OpenSSL TLS backend");
|
||||
|
||||
if (QSslSocket::sslLibraryVersionNumber() >= 0x10101000L) {
|
||||
// FIXME: investigate if this test makes any sense with TLS 1.3.
|
||||
|
|
@ -4405,8 +4401,9 @@ void tst_QSslSocket::signatureAlgorithm()
|
|||
|
||||
void tst_QSslSocket::forwardReadChannelFinished()
|
||||
{
|
||||
if (!QSslSocket::supportsSsl())
|
||||
QSKIP("Needs SSL");
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("This test requires the OpenSSL backend");
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy)
|
||||
QSKIP("This test doesn't work via a proxy");
|
||||
|
|
@ -4425,7 +4422,7 @@ void tst_QSslSocket::forwardReadChannelFinished()
|
|||
QVERIFY(readChannelFinishedSpy.count());
|
||||
}
|
||||
|
||||
#endif // QT_NO_OPENSSL
|
||||
#endif // QT_CONFIG(openssl)
|
||||
|
||||
void tst_QSslSocket::unsupportedProtocols_data()
|
||||
{
|
||||
|
|
@ -4545,8 +4542,6 @@ void tst_QSslSocket::oldErrorsOnSocketReuse()
|
|||
}
|
||||
}
|
||||
|
||||
#endif // QT_NO_SSL
|
||||
|
||||
#if QT_CONFIG(openssl)
|
||||
|
||||
void tst_QSslSocket::alertMissingCertificate()
|
||||
|
|
@ -4554,6 +4549,8 @@ void tst_QSslSocket::alertMissingCertificate()
|
|||
// In this test we want a server to abort the connection due to the failing
|
||||
// client authentication. The server expected to send an alert before closing
|
||||
// the connection, and the client expected to receive this alert and report it.
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("This test requires the OpenSSL backend");
|
||||
|
||||
QFETCH_GLOBAL(const bool, setProxy);
|
||||
if (setProxy) // Not what we test here, bail out.
|
||||
|
|
@ -4610,6 +4607,9 @@ void tst_QSslSocket::alertInvalidCertificate()
|
|||
// it also will do 'early' checks, meaning the reported and
|
||||
// not ignored _during_ the hanshake, not after. This ensures
|
||||
// OpenSSL sends an alert.
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("This test requires the OpenSSL backend");
|
||||
|
||||
QFETCH_GLOBAL(const bool, setProxy);
|
||||
if (setProxy) // Not what we test here, bail out.
|
||||
return;
|
||||
|
|
@ -4658,6 +4658,9 @@ void tst_QSslSocket::alertInvalidCertificate()
|
|||
|
||||
void tst_QSslSocket::selfSignedCertificates_data()
|
||||
{
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not detect the required error");
|
||||
|
||||
QTest::addColumn<bool>("clientKnown");
|
||||
|
||||
QTest::newRow("Client known") << true;
|
||||
|
|
@ -4790,6 +4793,9 @@ void tst_QSslSocket::selfSignedCertificates()
|
|||
|
||||
void tst_QSslSocket::pskHandshake_data()
|
||||
{
|
||||
if (!isTestingOpenSsl)
|
||||
QSKIP("The active TLS backend does not support PSK");
|
||||
|
||||
QTest::addColumn<bool>("pskRight");
|
||||
|
||||
QTest::newRow("Psk right") << true;
|
||||
|
|
@ -4926,7 +4932,9 @@ void tst_QSslSocket::pskHandshake()
|
|||
}
|
||||
}
|
||||
|
||||
#endif // openssl
|
||||
#endif // QT_CONFIG(openssl)
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
|
||||
QTEST_MAIN(tst_QSslSocket)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtNetwork/qtnetworkglobal.h>
|
||||
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
#include <QtNetwork/qsslsocket.h>
|
||||
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
// TODO: these 'helpers' later to include OpenSSL resolver/sumbols
|
||||
// required by some auto-tests.
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if QT_CONFIG(ssl)
|
||||
|
||||
namespace TlsAux {
|
||||
|
||||
inline bool activeBackendSupportsDtls()
|
||||
{
|
||||
// In case Qt was built with OpenSSL (the only DTLS-capable backend
|
||||
// at the moment) and some other backend, and later when running
|
||||
// the test OpenSSL library is not available, skip the whole
|
||||
// test.
|
||||
// IMPORTANT: extend this definition, if a new backend supporting
|
||||
// DTLS is introduced or if one of the already-supported backends
|
||||
// adds DTLS support.
|
||||
return QSslSocket::activeBackend() == QStringLiteral("openssl");
|
||||
}
|
||||
|
||||
} // namespace TlsAux
|
||||
|
||||
#endif // QT_CONFIG(ssl)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
Loading…
Reference in New Issue