ssl: make peerVerifyError test agnostic of error order
Currently the peerVerifyError test for QSslSocket makes an assumption about the order in which SSL errors are emitted by peerVerifyError. This assumption does not necessarily hold for non-OpenSSL backends. This change fixes this assumption, and also checks that HostNameMismatch was found both in the errors emitted by peerVerifyError and by sslErrors. Change-Id: I856d1ea43b36332db0f178d35fc14a4bb18ad673 Reviewed-by: Richard J. Moore <rich@kde.org>bb10
parent
7b1dad8021
commit
863f598b65
|
|
@ -1998,10 +1998,23 @@ void tst_QSslSocket::peerVerifyError()
|
|||
socket->connectToHostEncrypted(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 443);
|
||||
if (socket->waitForEncrypted(10000))
|
||||
QSKIP("Skipping flaky test - See QTBUG-29941");
|
||||
|
||||
// check HostNameMismatch was emitted by peerVerifyError
|
||||
QVERIFY(!peerVerifyErrorSpy.isEmpty());
|
||||
SslErrorList peerErrors;
|
||||
const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy;
|
||||
foreach (const QVariantList &args, peerVerifyList)
|
||||
peerErrors << qvariant_cast<QSslError>(args.first()).error();
|
||||
QVERIFY(peerErrors.contains(QSslError::HostNameMismatch));
|
||||
|
||||
// check HostNameMismatch was emitted by sslErrors
|
||||
QVERIFY(!sslErrorsSpy.isEmpty());
|
||||
QCOMPARE(qvariant_cast<QSslError>(peerVerifyErrorSpy.last().at(0)).error(), QSslError::HostNameMismatch);
|
||||
QCOMPARE(qvariant_cast<QList<QSslError> >(sslErrorsSpy.at(0).at(0)).size(), peerVerifyErrorSpy.size());
|
||||
SslErrorList sslErrors;
|
||||
foreach (const QSslError &err, qvariant_cast<QList<QSslError> >(sslErrorsSpy.first().first()))
|
||||
sslErrors << err.error();
|
||||
QVERIFY(peerErrors.contains(QSslError::HostNameMismatch));
|
||||
|
||||
QCOMPARE(sslErrors.size(), peerErrors.size());
|
||||
}
|
||||
|
||||
void tst_QSslSocket::disconnectFromHostWhenConnecting()
|
||||
|
|
|
|||
Loading…
Reference in New Issue