diff options
author | Janek Bevendorff <janek@jbev.net> | 2020-04-26 02:31:38 +0300 |
---|---|---|
committer | Janek Bevendorff <janek@jbev.net> | 2020-05-02 23:30:27 +0300 |
commit | 596d2cf425c3c8495b4c4a58c61798afe9fdd536 (patch) | |
tree | f550255e5355098dd91ba9cd73c7289ac5b352d3 /tests | |
parent | 5add01243d6c86c6d59d5018f860add377575259 (diff) |
Refactor Config.
Replaces all string configuration options with enum types
that can be checked by the compiler. This prevents spelling
errors, in-place configuration definitions, and inconsistent
default values. The default value config getter signature was
removed in favour of consistently and centrally default-initialised
configuration values.
Individual default values were adjusted for better security,
such as the default password length, which was increased from
16 characters to 32.
The already existing config option deprecation map was extended
by a general migration procedure using configuration versioning.
Settings were split into Roaming and Local settings, which
go to their respective AppData locations on Windows.
Fixes #2574
Fixes #2193
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TestAutoType.cpp | 12 | ||||
-rw-r--r-- | tests/gui/TestGui.cpp | 14 | ||||
-rw-r--r-- | tests/gui/TestGuiBrowser.cpp | 12 |
3 files changed, 19 insertions, 19 deletions
diff --git a/tests/TestAutoType.cpp b/tests/TestAutoType.cpp index e2ab5db1c..5898f0477 100644 --- a/tests/TestAutoType.cpp +++ b/tests/TestAutoType.cpp @@ -35,8 +35,8 @@ void TestAutoType::initTestCase() { QVERIFY(Crypto::init()); Config::createTempFileInstance(); - config()->set("AutoTypeDelay", 1); - config()->set("security/autotypeask", false); + config()->set(Config::AutoTypeDelay, 1); + config()->set(Config::Security_AutoTypeAsk, false); AutoType::createTestInstance(); QPluginLoader loader(resources()->pluginPath("keepassx-autotype-test")); @@ -54,7 +54,7 @@ void TestAutoType::initTestCase() void TestAutoType::init() { - config()->set("AutoTypeEntryTitleMatch", false); + config()->set(Config::AutoTypeEntryTitleMatch, false); m_test->clearActions(); m_db = QSharedPointer<Database>::create(); @@ -165,7 +165,7 @@ void TestAutoType::testGlobalAutoTypeWithOneMatch() void TestAutoType::testGlobalAutoTypeTitleMatch() { - config()->set("AutoTypeEntryTitleMatch", true); + config()->set(Config::AutoTypeEntryTitleMatch, true); m_test->setActiveWindowTitle("An Entry Title!"); m_test->triggerGlobalAutoType(); @@ -176,7 +176,7 @@ void TestAutoType::testGlobalAutoTypeTitleMatch() void TestAutoType::testGlobalAutoTypeUrlMatch() { - config()->set("AutoTypeEntryTitleMatch", true); + config()->set(Config::AutoTypeEntryTitleMatch, true); m_test->setActiveWindowTitle("Dummy - http://example.org/ - <My Browser>"); m_test->triggerGlobalAutoType(); @@ -187,7 +187,7 @@ void TestAutoType::testGlobalAutoTypeUrlMatch() void TestAutoType::testGlobalAutoTypeUrlSubdomainMatch() { - config()->set("AutoTypeEntryTitleMatch", true); + config()->set(Config::AutoTypeEntryTitleMatch, true); m_test->setActiveWindowTitle("Dummy - http://sub.example.org/ - <My Browser>"); m_test->triggerGlobalAutoType(); diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index f8fbfa7f1..3b97ffde8 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -99,14 +99,14 @@ void TestGui::initTestCase() QVERIFY(Crypto::init()); Config::createTempFileInstance(); // Disable autosave so we can test the modified file indicator - config()->set("AutoSaveAfterEveryChange", false); - config()->set("AutoSaveOnExit", false); + config()->set(Config::AutoSaveAfterEveryChange, false); + config()->set(Config::AutoSaveOnExit, false); // Enable the tray icon so we can test hiding/restoring the windowQByteArray - config()->set("GUI/ShowTrayIcon", true); + config()->set(Config::GUI_ShowTrayIcon, true); // Disable advanced settings mode (activate within individual tests to test advanced settings) - config()->set("GUI/AdvancedSettings", false); + config()->set(Config::GUI_AdvancedSettings, false); // Disable the update check first time alert - config()->set("UpdateCheckMessageShown", true); + config()->set(Config::UpdateCheckMessageShown, true); Bootstrap::bootstrapApplication(); @@ -342,7 +342,7 @@ void TestGui::testMergeDatabase() void TestGui::testAutoreloadDatabase() { - config()->set("AutoReloadOnChange", false); + config()->set(Config::AutoReloadOnChange, false); // Test accepting new file in autoreload MessageBox::setNextAnswer(MessageBox::Yes); @@ -375,7 +375,7 @@ void TestGui::testAutoreloadDatabase() // Test accepting a merge of edits into autoreload // Turn on autoload so we only get one messagebox (for the merge) - config()->set("AutoReloadOnChange", true); + config()->set(Config::AutoReloadOnChange, true); // Modify some entries testEditEntry(); diff --git a/tests/gui/TestGuiBrowser.cpp b/tests/gui/TestGuiBrowser.cpp index 1750caa80..7e5d89df4 100644 --- a/tests/gui/TestGuiBrowser.cpp +++ b/tests/gui/TestGuiBrowser.cpp @@ -69,14 +69,14 @@ void TestGuiBrowser::initTestCase() QVERIFY(Crypto::init()); Config::createTempFileInstance(); // Disable autosave so we can test the modified file indicator - config()->set("AutoSaveAfterEveryChange", false); - config()->set("AutoSaveOnExit", false); + config()->set(Config::AutoSaveAfterEveryChange, false); + config()->set(Config::AutoSaveOnExit, false); // Enable the tray icon so we can test hiding/restoring the windowQByteArray - config()->set("GUI/ShowTrayIcon", true); + config()->set(Config::GUI_ShowTrayIcon, true); // Disable advanced settings mode (activate within individual tests to test advanced settings) - config()->set("GUI/AdvancedSettings", false); + config()->set(Config::GUI_AdvancedSettings, false); // Disable the update check first time alert - config()->set("UpdateCheckMessageShown", true); + config()->set(Config::UpdateCheckMessageShown, true); m_mainWindow.reset(new MainWindow()); Bootstrap::restoreMainWindowState(*m_mainWindow); @@ -146,7 +146,7 @@ void TestGuiBrowser::cleanupTestCase() void TestGuiBrowser::testEntrySettings() { // Enable the Browser Integration - config()->set("Browser/Enabled", true); + config()->set(Config::Browser_Enabled, true); auto* toolBar = m_mainWindow->findChild<QToolBar*>("toolBar"); auto* entryView = m_dbWidget->findChild<EntryView*>("entryView"); |