2024-01-11 07:18:11 -05:00
|
|
|
# Copyright (C) 2023 KeePassXC Team <team@keepassxc.org>
|
2010-08-13 12:08:06 -04:00
|
|
|
# Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2018-10-19 15:41:56 -04:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${CMAKE_SOURCE_DIR}/src
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/../src)
|
2010-08-13 12:08:06 -04:00
|
|
|
|
2011-11-20 04:12:49 -05:00
|
|
|
add_definitions(-DQT_TEST_LIB)
|
|
|
|
|
2012-05-21 17:37:29 -04:00
|
|
|
set(KEEPASSX_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
|
|
|
configure_file(config-keepassx-tests.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx-tests.h)
|
|
|
|
|
|
|
|
macro(parse_arguments prefix arg_names option_names)
|
2018-10-19 15:41:56 -04:00
|
|
|
set(DEFAULT_ARGS)
|
|
|
|
foreach(arg_name ${arg_names})
|
|
|
|
set(${prefix}_${arg_name})
|
|
|
|
endforeach(arg_name)
|
|
|
|
foreach(option ${option_names})
|
|
|
|
set(${prefix}_${option} FALSE)
|
|
|
|
endforeach(option)
|
|
|
|
|
|
|
|
set(current_arg_name DEFAULT_ARGS)
|
|
|
|
set(current_arg_list)
|
|
|
|
foreach(arg ${ARGN})
|
|
|
|
set(larg_names ${arg_names})
|
|
|
|
list(FIND larg_names "${arg}" is_arg_name)
|
|
|
|
if(is_arg_name GREATER -1)
|
|
|
|
set(${prefix}_${current_arg_name} ${current_arg_list})
|
|
|
|
set(current_arg_name ${arg})
|
|
|
|
set(current_arg_list)
|
|
|
|
else()
|
|
|
|
set(loption_names ${option_names})
|
|
|
|
list(FIND loption_names "${arg}" is_option)
|
|
|
|
if(is_option GREATER -1)
|
|
|
|
set(${prefix}_${arg} TRUE)
|
|
|
|
else(is_option GREATER -1)
|
|
|
|
set(current_arg_list ${current_arg_list} ${arg})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach(arg)
|
|
|
|
set(${prefix}_${current_arg_name} ${current_arg_list})
|
2012-05-21 17:37:29 -04:00
|
|
|
endmacro(parse_arguments)
|
|
|
|
|
|
|
|
macro(add_unit_test)
|
2019-12-16 16:49:58 -05:00
|
|
|
parse_arguments(TEST "NAME;SOURCES;LIBS;LAUNCHER" "" ${ARGN})
|
2018-10-19 15:41:56 -04:00
|
|
|
set(_test_NAME ${TEST_NAME})
|
2019-12-16 16:49:58 -05:00
|
|
|
set(_test_LAUNCHER ${TEST_LAUNCHER})
|
2018-10-19 15:41:56 -04:00
|
|
|
set(_srcList ${TEST_SOURCES})
|
|
|
|
add_executable(${_test_NAME} ${_srcList})
|
|
|
|
target_link_libraries(${_test_NAME} ${TEST_LIBS})
|
|
|
|
|
|
|
|
if(NOT TEST_OUTPUT)
|
|
|
|
set(TEST_OUTPUT plaintext)
|
|
|
|
endif(NOT TEST_OUTPUT)
|
|
|
|
set(TEST_OUTPUT ${TEST_OUTPUT} CACHE STRING "The output to generate when running the QTest unit tests")
|
|
|
|
|
|
|
|
if(KDE4_TEST_OUTPUT STREQUAL "xml")
|
2019-12-16 16:49:58 -05:00
|
|
|
add_test(${_test_NAME} ${_test_LAUNCHER} ${_test_NAME} -xml -o ${_test_NAME}.tml)
|
2018-10-19 15:41:56 -04:00
|
|
|
else(KDE4_TEST_OUTPUT STREQUAL "xml")
|
2019-12-16 16:49:58 -05:00
|
|
|
add_test(${_test_NAME} ${_test_LAUNCHER} ${_test_NAME})
|
2018-10-19 15:41:56 -04:00
|
|
|
endif(KDE4_TEST_OUTPUT STREQUAL "xml")
|
|
|
|
|
|
|
|
if(NOT MSVC_IDE) #not needed for the ide
|
|
|
|
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
|
|
|
|
if(NOT WITH_TESTS)
|
|
|
|
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
|
|
|
|
if(NOT _buildtestsAdded)
|
|
|
|
add_custom_target(buildtests)
|
|
|
|
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
|
|
|
|
endif()
|
|
|
|
add_dependencies(buildtests ${_test_NAME})
|
|
|
|
endif()
|
2012-05-21 17:37:29 -04:00
|
|
|
endif()
|
|
|
|
endmacro(add_unit_test)
|
2010-08-13 12:08:06 -04:00
|
|
|
|
2019-10-27 21:37:42 -04:00
|
|
|
set(TEST_LIBRARIES keepassx_core Qt5::Test)
|
2010-09-11 13:49:30 -04:00
|
|
|
|
2018-12-19 17:52:12 -05:00
|
|
|
set(testsupport_SOURCES
|
|
|
|
modeltest.cpp
|
|
|
|
FailDevice.cpp
|
|
|
|
mock/MockClock.cpp
|
2021-04-04 08:56:00 -04:00
|
|
|
util/TemporaryFile.cpp)
|
2015-07-20 15:32:07 -04:00
|
|
|
add_library(testsupport STATIC ${testsupport_SOURCES})
|
2017-06-29 13:54:49 -04:00
|
|
|
target_link_libraries(testsupport Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Test)
|
2010-08-14 08:26:25 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testgroup SOURCES TestGroup.cpp
|
2018-10-19 15:41:56 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2010-09-19 18:16:30 -04:00
|
|
|
|
2018-01-17 14:52:29 -05:00
|
|
|
add_unit_test(NAME testkdbx2 SOURCES TestKdbx2.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-08-15 06:31:48 -04:00
|
|
|
|
2020-01-09 20:11:43 -05:00
|
|
|
add_unit_test(NAME testkdbx3 SOURCES TestKeePass2Format.cpp FailDevice.cpp mock/MockChallengeResponseKey.cpp TestKdbx3.cpp
|
2018-10-19 15:41:56 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2018-01-05 10:41:29 -05:00
|
|
|
|
2018-03-01 15:25:29 -05:00
|
|
|
add_unit_test(NAME testkdbx4 SOURCES TestKeePass2Format.cpp FailDevice.cpp mock/MockChallengeResponseKey.cpp TestKdbx4.cpp
|
2018-10-19 15:41:56 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2011-11-13 08:52:43 -05:00
|
|
|
|
2018-03-01 14:07:19 -05:00
|
|
|
add_unit_test(NAME testkeys SOURCES TestKeys.cpp mock/MockChallengeResponseKey.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testgroupmodel SOURCES TestGroupModel.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2010-09-11 13:49:30 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testentrymodel SOURCES TestEntryModel.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2010-09-11 13:49:30 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testcryptohash SOURCES TestCryptoHash.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-09-18 11:19:42 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testsymmetriccipher SOURCES TestSymmetricCipher.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2010-11-21 17:06:30 -05:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testhashedblockstream SOURCES TestHashedBlockStream.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2011-07-06 18:08:37 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testkeepass2randomstream SOURCES TestKeePass2RandomStream.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2011-12-26 13:18:21 -05:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testmodified SOURCES TestModified.cpp
|
2018-10-19 15:41:56 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2012-04-18 07:27:16 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testdeletedobjects SOURCES TestDeletedObjects.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2012-04-21 17:17:26 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2011-12-26 13:18:21 -05:00
|
|
|
|
2019-05-19 17:49:48 -04:00
|
|
|
add_unit_test(NAME testopvaultreader SOURCES TestOpVaultReader.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
|
2019-01-30 09:11:50 -05:00
|
|
|
if(WITH_XC_NETWORKING)
|
|
|
|
add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
2020-10-04 14:27:02 -04:00
|
|
|
|
|
|
|
add_unit_test(NAME testicondownloader SOURCES TestIconDownloader.cpp LIBS ${TEST_LIBRARIES})
|
2019-01-30 09:11:50 -05:00
|
|
|
endif()
|
|
|
|
|
2016-12-04 13:57:24 -05:00
|
|
|
if(WITH_XC_AUTOTYPE)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_unit_test(NAME testautotype SOURCES TestAutoType.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
set_target_properties(testautotype PROPERTIES ENABLE_EXPORTS ON)
|
2016-12-04 13:57:24 -05:00
|
|
|
endif()
|
2012-10-28 10:31:57 -04:00
|
|
|
|
2021-04-04 08:56:00 -04:00
|
|
|
if(WITH_XC_SSHAGENT)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_unit_test(NAME testopensshkey SOURCES TestOpenSSHKey.cpp
|
2021-04-04 08:56:00 -04:00
|
|
|
LIBS sshagent ${TEST_LIBRARIES})
|
2020-02-06 03:15:50 -05:00
|
|
|
if(NOT WIN32)
|
|
|
|
add_unit_test(NAME testsshagent SOURCES TestSSHAgent.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
endif()
|
2017-10-29 11:17:24 -04:00
|
|
|
endif()
|
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testentry SOURCES TestEntry.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2013-03-24 16:21:06 -04:00
|
|
|
|
2017-09-05 10:28:47 -04:00
|
|
|
add_unit_test(NAME testmerge SOURCES TestMerge.cpp
|
2018-09-29 13:00:47 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
|
|
|
|
|
|
|
add_unit_test(NAME testpasswordgenerator SOURCES TestPasswordGenerator.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-09-05 10:28:47 -04:00
|
|
|
|
2020-02-01 08:42:34 -05:00
|
|
|
add_unit_test(NAME testpasswordhealth SOURCES TestPasswordHealth.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
|
2019-05-24 18:23:19 -04:00
|
|
|
add_unit_test(NAME testpassphrasegenerator SOURCES TestPassphraseGenerator.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
|
2019-06-24 18:03:42 -04:00
|
|
|
add_unit_test(NAME testhibp SOURCES TestHibp.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
|
2017-04-13 06:05:36 -04:00
|
|
|
add_unit_test(NAME testtotp SOURCES TestTotp.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-04-13 06:05:36 -04:00
|
|
|
|
2017-09-24 18:00:12 -04:00
|
|
|
add_unit_test(NAME testbase32 SOURCES TestBase32.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-09-24 18:00:12 -04:00
|
|
|
|
2017-01-08 19:33:21 -05:00
|
|
|
add_unit_test(NAME testcsvparser SOURCES TestCsvParser.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2017-01-08 19:33:21 -05:00
|
|
|
|
2018-10-01 10:26:24 -04:00
|
|
|
add_unit_test(NAME testrandomgenerator SOURCES TestRandomGenerator.cpp
|
2019-12-21 09:46:01 -05:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2013-10-09 17:11:18 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2014-05-15 17:48:54 -04:00
|
|
|
|
2015-07-22 10:59:38 -04:00
|
|
|
add_unit_test(NAME testcsvexporter SOURCES TestCsvExporter.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2015-07-14 16:14:34 -04:00
|
|
|
|
2020-04-06 08:42:20 -04:00
|
|
|
if(WITH_XC_YUBIKEY)
|
|
|
|
add_unit_test(NAME testykchallengeresponsekey
|
2018-01-24 07:22:20 -05:00
|
|
|
SOURCES TestYkChallengeResponseKey.cpp
|
2018-01-17 12:15:37 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2020-04-06 08:42:20 -04:00
|
|
|
endif()
|
2014-05-26 03:46:41 -04:00
|
|
|
|
2018-10-01 10:26:24 -04:00
|
|
|
if(WITH_XC_KEESHARE)
|
|
|
|
add_unit_test(NAME testsharing SOURCES TestSharing.cpp
|
2019-12-21 09:46:01 -05:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2018-10-01 10:26:24 -04:00
|
|
|
endif()
|
|
|
|
|
2017-04-22 03:02:59 -04:00
|
|
|
add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
2019-10-14 09:31:23 -04:00
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
2017-04-22 03:02:59 -04:00
|
|
|
|
2018-05-14 15:26:26 -04:00
|
|
|
add_unit_test(NAME testtools SOURCES TestTools.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
|
2020-05-10 21:35:08 -04:00
|
|
|
add_unit_test(NAME testconfig SOURCES TestConfig.cpp
|
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
|
|
|
|
Add Freedesktop.org Secret Storage Spec Server Side API (Fix #1403)
This plugin implements the Secret Storage specification version 0.2.
While running KeePassXC, it acts as a Secret Service server, registered
on DBus, so clients like seahorse, python-secretstorage, or other
implementations can connect and access the exposed database in KeePassXC.
Squashed commits:
- Initial code
- Add SessionAdaptor and fix build
- The skeletons for all dbus objects are in place
- Implement collection creation and deletion
- Emit collectionChanged signal
- Implement app-wise settings page
- Implement error message on GUI
- Implement settings
- Fix uuid to dbus path
- Implement app level settings
- Add freedesktop logo
- Implement database settings page
- Change database settings to a treeview
- Move all settings read/write to one place
- Rename SecretServiceOptionsPage to SettingsWidgetFdoSecrets
- Fix selected group can not be saved if the user hasn't click on the item
- Show selected group per database in app settings
- Disable editing of various readonly widgets
- Remove unused warning about non exposed database
- Fix method signature on dbus adaptors
- Fix type derived from DBusObject not recognized as QDBusContext
- Resolve a few TODOs around error handling
- Remove const when passing DBus exposed objects
- Move dismiss to PromptBase
- Implement per collection locking/unlocking
- Fix const correctness on Item::setSecret
- Implement SecretService::getSecrets
- Rework the signal connections around collections.
- Remove generateId from DBusObject
- Per spec, use encoded label as DBus object path for collections
- Fix some corner cases around collection name changes
- Implement alias
- Fix wrong alias dbus path
- Implement encryption per spec
- Cleanup SessionCipher
- Implement searchItems for SecretService
- Use Tools::uuidToHex
- Implement Item attributes and delete
- Implement createItem
- Always check if the database is unlocked before perform any operation
- Add missing ReadAlias/SetAlias on service
- Reorganize and fix OpenSession always returning empty output
- Overhaul error handling
- Make sure default alias is always present
- Remove collection aliases early in doDelete
- Handles all content types, fix setProperties not working
- Fix sometimes there is an extraneous leading zero when converting from MPI
- Fix session encryption negotiation
- Do not expose recycle bin
- Protect against the methods not called from DBus
- Also emit collectionChanged signal when lock state changes
- Show notification when entry secret is requested
- Add a README file
- Actually close session when client disconnects
- Gracefully return alternative label when collection is locked
- Reorganize, rename secretservice to fdosecrets
- Fix issues reported by clazy
- Unify UI strings and fix icon
- Implement a setting to skip confirmation when deleting entries from DBus
- Remove some unused debugging log
- Simply ignore errors when DBus context is not available. QtDBus won't set QDBusContext when deliver property get/set, and there is no way to get a QDBusMessage in property getter/setter.
- Simplify GcryptMPI using std::unique_ptr and add unit test
- Format code in fdosecrets
- Move DBusReturnImpl to details namespace
- Fix crash when locking a database: don't modify exposedGroup setting in customData when database is deleted
- Make sure Collection::searchItems works, whether it's locked or not
- Fix FdoSecrets::Collection becomes empty after a database reload
- Fix crash when looping while modifying the list
2019-03-25 23:07:18 -04:00
|
|
|
if(WITH_XC_FDOSECRETS)
|
|
|
|
add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp
|
|
|
|
LIBS testsupport ${TEST_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2018-12-10 07:20:58 -05:00
|
|
|
if(WITH_XC_BROWSER)
|
2019-05-30 17:22:09 -04:00
|
|
|
add_unit_test(NAME testbrowser SOURCES TestBrowser.cpp
|
2018-12-10 07:20:58 -05:00
|
|
|
LIBS ${TEST_LIBRARIES})
|
2024-01-11 07:18:11 -05:00
|
|
|
|
|
|
|
if(WITH_XC_BROWSER_PASSKEYS)
|
|
|
|
# Prevent duplicate linking with macOS
|
|
|
|
if(APPLE)
|
|
|
|
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
|
|
|
|
LIBS ${TEST_LIBRARIES})
|
|
|
|
else()
|
|
|
|
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
|
|
|
|
LIBS keepassxcbrowser ${TEST_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-12-10 07:20:58 -05:00
|
|
|
endif()
|
|
|
|
|
2021-09-26 06:36:54 -04:00
|
|
|
add_unit_test(NAME testcli SOURCES TestCli.cpp
|
|
|
|
LIBS testsupport cli ${TEST_LIBRARIES})
|
2022-10-29 08:07:31 -04:00
|
|
|
target_compile_definitions(testcli PRIVATE KEEPASSX_CLI_PATH="$<TARGET_FILE:keepassxc-cli>")
|
2018-09-29 13:00:47 -04:00
|
|
|
|
2011-12-26 13:18:21 -05:00
|
|
|
if(WITH_GUI_TESTS)
|
2018-10-19 15:41:56 -04:00
|
|
|
add_subdirectory(gui)
|
2011-12-26 13:18:21 -05:00
|
|
|
endif(WITH_GUI_TESTS)
|