Add another SSL test.

One gets the SSL version string. That initializes something in the guts of Qt,
and gets things unstuck. Another doesn't and gets stuck if called as the only test.
This commit is contained in:
Dale Glass 2024-06-03 23:10:17 +02:00
parent 57fcc378bf
commit aaf08cf523
2 changed files with 32 additions and 1 deletions

View file

@ -106,6 +106,11 @@ void QtNetworkTests::httpRequest() {
void QtNetworkTests::httpsRequest() {
auto manager = new QNetworkAccessManager();
qDebug() << "SSL library version : " << QSslSocket::sslLibraryVersionString();
qDebug() << "SSL library version : " << QSslSocket::sslLibraryVersionString();
qDebug() << "SSL library build version: " << QSslSocket::sslLibraryBuildVersionString();
qDebug() << "Making request to" << HTTPS_URL;
QSignalSpy spy(manager, &QNetworkAccessManager::finished);
QNetworkRequest req(HTTPS_URL);
@ -118,7 +123,32 @@ void QtNetworkTests::httpsRequest() {
QNetworkReply *reply = arguments.at(0).value<QNetworkReply*>();
QVERIFY(!reply->error());
QVERIFY(!reply->sslConfiguration().isNull());
qDebug() << "Peer cert:" << reply->sslConfiguration().peerCertificate();
QString data = reply->readAll();
qDebug() << "DATA: " << data;
qDebug() << "SSL library version: " << QSslSocket::sslLibraryVersionString();
}
void QtNetworkTests::httpsRequestNoSSLVersion() {
auto manager = new QNetworkAccessManager();
qDebug() << "Making request to" << HTTPS_URL;
QSignalSpy spy(manager, &QNetworkAccessManager::finished);
QNetworkRequest req(HTTPS_URL);
manager->get(req);
spy.wait();
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QNetworkReply *reply = arguments.at(0).value<QNetworkReply*>();
QVERIFY(!reply->error());
QVERIFY(!reply->sslConfiguration().isNull());
qDebug() << "Peer cert:" << reply->sslConfiguration().peerCertificate();
QString data = reply->readAll();
qDebug() << "DATA: " << data;
qDebug() << "SSL library version: " << QSslSocket::sslLibraryVersionString();
}

View file

@ -24,6 +24,7 @@ private slots:
void tcpSocket();
void sslSocket();
void httpRequest();
void httpsRequestNoSSLVersion();
void httpsRequest();
};