Merge PR #29: Fix authentication reply crash if client already disconnected
This commit is contained in:
commit
a04f6d117e
@ -51,28 +51,10 @@ QString AwsAuthenticator::name() const
|
|||||||
return "AWS authenticator";
|
return "AWS authenticator";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AwsAuthenticator::onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation)
|
|
||||||
{
|
|
||||||
AuthenticationProcess *process = static_cast<AuthenticationProcess *>(sender());
|
|
||||||
AuthenticationReply *reply = m_runningProcesses.take(process);
|
|
||||||
|
|
||||||
if (error == AuthenticationErrorNoError) {
|
|
||||||
qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished successfully." << userInformation;
|
|
||||||
} else {
|
|
||||||
qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished with error" << error;
|
|
||||||
}
|
|
||||||
|
|
||||||
reply->proxyClient()->setUserName(userInformation.email());
|
|
||||||
|
|
||||||
setReplyError(reply, error);
|
|
||||||
setReplyFinished(reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthenticationReply *AwsAuthenticator::authenticate(ProxyClient *proxyClient)
|
AuthenticationReply *AwsAuthenticator::authenticate(ProxyClient *proxyClient)
|
||||||
{
|
{
|
||||||
qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient;
|
qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient;
|
||||||
AuthenticationReply *reply = createAuthenticationReply(proxyClient, this);
|
AuthenticationReply *reply = createAuthenticationReply(proxyClient, proxyClient);
|
||||||
|
|
||||||
if (!m_credentialsProvider->isValid()) {
|
if (!m_credentialsProvider->isValid()) {
|
||||||
qCWarning(dcAuthentication()) << name() << "There are no credentials for authenticating.";
|
qCWarning(dcAuthentication()) << name() << "There are no credentials for authenticating.";
|
||||||
setReplyError(reply, AuthenticationErrorProxyError);
|
setReplyError(reply, AuthenticationErrorProxyError);
|
||||||
@ -83,12 +65,21 @@ AuthenticationReply *AwsAuthenticator::authenticate(ProxyClient *proxyClient)
|
|||||||
AuthenticationProcess *process = new AuthenticationProcess(m_manager,
|
AuthenticationProcess *process = new AuthenticationProcess(m_manager,
|
||||||
m_credentialsProvider->accessKey(),
|
m_credentialsProvider->accessKey(),
|
||||||
m_credentialsProvider->secretAccessKey(),
|
m_credentialsProvider->secretAccessKey(),
|
||||||
m_credentialsProvider->sessionToken(), this);
|
m_credentialsProvider->sessionToken(), reply);
|
||||||
|
|
||||||
connect(process, &AuthenticationProcess::authenticationFinished, this, &AwsAuthenticator::onAuthenticationProcessFinished);
|
connect(process, &AuthenticationProcess::authenticationFinished, proxyClient, [=](Authenticator::AuthenticationError error, const UserInformation &userInformation = UserInformation()){
|
||||||
|
if (error == AuthenticationErrorNoError) {
|
||||||
|
qCDebug(dcAuthentication()) << name() << proxyClient << "finished successfully." << userInformation;
|
||||||
|
} else {
|
||||||
|
qCDebug(dcAuthentication()) << name() << proxyClient << "finished with error" << error;
|
||||||
|
}
|
||||||
|
|
||||||
|
proxyClient->setUserName(userInformation.email());
|
||||||
|
|
||||||
|
setReplyError(reply, error);
|
||||||
|
setReplyFinished(reply);
|
||||||
|
});
|
||||||
|
|
||||||
// Configure process
|
|
||||||
m_runningProcesses.insert(process, reply);
|
|
||||||
|
|
||||||
// Start authentication process
|
// Start authentication process
|
||||||
process->authenticate(proxyClient->token());
|
process->authenticate(proxyClient->token());
|
||||||
|
|||||||
@ -50,10 +50,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
QNetworkAccessManager *m_manager = nullptr;
|
QNetworkAccessManager *m_manager = nullptr;
|
||||||
AwsCredentialProvider *m_credentialsProvider = nullptr;
|
AwsCredentialProvider *m_credentialsProvider = nullptr;
|
||||||
QHash<AuthenticationProcess *, AuthenticationReply *> m_runningProcesses;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
AuthenticationReply *authenticate(ProxyClient *proxyClient) override;
|
AuthenticationReply *authenticate(ProxyClient *proxyClient) override;
|
||||||
|
|||||||
@ -79,36 +79,28 @@ JsonReply *AuthenticationHandler::Authenticate(const QVariantMap ¶ms, Transp
|
|||||||
proxyClient->setNonce(nonce);
|
proxyClient->setNonce(nonce);
|
||||||
|
|
||||||
AuthenticationReply *authReply = Engine::instance()->authenticator()->authenticate(proxyClient);
|
AuthenticationReply *authReply = Engine::instance()->authenticator()->authenticate(proxyClient);
|
||||||
connect(authReply, &AuthenticationReply::finished, this, &AuthenticationHandler::onAuthenticationFinished);
|
connect(authReply, &AuthenticationReply::finished, jsonReply, [=](){
|
||||||
|
authReply->deleteLater();
|
||||||
|
|
||||||
m_runningAuthentications.insert(authReply, jsonReply);
|
qCDebug(dcJsonRpc()) << "Authentication reply finished";
|
||||||
|
if (authReply->error() != Authenticator::AuthenticationErrorNoError) {
|
||||||
|
qCWarning(dcJsonRpc()) << "Authentication error occurred" << authReply->error();
|
||||||
|
jsonReply->setSuccess(false);
|
||||||
|
} else {
|
||||||
|
// Successfully authenticated
|
||||||
|
jsonReply->setSuccess(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set client authenticated if still there
|
||||||
|
if (!authReply->proxyClient().isNull()) {
|
||||||
|
authReply->proxyClient()->setAuthenticated(authReply->error() == Authenticator::AuthenticationErrorNoError);
|
||||||
|
jsonReply->setData(errorToReply(authReply->error()));
|
||||||
|
}
|
||||||
|
|
||||||
|
emit jsonReply->finished();
|
||||||
|
});
|
||||||
|
|
||||||
return jsonReply;
|
return jsonReply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthenticationHandler::onAuthenticationFinished()
|
|
||||||
{
|
|
||||||
AuthenticationReply *authenticationReply = static_cast<AuthenticationReply *>(sender());
|
|
||||||
authenticationReply->deleteLater();
|
|
||||||
|
|
||||||
qCDebug(dcJsonRpc()) << "Authentication reply finished";
|
|
||||||
JsonReply *jsonReply = m_runningAuthentications.take(authenticationReply);
|
|
||||||
|
|
||||||
if (authenticationReply->error() != Authenticator::AuthenticationErrorNoError) {
|
|
||||||
qCWarning(dcJsonRpc()) << "Authentication error occurred" << authenticationReply->error();
|
|
||||||
jsonReply->setSuccess(false);
|
|
||||||
} else {
|
|
||||||
// Successfully authenticated
|
|
||||||
jsonReply->setSuccess(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set client authenticated if still there
|
|
||||||
if (!authenticationReply->proxyClient().isNull()) {
|
|
||||||
authenticationReply->proxyClient()->setAuthenticated(authenticationReply->error() == Authenticator::AuthenticationErrorNoError);
|
|
||||||
jsonReply->setData(errorToReply(authenticationReply->error()));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit jsonReply->finished();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,13 +48,6 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE JsonReply *Authenticate(const QVariantMap ¶ms, TransportClient *transportClient);
|
Q_INVOKABLE JsonReply *Authenticate(const QVariantMap ¶ms, TransportClient *transportClient);
|
||||||
|
|
||||||
private:
|
|
||||||
QHash<AuthenticationReply *, JsonReply *> m_runningAuthentications;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onAuthenticationFinished();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,6 +300,10 @@ void ProxyServer::onClientDataAvailable(const QUuid &clientId, const QByteArray
|
|||||||
// Calculate server statisitcs
|
// Calculate server statisitcs
|
||||||
m_troughputCounter += data.count();
|
m_troughputCounter += data.count();
|
||||||
proxyClient->addRxDataCount(data.count());
|
proxyClient->addRxDataCount(data.count());
|
||||||
|
|
||||||
|
if (!remoteClient)
|
||||||
|
return;
|
||||||
|
|
||||||
remoteClient->addTxDataCount(data.count());
|
remoteClient->addTxDataCount(data.count());
|
||||||
|
|
||||||
m_totalTraffic += data.count();
|
m_totalTraffic += data.count();
|
||||||
|
|||||||
@ -3,10 +3,10 @@ name=test-nymea-remoteproxy
|
|||||||
writeLogs=false
|
writeLogs=false
|
||||||
logFile=/var/log/nymea-remoteproxy.log
|
logFile=/var/log/nymea-remoteproxy.log
|
||||||
monitorSocket=/tmp/nymea-remoteproxy-test.sock
|
monitorSocket=/tmp/nymea-remoteproxy-test.sock
|
||||||
jsonRpcTimeout=2000
|
jsonRpcTimeout=10000
|
||||||
authenticationTimeout=1000
|
authenticationTimeout=10000
|
||||||
inactiveTimeout=1500
|
inactiveTimeout=5000
|
||||||
aloneTimeout=1500
|
aloneTimeout=10000
|
||||||
|
|
||||||
[SSL]
|
[SSL]
|
||||||
certificate=:/test-certificate.crt
|
certificate=:/test-certificate.crt
|
||||||
|
|||||||
@ -130,14 +130,14 @@ void RemoteProxyTestsProxy::monitorServer()
|
|||||||
// Connect one
|
// Connect one
|
||||||
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionOneReadySpy.wait();
|
if (connectionOneReadySpy.count() < 1) connectionOneReadySpy.wait();
|
||||||
QVERIFY(connectionOneReadySpy.count() == 1);
|
QVERIFY(connectionOneReadySpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
|
|
||||||
// Connect two
|
// Connect two
|
||||||
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionTwoReadySpy.wait();
|
if (connectionTwoReadySpy.count() < 1) connectionTwoReadySpy.wait();
|
||||||
QVERIFY(connectionTwoReadySpy.count() == 1);
|
QVERIFY(connectionTwoReadySpy.count() == 1);
|
||||||
QVERIFY(connectionTwo->isConnected());
|
QVERIFY(connectionTwo->isConnected());
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ void RemoteProxyTestsProxy::monitorServer()
|
|||||||
QSignalSpy remoteConnectionEstablishedOne(connectionOne, &RemoteProxyConnection::remoteConnectionEstablished);
|
QSignalSpy remoteConnectionEstablishedOne(connectionOne, &RemoteProxyConnection::remoteConnectionEstablished);
|
||||||
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionOne->authenticate(m_testToken));
|
QVERIFY(connectionOne->authenticate(m_testToken));
|
||||||
connectionOneAuthenticatedSpy.wait();
|
if (connectionOneAuthenticatedSpy.count() < 1) connectionOneAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
QVERIFY(connectionOne->isAuthenticated());
|
QVERIFY(connectionOne->isAuthenticated());
|
||||||
@ -155,14 +155,17 @@ void RemoteProxyTestsProxy::monitorServer()
|
|||||||
QSignalSpy remoteConnectionEstablishedTwo(connectionTwo, &RemoteProxyConnection::remoteConnectionEstablished);
|
QSignalSpy remoteConnectionEstablishedTwo(connectionTwo, &RemoteProxyConnection::remoteConnectionEstablished);
|
||||||
QSignalSpy connectionTwoAuthenticatedSpy(connectionTwo, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionTwoAuthenticatedSpy(connectionTwo, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionTwo->authenticate(m_testToken));
|
QVERIFY(connectionTwo->authenticate(m_testToken));
|
||||||
connectionTwoAuthenticatedSpy.wait();
|
if (connectionTwoAuthenticatedSpy.count() < 1) connectionTwoAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionTwoAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionTwoAuthenticatedSpy.count() == 1);
|
||||||
QVERIFY(connectionTwo->isConnected());
|
QVERIFY(connectionTwo->isConnected());
|
||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
@ -174,16 +177,15 @@ void RemoteProxyTestsProxy::monitorServer()
|
|||||||
QCOMPARE(connectionTwo->tunnelPartnerName(), nameConnectionOne);
|
QCOMPARE(connectionTwo->tunnelPartnerName(), nameConnectionOne);
|
||||||
QCOMPARE(QUuid(connectionTwo->tunnelPartnerUuid()), uuidConnectionOne);
|
QCOMPARE(QUuid(connectionTwo->tunnelPartnerUuid()), uuidConnectionOne);
|
||||||
|
|
||||||
|
|
||||||
// Get monitor data
|
// Get monitor data
|
||||||
QLocalSocket *monitor = new QLocalSocket(this);
|
QLocalSocket *monitor = new QLocalSocket(this);
|
||||||
QSignalSpy connectedSpy(monitor, &QLocalSocket::connected);
|
QSignalSpy connectedSpy(monitor, &QLocalSocket::connected);
|
||||||
monitor->connectToServer(m_configuration->monitorSocketFileName());
|
monitor->connectToServer(m_configuration->monitorSocketFileName());
|
||||||
connectedSpy.wait(200);
|
if (connectedSpy.count() < 1) connectedSpy.wait();
|
||||||
QVERIFY(connectedSpy.count() == 1);
|
QVERIFY(connectedSpy.count() == 1);
|
||||||
|
|
||||||
QSignalSpy dataSpy(monitor, &QLocalSocket::readyRead);
|
QSignalSpy dataSpy(monitor, &QLocalSocket::readyRead);
|
||||||
dataSpy.wait();
|
if (dataSpy.count() < 1) dataSpy.wait();
|
||||||
QVERIFY(dataSpy.count() == 1);
|
QVERIFY(dataSpy.count() == 1);
|
||||||
QByteArray data = monitor->readAll();
|
QByteArray data = monitor->readAll();
|
||||||
qDebug() << data;
|
qDebug() << data;
|
||||||
@ -192,7 +194,7 @@ void RemoteProxyTestsProxy::monitorServer()
|
|||||||
|
|
||||||
QSignalSpy disconnectedSpy(monitor, &QLocalSocket::connected);
|
QSignalSpy disconnectedSpy(monitor, &QLocalSocket::connected);
|
||||||
monitor->disconnectFromServer();
|
monitor->disconnectFromServer();
|
||||||
disconnectedSpy.wait(200);
|
if (disconnectedSpy.count() < 1) disconnectedSpy.wait();
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
monitor->deleteLater();
|
monitor->deleteLater();
|
||||||
@ -315,7 +317,7 @@ void RemoteProxyTestsProxy::websocketBinaryData()
|
|||||||
// Send binary data and make sure the server disconnects this socket
|
// Send binary data and make sure the server disconnects this socket
|
||||||
QSignalSpy spyDisconnected(client, SIGNAL(disconnected()));
|
QSignalSpy spyDisconnected(client, SIGNAL(disconnected()));
|
||||||
client->sendBinaryMessage("trying to upload stuff...stuff...more stuff... other stuff");
|
client->sendBinaryMessage("trying to upload stuff...stuff...more stuff... other stuff");
|
||||||
spyConnection.wait(200);
|
spyConnection.wait(1000);
|
||||||
QVERIFY(spyConnection.count() == 1);
|
QVERIFY(spyConnection.count() == 1);
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
@ -508,26 +510,26 @@ void RemoteProxyTestsProxy::authenticate_data()
|
|||||||
QTest::addColumn<Authenticator::AuthenticationError>("expectedError");
|
QTest::addColumn<Authenticator::AuthenticationError>("expectedError");
|
||||||
|
|
||||||
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
||||||
<< 100 << Authenticator::AuthenticationErrorNoError;
|
<< 500 << Authenticator::AuthenticationErrorNoError;
|
||||||
|
|
||||||
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << "nonce"
|
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << "nonce"
|
||||||
<< 100 << Authenticator::AuthenticationErrorNoError;
|
<< 500 << Authenticator::AuthenticationErrorNoError;
|
||||||
|
|
||||||
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << "nonce"
|
QTest::newRow("success") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << "nonce"
|
||||||
<< 100 << Authenticator::AuthenticationErrorAuthenticationFailed;
|
<< 300 << Authenticator::AuthenticationErrorAuthenticationFailed;
|
||||||
|
|
||||||
|
|
||||||
QTest::newRow("failed") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
QTest::newRow("failed") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
||||||
<< 100 << Authenticator::AuthenticationErrorAuthenticationFailed;
|
<< 300 << Authenticator::AuthenticationErrorAuthenticationFailed;
|
||||||
|
|
||||||
QTest::newRow("not responding") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
QTest::newRow("not responding") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
||||||
<< 200 << Authenticator::AuthenticationErrorProxyError;
|
<< 500 << Authenticator::AuthenticationErrorProxyError;
|
||||||
|
|
||||||
QTest::newRow("aborted") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
QTest::newRow("aborted") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
||||||
<< 100 << Authenticator::AuthenticationErrorAborted;
|
<< 300 << Authenticator::AuthenticationErrorAborted;
|
||||||
|
|
||||||
QTest::newRow("unknown") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
QTest::newRow("unknown") << QUuid::createUuid().toString() << "Testclient, hello form the test!" << m_testToken << ""
|
||||||
<< 100 << Authenticator::AuthenticationErrorUnknown;
|
<< 300 << Authenticator::AuthenticationErrorUnknown;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,6 +545,10 @@ void RemoteProxyTestsProxy::authenticate()
|
|||||||
// Start the server
|
// Start the server
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
|
m_configuration->setAuthenticationTimeout(8000);
|
||||||
|
m_configuration->setJsonRpcTimeout(10000);
|
||||||
|
m_configuration->setInactiveTimeout(10000);
|
||||||
|
|
||||||
// Configure result
|
// Configure result
|
||||||
m_mockAuthenticator->setExpectedAuthenticationError(expectedError);
|
m_mockAuthenticator->setExpectedAuthenticationError(expectedError);
|
||||||
m_mockAuthenticator->setTimeoutDuration(timeout);
|
m_mockAuthenticator->setTimeoutDuration(timeout);
|
||||||
@ -630,8 +636,11 @@ void RemoteProxyTestsProxy::authenticateNonce()
|
|||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
@ -648,12 +657,12 @@ void RemoteProxyTestsProxy::authenticateNonce()
|
|||||||
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
||||||
|
|
||||||
connectionOne->sendData(dataOne);
|
connectionOne->sendData(dataOne);
|
||||||
remoteConnectionDataTwo.wait(500);
|
remoteConnectionDataTwo.wait();
|
||||||
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
||||||
|
|
||||||
connectionTwo->sendData(dataTwo);
|
connectionTwo->sendData(dataTwo);
|
||||||
remoteConnectionDataOne.wait(500);
|
remoteConnectionDataOne.wait();
|
||||||
QVERIFY(remoteConnectionDataOne.count() == 1);
|
QVERIFY(remoteConnectionDataOne.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
||||||
|
|
||||||
@ -750,8 +759,7 @@ void RemoteProxyTestsProxy::clientConnectionWebSocket()
|
|||||||
// Disconnect and clean up
|
// Disconnect and clean up
|
||||||
QSignalSpy spyDisconnected(connection, &RemoteProxyConnection::disconnected);
|
QSignalSpy spyDisconnected(connection, &RemoteProxyConnection::disconnected);
|
||||||
connection->disconnectServer();
|
connection->disconnectServer();
|
||||||
// FIXME: check why it waits the full time here
|
if (spyDisconnected.count() < 1) spyDisconnected.wait();
|
||||||
spyDisconnected.wait(500);
|
|
||||||
|
|
||||||
QVERIFY(spyDisconnected.count() >= 1);
|
QVERIFY(spyDisconnected.count() >= 1);
|
||||||
QVERIFY(!connection->isConnected());
|
QVERIFY(!connection->isConnected());
|
||||||
@ -800,8 +808,8 @@ void RemoteProxyTestsProxy::clientConnectionTcpSocket()
|
|||||||
// Disconnect and clean up
|
// Disconnect and clean up
|
||||||
QSignalSpy spyDisconnected(connection, &RemoteProxyConnection::disconnected);
|
QSignalSpy spyDisconnected(connection, &RemoteProxyConnection::disconnected);
|
||||||
connection->disconnectServer();
|
connection->disconnectServer();
|
||||||
// FIXME: check why it waits the full time here
|
|
||||||
spyDisconnected.wait(500);
|
if (spyDisconnected.count() < 1) spyDisconnected.wait();
|
||||||
|
|
||||||
QVERIFY(spyDisconnected.count() >= 1);
|
QVERIFY(spyDisconnected.count() >= 1);
|
||||||
QVERIFY(!connection->isConnected());
|
QVERIFY(!connection->isConnected());
|
||||||
@ -869,8 +877,11 @@ void RemoteProxyTestsProxy::remoteConnection()
|
|||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
@ -887,12 +898,12 @@ void RemoteProxyTestsProxy::remoteConnection()
|
|||||||
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
||||||
|
|
||||||
connectionOne->sendData(dataOne);
|
connectionOne->sendData(dataOne);
|
||||||
remoteConnectionDataTwo.wait(500);
|
remoteConnectionDataTwo.wait();
|
||||||
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
||||||
|
|
||||||
connectionTwo->sendData(dataTwo);
|
connectionTwo->sendData(dataTwo);
|
||||||
remoteConnectionDataOne.wait(500);
|
remoteConnectionDataOne.wait();
|
||||||
QVERIFY(remoteConnectionDataOne.count() == 1);
|
QVERIFY(remoteConnectionDataOne.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
||||||
|
|
||||||
@ -957,21 +968,21 @@ void RemoteProxyTestsProxy::trippleConnection()
|
|||||||
// Connect one
|
// Connect one
|
||||||
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionOneReadySpy.wait();
|
if (connectionOneReadySpy.count() < 1) connectionOneReadySpy.wait();
|
||||||
QVERIFY(connectionOneReadySpy.count() == 1);
|
QVERIFY(connectionOneReadySpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
|
|
||||||
// Connect two
|
// Connect two
|
||||||
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionTwoReadySpy.wait();
|
if (connectionTwoReadySpy.count() < 1) connectionTwoReadySpy.wait();
|
||||||
QVERIFY(connectionTwoReadySpy.count() == 1);
|
QVERIFY(connectionTwoReadySpy.count() == 1);
|
||||||
QVERIFY(connectionTwo->isConnected());
|
QVERIFY(connectionTwo->isConnected());
|
||||||
|
|
||||||
// Authenticate one
|
// Authenticate one
|
||||||
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionOne->authenticate(m_testToken, nonce));
|
QVERIFY(connectionOne->authenticate(m_testToken, nonce));
|
||||||
connectionOneAuthenticatedSpy.wait();
|
if (connectionOneAuthenticatedSpy.count() < 1) connectionOneAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
QVERIFY(connectionOne->isAuthenticated());
|
QVERIFY(connectionOne->isAuthenticated());
|
||||||
@ -983,13 +994,14 @@ void RemoteProxyTestsProxy::trippleConnection()
|
|||||||
QSignalSpy remoteConnectionEstablishedTwo(connectionTwo, &RemoteProxyConnection::remoteConnectionEstablished);
|
QSignalSpy remoteConnectionEstablishedTwo(connectionTwo, &RemoteProxyConnection::remoteConnectionEstablished);
|
||||||
QSignalSpy connectionTwoAuthenticatedSpy(connectionTwo, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionTwoAuthenticatedSpy(connectionTwo, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionTwo->authenticate(m_testToken, nonce));
|
QVERIFY(connectionTwo->authenticate(m_testToken, nonce));
|
||||||
connectionTwoAuthenticatedSpy.wait();
|
if (connectionTwoAuthenticatedSpy.count() < 1) connectionTwoAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionTwoAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionTwoAuthenticatedSpy.count() == 1);
|
||||||
QVERIFY(connectionTwo->isConnected());
|
QVERIFY(connectionTwo->isConnected());
|
||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
// Now connect a third connection and make sure the client will be closed
|
// Now connect a third connection and make sure the client will be closed
|
||||||
|
|
||||||
@ -997,17 +1009,17 @@ void RemoteProxyTestsProxy::trippleConnection()
|
|||||||
QSignalSpy connectionThreeReadySpy(connectionThree, &RemoteProxyConnection::ready);
|
QSignalSpy connectionThreeReadySpy(connectionThree, &RemoteProxyConnection::ready);
|
||||||
QSignalSpy connectionThreeDisconnectedSpy(connectionThree, &RemoteProxyConnection::disconnected);
|
QSignalSpy connectionThreeDisconnectedSpy(connectionThree, &RemoteProxyConnection::disconnected);
|
||||||
QVERIFY(connectionThree->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionThree->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionThreeReadySpy.wait();
|
if (connectionThreeReadySpy.count() < 1) connectionThreeReadySpy.wait();
|
||||||
QVERIFY(connectionThreeReadySpy.count() == 1);
|
QVERIFY(connectionThreeReadySpy.count() == 1);
|
||||||
QVERIFY(connectionThree->isConnected());
|
QVERIFY(connectionThree->isConnected());
|
||||||
|
|
||||||
// Authenticate three
|
// Authenticate three
|
||||||
QSignalSpy connectionThreeAuthenticatedSpy(connectionThree, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionThreeAuthenticatedSpy(connectionThree, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionThree->authenticate(m_testToken, nonce));
|
QVERIFY(connectionThree->authenticate(m_testToken, nonce));
|
||||||
connectionThreeAuthenticatedSpy.wait();
|
if (connectionThreeAuthenticatedSpy.count() < 1) connectionThreeAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
||||||
|
|
||||||
connectionThreeDisconnectedSpy.wait(200);
|
if (connectionThreeDisconnectedSpy.count() < 1) connectionThreeDisconnectedSpy.wait();
|
||||||
QVERIFY(connectionThreeDisconnectedSpy.count() >= 1);
|
QVERIFY(connectionThreeDisconnectedSpy.count() >= 1);
|
||||||
|
|
||||||
// Make sure the one and two are still connected
|
// Make sure the one and two are still connected
|
||||||
@ -1042,21 +1054,21 @@ void RemoteProxyTestsProxy::duplicateUuid()
|
|||||||
// Connect one
|
// Connect one
|
||||||
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
QSignalSpy connectionOneReadySpy(connectionOne, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionOne->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionOneReadySpy.wait();
|
if (connectionOneReadySpy.count() < 1) connectionOneReadySpy.wait();
|
||||||
QVERIFY(connectionOneReadySpy.count() == 1);
|
QVERIFY(connectionOneReadySpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
|
|
||||||
// Connect two
|
// Connect two
|
||||||
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
QSignalSpy connectionTwoReadySpy(connectionTwo, &RemoteProxyConnection::ready);
|
||||||
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connectionTwo->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionTwoReadySpy.wait();
|
if (connectionTwoReadySpy.count() < 1) connectionTwoReadySpy.wait();
|
||||||
QVERIFY(connectionTwoReadySpy.count() == 1);
|
QVERIFY(connectionTwoReadySpy.count() == 1);
|
||||||
QVERIFY(connectionTwo->isConnected());
|
QVERIFY(connectionTwo->isConnected());
|
||||||
|
|
||||||
// Authenticate one
|
// Authenticate one
|
||||||
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
QSignalSpy connectionOneAuthenticatedSpy(connectionOne, &RemoteProxyConnection::authenticated);
|
||||||
QVERIFY(connectionOne->authenticate(m_testToken));
|
QVERIFY(connectionOne->authenticate(m_testToken));
|
||||||
connectionOneAuthenticatedSpy.wait();
|
if (connectionOneAuthenticatedSpy.count() < 1) connectionOneAuthenticatedSpy.wait();
|
||||||
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
QVERIFY(connectionOneAuthenticatedSpy.count() == 1);
|
||||||
QVERIFY(connectionOne->isConnected());
|
QVERIFY(connectionOne->isConnected());
|
||||||
QVERIFY(connectionOne->isAuthenticated());
|
QVERIFY(connectionOne->isAuthenticated());
|
||||||
@ -1067,10 +1079,10 @@ void RemoteProxyTestsProxy::duplicateUuid()
|
|||||||
QSignalSpy disconnectSpyTwo(connectionTwo, &RemoteProxyConnection::disconnected);
|
QSignalSpy disconnectSpyTwo(connectionTwo, &RemoteProxyConnection::disconnected);
|
||||||
|
|
||||||
QVERIFY(connectionTwo->authenticate(m_testToken));
|
QVERIFY(connectionTwo->authenticate(m_testToken));
|
||||||
disconnectSpyOne.wait(200);
|
if (disconnectSpyOne.count() < 1 ) disconnectSpyOne.wait();
|
||||||
QVERIFY(disconnectSpyOne.count() >= 1);
|
QVERIFY(disconnectSpyOne.count() >= 1);
|
||||||
|
|
||||||
disconnectSpyTwo.wait(200);
|
if (disconnectSpyTwo.count() < 1 ) disconnectSpyTwo.wait();
|
||||||
QVERIFY(disconnectSpyTwo.count() >= 1);
|
QVERIFY(disconnectSpyTwo.count() >= 1);
|
||||||
|
|
||||||
connectionOne->deleteLater();
|
connectionOne->deleteLater();
|
||||||
@ -1116,16 +1128,12 @@ void RemoteProxyTestsProxy::jsonRpcTimeout()
|
|||||||
// Start the server
|
// Start the server
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
m_configuration->setAuthenticationTimeout(3000);
|
|
||||||
m_configuration->setJsonRpcTimeout(1000);
|
|
||||||
m_configuration->setInactiveTimeout(2000);
|
|
||||||
|
|
||||||
// Configure result (authentication takes longer than json rpc timeout
|
// Configure result (authentication takes longer than json rpc timeout
|
||||||
m_mockAuthenticator->setExpectedAuthenticationError();
|
m_mockAuthenticator->setExpectedAuthenticationError();
|
||||||
m_mockAuthenticator->setTimeoutDuration(4000);
|
m_mockAuthenticator->setTimeoutDuration(10000);
|
||||||
m_configuration->setAuthenticationTimeout(4000);
|
m_configuration->setAuthenticationTimeout(10000);
|
||||||
m_configuration->setJsonRpcTimeout(1000);
|
m_configuration->setJsonRpcTimeout(1000);
|
||||||
m_configuration->setInactiveTimeout(2000);
|
m_configuration->setInactiveTimeout(10000);
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
QVariantMap params;
|
QVariantMap params;
|
||||||
@ -1147,6 +1155,8 @@ void RemoteProxyTestsProxy::inactiveTimeout()
|
|||||||
// Start the server
|
// Start the server
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
|
m_configuration->setInactiveTimeout(1000);
|
||||||
|
|
||||||
RemoteProxyConnection *connection = new RemoteProxyConnection(QUuid::createUuid(), "Sleepy test client", this);
|
RemoteProxyConnection *connection = new RemoteProxyConnection(QUuid::createUuid(), "Sleepy test client", this);
|
||||||
connect(connection, &RemoteProxyConnection::sslErrors, this, &BaseTest::ignoreConnectionSslError);
|
connect(connection, &RemoteProxyConnection::sslErrors, this, &BaseTest::ignoreConnectionSslError);
|
||||||
|
|
||||||
@ -1154,11 +1164,13 @@ void RemoteProxyTestsProxy::inactiveTimeout()
|
|||||||
QSignalSpy connectionReadySpy(connection, &RemoteProxyConnection::ready);
|
QSignalSpy connectionReadySpy(connection, &RemoteProxyConnection::ready);
|
||||||
QSignalSpy connectionDisconnectedSpy(connection, &RemoteProxyConnection::disconnected);
|
QSignalSpy connectionDisconnectedSpy(connection, &RemoteProxyConnection::disconnected);
|
||||||
QVERIFY(connection->connectServer(m_serverUrlProxyTcp));
|
QVERIFY(connection->connectServer(m_serverUrlProxyTcp));
|
||||||
connectionReadySpy.wait();
|
if (connectionReadySpy.count() < 1) connectionReadySpy.wait();
|
||||||
QVERIFY(connectionReadySpy.count() == 1);
|
QVERIFY(connectionReadySpy.count() == 1);
|
||||||
|
|
||||||
// Now wait for disconnected
|
// Now wait for disconnected
|
||||||
connectionDisconnectedSpy.wait();
|
if (connectionDisconnectedSpy.count() < 1)
|
||||||
|
connectionDisconnectedSpy.wait();
|
||||||
|
|
||||||
QVERIFY(connectionDisconnectedSpy.count() >= 1);
|
QVERIFY(connectionDisconnectedSpy.count() >= 1);
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
@ -1285,8 +1297,11 @@ void RemoteProxyTestsProxy::tcpRemoteConnection()
|
|||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
@ -1303,12 +1318,12 @@ void RemoteProxyTestsProxy::tcpRemoteConnection()
|
|||||||
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
||||||
|
|
||||||
connectionOne->sendData(dataOne);
|
connectionOne->sendData(dataOne);
|
||||||
remoteConnectionDataTwo.wait(500);
|
remoteConnectionDataTwo.wait();
|
||||||
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
||||||
|
|
||||||
connectionTwo->sendData(dataTwo);
|
connectionTwo->sendData(dataTwo);
|
||||||
remoteConnectionDataOne.wait(500);
|
remoteConnectionDataOne.wait();
|
||||||
QVERIFY(remoteConnectionDataOne.count() == 1);
|
QVERIFY(remoteConnectionDataOne.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
||||||
|
|
||||||
@ -1379,8 +1394,11 @@ void RemoteProxyTestsProxy::tcpWebsocketRemoteConnection()
|
|||||||
QVERIFY(connectionTwo->isAuthenticated());
|
QVERIFY(connectionTwo->isAuthenticated());
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
QVERIFY(remoteConnectionEstablishedOne.count() == 1);
|
||||||
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
QVERIFY(remoteConnectionEstablishedTwo.count() == 1);
|
||||||
@ -1397,12 +1415,12 @@ void RemoteProxyTestsProxy::tcpWebsocketRemoteConnection()
|
|||||||
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
QSignalSpy remoteConnectionDataTwo(connectionTwo, &RemoteProxyConnection::dataReady);
|
||||||
|
|
||||||
connectionOne->sendData(dataOne);
|
connectionOne->sendData(dataOne);
|
||||||
remoteConnectionDataTwo.wait(500);
|
remoteConnectionDataTwo.wait();
|
||||||
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
QVERIFY(remoteConnectionDataTwo.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
QCOMPARE(remoteConnectionDataTwo.at(0).at(0).toByteArray().trimmed(), dataOne);
|
||||||
|
|
||||||
connectionTwo->sendData(dataTwo);
|
connectionTwo->sendData(dataTwo);
|
||||||
remoteConnectionDataOne.wait(500);
|
remoteConnectionDataOne.wait();
|
||||||
QVERIFY(remoteConnectionDataOne.count() == 1);
|
QVERIFY(remoteConnectionDataOne.count() == 1);
|
||||||
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
QCOMPARE(remoteConnectionDataOne.at(0).at(0).toByteArray().trimmed(), dataTwo);
|
||||||
|
|
||||||
|
|||||||
@ -125,7 +125,7 @@ void BaseTest::startServer()
|
|||||||
QSignalSpy runningSpy(Engine::instance(), &Engine::runningChanged);
|
QSignalSpy runningSpy(Engine::instance(), &Engine::runningChanged);
|
||||||
Engine::instance()->setDeveloperModeEnabled(true);
|
Engine::instance()->setDeveloperModeEnabled(true);
|
||||||
Engine::instance()->start(m_configuration);
|
Engine::instance()->start(m_configuration);
|
||||||
runningSpy.wait(200);
|
runningSpy.wait();
|
||||||
QVERIFY(runningSpy.count() == 1);
|
QVERIFY(runningSpy.count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,8 +266,7 @@ QVariant BaseTest::invokeTcpSocketProxyApiCall(const QString &method, const QVar
|
|||||||
|
|
||||||
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
||||||
socket->write(jsonDoc.toJson(QJsonDocument::Compact) + '\n');
|
socket->write(jsonDoc.toJson(QJsonDocument::Compact) + '\n');
|
||||||
// FIXME: check why it waits the full time here
|
dataSpy.wait();
|
||||||
dataSpy.wait(500);
|
|
||||||
if (dataSpy.count() != 1) {
|
if (dataSpy.count() != 1) {
|
||||||
qWarning() << "No data received";
|
qWarning() << "No data received";
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -368,7 +367,7 @@ bool BaseTest::createRemoteConnection(const QString &token, const QString &nonce
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionOneAuthenticatedSpy.wait(500);
|
connectionOneAuthenticatedSpy.wait();
|
||||||
if (connectionOneAuthenticatedSpy.count() != 1) {
|
if (connectionOneAuthenticatedSpy.count() != 1) {
|
||||||
qWarning() << "Could not authenticate client one";
|
qWarning() << "Could not authenticate client one";
|
||||||
return false;
|
return false;
|
||||||
@ -387,7 +386,7 @@ bool BaseTest::createRemoteConnection(const QString &token, const QString &nonce
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionTwoAuthenticatedSpy.wait(500);
|
connectionTwoAuthenticatedSpy.wait();
|
||||||
if (connectionTwoAuthenticatedSpy.count() != 1) {
|
if (connectionTwoAuthenticatedSpy.count() != 1) {
|
||||||
qWarning() << "Could not authenticate client two";
|
qWarning() << "Could not authenticate client two";
|
||||||
return false;
|
return false;
|
||||||
@ -399,8 +398,11 @@ bool BaseTest::createRemoteConnection(const QString &token, const QString &nonce
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for both to be connected
|
// Wait for both to be connected
|
||||||
remoteConnectionEstablishedOne.wait(500);
|
if (remoteConnectionEstablishedOne.count() < 1)
|
||||||
remoteConnectionEstablishedTwo.wait(500);
|
remoteConnectionEstablishedOne.wait();
|
||||||
|
|
||||||
|
if (remoteConnectionEstablishedTwo.count() < 1)
|
||||||
|
remoteConnectionEstablishedTwo.wait();
|
||||||
|
|
||||||
if (remoteConnectionEstablishedOne.count() != 1 || remoteConnectionEstablishedTwo.count() != 1) {
|
if (remoteConnectionEstablishedOne.count() != 1 || remoteConnectionEstablishedTwo.count() != 1) {
|
||||||
qWarning() << "Could not establish remote connection";
|
qWarning() << "Could not establish remote connection";
|
||||||
@ -433,8 +435,6 @@ QVariant BaseTest::injectTcpSocketProxyData(const QByteArray &data)
|
|||||||
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
||||||
socket->write(data + '\n');
|
socket->write(data + '\n');
|
||||||
dataSpy.wait();
|
dataSpy.wait();
|
||||||
// FIXME: check why it waits the full time here
|
|
||||||
dataSpy.wait(500);
|
|
||||||
if (dataSpy.count() != 1) {
|
if (dataSpy.count() != 1) {
|
||||||
qWarning() << "No data received";
|
qWarning() << "No data received";
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -578,8 +578,7 @@ QVariant BaseTest::invokeTcpSocketTunnelProxyApiCall(const QString &method, cons
|
|||||||
|
|
||||||
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
||||||
socket->write(jsonDoc.toJson(QJsonDocument::Compact) + '\n');
|
socket->write(jsonDoc.toJson(QJsonDocument::Compact) + '\n');
|
||||||
// FIXME: check why it waits the full time here
|
dataSpy.wait();
|
||||||
dataSpy.wait(500);
|
|
||||||
if (dataSpy.count() != 1) {
|
if (dataSpy.count() != 1) {
|
||||||
qWarning() << "No data received";
|
qWarning() << "No data received";
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -631,8 +630,6 @@ QVariant BaseTest::injectTcpSocketTunnelProxyData(const QByteArray &data)
|
|||||||
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
QSignalSpy dataSpy(socket, &QSslSocket::readyRead);
|
||||||
socket->write(data + '\n');
|
socket->write(data + '\n');
|
||||||
dataSpy.wait();
|
dataSpy.wait();
|
||||||
// FIXME: check why it waits the full time here
|
|
||||||
dataSpy.wait(500);
|
|
||||||
if (dataSpy.count() != 1) {
|
if (dataSpy.count() != 1) {
|
||||||
qWarning() << "No data received";
|
qWarning() << "No data received";
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -697,8 +694,7 @@ QPair<QVariant, QSslSocket *> BaseTest::invokeTcpSocketTunnelProxyApiCallPersist
|
|||||||
socket->write(payload);
|
socket->write(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: check why it waits the full time here
|
dataSpy.wait();
|
||||||
dataSpy.wait(500);
|
|
||||||
if (dataSpy.count() < 1) {
|
if (dataSpy.count() < 1) {
|
||||||
qWarning() << "No data received";
|
qWarning() << "No data received";
|
||||||
return QPair<QVariant, QSslSocket *>(QVariant(), socket);
|
return QPair<QVariant, QSslSocket *>(QVariant(), socket);
|
||||||
|
|||||||
Reference in New Issue
Block a user