2025-03-28 19:00:43 +00:00
|
|
|
/*
|
|
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
|
|
|
|
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
|
|
|
*/
|
|
|
|
|
|
2025-05-10 03:23:46 +00:00
|
|
|
#include "common/Settings.h"
|
2025-03-28 19:00:43 +00:00
|
|
|
|
|
|
|
|
#include <QTest>
|
|
|
|
|
|
|
|
|
|
class SettingsTests : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2025-05-31 15:35:37 +00:00
|
|
|
private Q_SLOTS:
|
2025-03-28 19:00:43 +00:00
|
|
|
void initTestCase();
|
|
|
|
|
// Test are run in order top to bottom
|
2025-10-15 12:42:55 +00:00
|
|
|
void setSettingsFile();
|
2025-11-11 19:44:28 +00:00
|
|
|
void setStateFile();
|
2025-03-28 19:00:43 +00:00
|
|
|
void settingsFile();
|
|
|
|
|
void settingsPath();
|
|
|
|
|
void tlsDir();
|
|
|
|
|
void tlsLocalDb();
|
|
|
|
|
void tlsTrustedServersDb();
|
|
|
|
|
void tlsTrustedClientsDb();
|
|
|
|
|
void checkValidSettings();
|
|
|
|
|
|
|
|
|
|
private:
|
2025-10-09 13:56:34 +00:00
|
|
|
inline static const QString m_settingsPathTemp = QStringLiteral("tmp/test");
|
|
|
|
|
inline static const QString m_settingsFile = QStringLiteral("%1/Deskflow.conf").arg(m_settingsPathTemp);
|
2025-11-11 19:44:28 +00:00
|
|
|
inline static const QString m_stateFile = QStringLiteral("%1/Deskflow.state").arg(m_settingsPathTemp);
|
2025-10-09 13:56:34 +00:00
|
|
|
|
|
|
|
|
// Gotcha: On Windows non-portable mode, additional config files such as TLS config are saved
|
|
|
|
|
// in 'Program Data' and are not stored in the same place as the settings file.
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
inline static const QString m_settingsPath = Settings::SystemDir;
|
|
|
|
|
#else
|
|
|
|
|
inline static const QString m_settingsPath = m_settingsPathTemp;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
inline static const QString m_expectedTlsDir = QStringLiteral("%1/%2").arg(m_settingsPath, kTlsDirName);
|
2025-03-28 19:00:43 +00:00
|
|
|
inline static const QString m_expectedTlsLocalDB =
|
|
|
|
|
QStringLiteral("%1/%2").arg(m_expectedTlsDir, kTlsFingerprintLocalFilename);
|
|
|
|
|
inline static const QString m_expectedTlsServerDB =
|
|
|
|
|
QStringLiteral("%1/%2").arg(m_expectedTlsDir, kTlsFingerprintTrustedServersFilename);
|
|
|
|
|
inline static const QString m_expectedTlsClientDB =
|
|
|
|
|
QStringLiteral("%1/%2").arg(m_expectedTlsDir, kTlsFingerprintTrustedClientsFilename);
|
|
|
|
|
};
|