Wait for both client and server sockets
Fixes the test
This commit is contained in:
parent
395536b382
commit
4d059af839
1 changed files with 20 additions and 4 deletions
|
@ -123,10 +123,18 @@ void TestSslSocketLineReader::testTrustedDevice()
|
|||
m_clientSocket->setPeerVerifyMode(QSslSocket::VerifyPeer);
|
||||
m_clientSocket->addCaCertificate(serverSocket->localCertificate());
|
||||
|
||||
connect(m_clientSocket, &QSslSocket::encrypted, &m_loop, &QEventLoop::quit);
|
||||
int connected_sockets = 0;
|
||||
auto connected_lambda = [&](){
|
||||
connected_sockets++;
|
||||
if (connected_sockets >= 2) {
|
||||
m_loop.quit();
|
||||
}
|
||||
};
|
||||
connect(serverSocket, &QSslSocket::encrypted, connected_lambda);
|
||||
connect(m_clientSocket, &QSslSocket::encrypted, connected_lambda);
|
||||
serverSocket->startServerEncryption();
|
||||
m_clientSocket->startClientEncryption();
|
||||
m_loop.exec();
|
||||
m_loop.exec(); //Block until QEventLoop::quit gets called by the lambda
|
||||
|
||||
// Both client and server socket should be encrypted here and should have remote certificate because VerifyPeer is used
|
||||
QVERIFY2(m_clientSocket->isOpen(), "Client socket already closed");
|
||||
|
@ -183,10 +191,18 @@ void TestSslSocketLineReader::testUntrustedDevice()
|
|||
m_clientSocket->setPeerVerifyName(QStringLiteral("Test Server"));
|
||||
m_clientSocket->setPeerVerifyMode(QSslSocket::QueryPeer);
|
||||
|
||||
connect(m_clientSocket, &QSslSocket::encrypted, &m_loop, &QEventLoop::quit);
|
||||
int connected_sockets = 0;
|
||||
auto connected_lambda = [&](){
|
||||
connected_sockets++;
|
||||
if (connected_sockets >= 2) {
|
||||
m_loop.quit();
|
||||
}
|
||||
};
|
||||
connect(serverSocket, &QSslSocket::encrypted, connected_lambda);
|
||||
connect(m_clientSocket, &QSslSocket::encrypted, connected_lambda);
|
||||
serverSocket->startServerEncryption();
|
||||
m_clientSocket->startClientEncryption();
|
||||
m_loop.exec();
|
||||
m_loop.exec(); //Block until QEventLoop::quit gets called by the lambda
|
||||
|
||||
QVERIFY2(m_clientSocket->isOpen(), "Client socket already closed");
|
||||
QVERIFY2(serverSocket->isOpen(), "Server socket already closed");
|
||||
|
|
Loading…
Reference in a new issue