Skip to content

Commit

Permalink
Add some basic tests on bkcrack executable
Browse files Browse the repository at this point in the history
  • Loading branch information
kimci86 committed Jan 22, 2024
1 parent d20c25a commit 1e65580
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 .)
Expand Down
19 changes: 19 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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:")

0 comments on commit 1e65580

Please sign in to comment.