From 560209550c379c87763827d97149d9faa158b9ca Mon Sep 17 00:00:00 2001 From: ameyer0 <48535411+ameyer0@users.noreply.github.com> Date: Sun, 10 May 2020 21:35:08 -0400 Subject: Change settings checkbox texts to positive phrasing (#4715) --- tests/CMakeLists.txt | 3 +++ tests/TestConfig.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++ tests/TestConfig.h | 30 ++++++++++++++++++++++++++++ tests/data/OutdatedConfig.ini | 8 ++++++++ 4 files changed, 87 insertions(+) create mode 100644 tests/TestConfig.cpp create mode 100644 tests/TestConfig.h create mode 100644 tests/data/OutdatedConfig.ini (limited to 'tests') 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 + * + * 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 . + */ + +#include "TestConfig.h" + +#include +#include + +#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 + * + * 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 . + */ + +#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 -- cgit v1.2.3