From 1e655808138f41ed3102c030a9284ac611dfc94e Mon Sep 17 00:00:00 2001 From: kimci86 Date: Mon, 22 Jan 2024 21:40:38 +0100 Subject: [PATCH] Add some basic tests on bkcrack executable --- CMakeLists.txt | 15 +++++++++++---- tests/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d8fc7b..ca46671 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,15 +15,22 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -# option for building the documentation -option(BKCRACK_BUILD_DOC "Enable documentation generation with doxygen." OFF) - -# add the subdirectories +# main program add_subdirectory(src) + +# documentation generation +option(BKCRACK_BUILD_DOC "Enable documentation generation with doxygen." OFF) if(BKCRACK_BUILD_DOC) add_subdirectory(doc) endif() +# automated tests +option(BKCRACK_BUILD_TESTING "Enable automated testing with ctest." OFF) +if(BKCRACK_BUILD_TESTING) + enable_testing() + add_subdirectory(tests) +endif() + # install rules install(DIRECTORY example DESTINATION .) install(DIRECTORY tools DESTINATION .) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..3bb067a --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,19 @@ +add_test(NAME cli.password COMMAND bkcrack --password W4sF0rgotten) +set_tests_properties(cli.password PROPERTIES PASS_REGULAR_EXPRESSION "c4490e28 b414a23d 91404b31") + +add_test(NAME cli.bruteforce.empty COMMAND bkcrack -k 12345678 23456789 34567890 -r 0 ?b) +add_test(NAME cli.bruteforce.tiny COMMAND bkcrack -k 1b226dfe c089e0a3 6af00ee6 -r 4 ?b) +add_test(NAME cli.bruteforce.small COMMAND bkcrack -k 9bcb20c6 10a97ca5 103c0614 -r 8 ?p) +add_test(NAME cli.bruteforce.medium COMMAND bkcrack -k edb43a00 9ce6e179 8cf2cbba -r 10 ?a) +add_test(NAME cli.bruteforce.long COMMAND bkcrack -k dcce7593 b8a2e617 b2bd4365 -r 12 ?l) +set_tests_properties(cli.bruteforce.empty PROPERTIES PASS_REGULAR_EXPRESSION "Password: \n") +set_tests_properties(cli.bruteforce.tiny PROPERTIES PASS_REGULAR_EXPRESSION "Password: 🔐\n") +set_tests_properties(cli.bruteforce.small PROPERTIES PASS_REGULAR_EXPRESSION "Password: _S#cr3t!\n") +set_tests_properties(cli.bruteforce.medium PROPERTIES PASS_REGULAR_EXPRESSION "Password: q1w2e3r4t5\n") +set_tests_properties(cli.bruteforce.long PROPERTIES PASS_REGULAR_EXPRESSION "Password: abcdefghijkl\n") + +add_test(NAME cli.list COMMAND bkcrack -L secrets.zip WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/example) +set_tests_properties(cli.list PROPERTIES PASS_REGULAR_EXPRESSION "advice\.jpg.*spiral\.svg") + +add_test(NAME cli.help COMMAND bkcrack -h) +set_tests_properties(cli.help PROPERTIES PASS_REGULAR_EXPRESSION "usage:")