chore: modify client trying to connect dialog to inform user the new client needs to be put in the layout when both tls is enabled and peer key checking is enabled , otherwise show the old dialog asking to allow the client to connect
This commit is contained in:
parent
0667f5de73
commit
79dc858446
5 changed files with 37 additions and 24 deletions
|
|
@ -20,9 +20,9 @@ namespace deskflow::gui {
|
|||
//
|
||||
|
||||
messages::NewClientPromptResult
|
||||
ServerConnection::Deps::showNewClientPrompt(QWidget *parent, const QString &clientName) const
|
||||
ServerConnection::Deps::showNewClientPrompt(QWidget *parent, const QString &clientName, bool previouslyAccepted) const
|
||||
{
|
||||
return messages::showNewClientPrompt(parent, clientName);
|
||||
return messages::showNewClientPrompt(parent, clientName, previouslyAccepted);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -93,7 +93,8 @@ void ServerConnection::handleNewClient(const QString &clientName)
|
|||
Q_EMIT messageShowing();
|
||||
|
||||
m_messageShowing = true;
|
||||
const auto result = m_pDeps->showNewClientPrompt(m_pParent, clientName);
|
||||
const auto result =
|
||||
m_pDeps->showNewClientPrompt(m_pParent, clientName, m_appConfig.tlsEnabled() && m_appConfig.requireClientCerts());
|
||||
m_messageShowing = false;
|
||||
|
||||
if (result == Add) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public:
|
|||
struct Deps
|
||||
{
|
||||
virtual ~Deps() = default;
|
||||
virtual messages::NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName) const;
|
||||
virtual messages::NewClientPromptResult
|
||||
showNewClientPrompt(QWidget *parent, const QString &clientName, bool previouslyAccepted = false) const;
|
||||
};
|
||||
|
||||
explicit ServerConnection(
|
||||
|
|
|
|||
|
|
@ -205,23 +205,33 @@ void showClientConnectError(QWidget *parent, ClientError error, const QString &a
|
|||
dialog.exec();
|
||||
}
|
||||
|
||||
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName)
|
||||
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName, bool tlsAcceptedClient)
|
||||
{
|
||||
using enum NewClientPromptResult;
|
||||
|
||||
QMessageBox message(parent);
|
||||
const QPushButton *ignore = message.addButton("Ignore", QMessageBox::RejectRole);
|
||||
const QPushButton *add = message.addButton("Add client", QMessageBox::AcceptRole);
|
||||
message.setText(QString("A new client called '%1' wants to connect").arg(clientName));
|
||||
message.exec();
|
||||
|
||||
if (message.clickedButton() == add) {
|
||||
if (tlsAcceptedClient) {
|
||||
// When peer checking is enabled you will be prompted to allow the connection before seeing this dialog.
|
||||
// This is why we do not show a dialog with an option to ignore the new client
|
||||
QMessageBox::information(
|
||||
parent, QString("New Client"),
|
||||
QString("A new client called '%1' has been accepted. You'll need to add it to your server's screen layout.")
|
||||
.arg(clientName)
|
||||
);
|
||||
return Add;
|
||||
} else if (message.clickedButton() == ignore) {
|
||||
return Ignore;
|
||||
} else {
|
||||
qFatal("no expected dialog button was clicked");
|
||||
abort();
|
||||
QMessageBox message(parent);
|
||||
const QPushButton *ignore = message.addButton("Ignore", QMessageBox::RejectRole);
|
||||
const QPushButton *add = message.addButton("Add client", QMessageBox::AcceptRole);
|
||||
message.setText(QString("A new client called '%1' wants to connect").arg(clientName));
|
||||
message.exec();
|
||||
if (message.clickedButton() == add) {
|
||||
return Add;
|
||||
} else if (message.clickedButton() == ignore) {
|
||||
return Ignore;
|
||||
} else {
|
||||
qFatal("no expected dialog button was clicked");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void showCloseReminder(QWidget *parent);
|
|||
|
||||
void showClientConnectError(QWidget *parent, ClientError error, const QString &address);
|
||||
|
||||
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName);
|
||||
NewClientPromptResult showNewClientPrompt(QWidget *parent, const QString &clientName, bool tlsAcceptedClient = false);
|
||||
|
||||
bool showClearSettings(QWidget *parent);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace {
|
|||
struct DepsMock : public ServerConnection::Deps
|
||||
{
|
||||
MOCK_METHOD(
|
||||
messages::NewClientPromptResult, showNewClientPrompt, (QWidget * parent, const QString &clientName),
|
||||
(const, override)
|
||||
messages::NewClientPromptResult, showNewClientPrompt,
|
||||
(QWidget * parent, const QString &clientName, bool previousyAccepted), (const, override)
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
|||
ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
||||
|
||||
QString clientName = "test client";
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName));
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, false));
|
||||
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "test client")");
|
||||
}
|
||||
|
|
@ -54,10 +54,11 @@ TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
|||
TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt)
|
||||
{
|
||||
ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
||||
ON_CALL(*m_pDeps, showNewClientPrompt(_, _)).WillByDefault(testing::Return(messages::NewClientPromptResult::Ignore));
|
||||
ON_CALL(*m_pDeps, showNewClientPrompt(_, _, false))
|
||||
.WillByDefault(testing::Return(messages::NewClientPromptResult::Ignore));
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "stub")");
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _)).Times(0);
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
||||
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "stub")");
|
||||
}
|
||||
|
|
@ -67,7 +68,7 @@ TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt
|
|||
ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
||||
ON_CALL(m_serverConfig, isFull()).WillByDefault(testing::Return(true));
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _)).Times(0);
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
||||
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "test client")");
|
||||
}
|
||||
|
|
@ -77,7 +78,7 @@ TEST_F(ServerConnectionTests, handleLogLine_screenExists_shouldNotShowPrompt)
|
|||
ServerConnection serverConnection(nullptr, m_appConfig, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
||||
ON_CALL(m_serverConfig, screenExists(_)).WillByDefault(testing::Return(true));
|
||||
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _)).Times(0);
|
||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
||||
|
||||
serverConnection.handleLogLine(R"(unrecognised client name "test client")");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue