diff options
author | ameyer0 <48535411+ameyer0@users.noreply.github.com> | 2020-05-11 04:35:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 04:35:08 +0300 |
commit | 560209550c379c87763827d97149d9faa158b9ca (patch) | |
tree | 4ad978cbe4bfe6e383312452b2d858f4f098414f /tests | |
parent | dcff507e0260940db818c688a658ee53d88f38cc (diff) |
Change settings checkbox texts to positive phrasing (#4715)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/TestConfig.cpp | 46 | ||||
-rw-r--r-- | tests/TestConfig.h | 30 | ||||
-rw-r--r-- | tests/data/OutdatedConfig.ini | 8 |
4 files changed, 87 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 96cb5267c..3a74622cb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -222,6 +222,9 @@ add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp add_unit_test(NAME testtools SOURCES TestTools.cpp LIBS ${TEST_LIBRARIES}) +add_unit_test(NAME testconfig SOURCES TestConfig.cpp + LIBS testsupport ${TEST_LIBRARIES}) + if(WITH_XC_FDOSECRETS) add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp LIBS testsupport ${TEST_LIBRARIES}) diff --git a/tests/TestConfig.cpp b/tests/TestConfig.cpp new file mode 100644 index 000000000..23661b046 --- /dev/null +++ b/tests/TestConfig.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "TestConfig.h" + +#include <QList> +#include <QTest> + +#include "config-keepassx-tests.h" +#include "core/Config.h" +#include "util/TemporaryFile.h" + +QTEST_GUILESS_MAIN(TestConfig) + +const QString oldTrueConfigPath = QString(KEEPASSX_TEST_DATA_DIR).append("/OutdatedConfig.ini"); + +// upgrade config file with deprecated settings (all of which are set to non-default values) +void TestConfig::testUpgrade() +{ + TemporaryFile tempFile; + + QVERIFY(tempFile.copyFromFile(oldTrueConfigPath)); + Config::createConfigFromFile(tempFile.fileName()); + + // value of new setting should be opposite the value of deprecated setting + QVERIFY(config()->get(Config::TrackNonDataChanges).toBool()); + QVERIFY(!config()->get(Config::Security_PasswordsRepeatVisible).toBool()); + QVERIFY(!config()->get(Config::Security_PasswordsHidden).toBool()); + QVERIFY(config()->get(Config::Security_PasswordEmptyPlaceholder).toBool()); + + tempFile.remove(); +} diff --git a/tests/TestConfig.h b/tests/TestConfig.h new file mode 100644 index 000000000..d5852acdd --- /dev/null +++ b/tests/TestConfig.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 or (at your option) + * version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef KEEPASSX_TESTCONFIG_H +#define KEEPASSX_TESTCONFIG_H + +#include "core/Config.h" + +class TestConfig : public QObject +{ + Q_OBJECT +private slots: + void testUpgrade(); +}; + +#endif // KEEPASSX_TESTCONFIG_H diff --git a/tests/data/OutdatedConfig.ini b/tests/data/OutdatedConfig.ini new file mode 100644 index 000000000..edc033057 --- /dev/null +++ b/tests/data/OutdatedConfig.ini @@ -0,0 +1,8 @@ +[General] +IgnoreGroupExpansion=false + +[security] +hidepassworddetails=false +passwordemptynodots=false +passwordscleartext=true +passwordsrepeat=true |