diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rwxr-xr-x | build/test_137-wrapper.sh | 10 | ||||
-rw-r--r-- | unittest/test_137.cc | 12 |
3 files changed, 23 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1004baf..a2ad1b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ IF (COMPILE_TESTS) unittest/test_multiple_devices.cc unittest/test_strdup.cpp unittest/test_safe.cpp + unittest/test_137.cc ) foreach(testsourcefile ${TESTS} ) diff --git a/build/test_137-wrapper.sh b/build/test_137-wrapper.sh new file mode 100755 index 0000000..be501cd --- /dev/null +++ b/build/test_137-wrapper.sh @@ -0,0 +1,10 @@ +#!/bin/bash +gpg2 --decrypt Makefile.gpg | wc -lc +sleep 1 +./test_137 -s +sleep 1 +gpg2 --decrypt Makefile.gpg | wc -lc +sleep 1 +./test_137 -s +gpg2 --version +git describe --long diff --git a/unittest/test_137.cc b/unittest/test_137.cc new file mode 100644 index 0000000..bc914d9 --- /dev/null +++ b/unittest/test_137.cc @@ -0,0 +1,12 @@ +#include <libnitrokey/NK_C_API.h> +#include "catch2/catch.hpp" +#include <cstring> + +TEST_CASE("Issue #137", "[fast]") { + REQUIRE(NK_login_auto() == 1); + REQUIRE(NK_user_authenticate("123456", "temppw") == 0); + auto s = NK_get_totp_code_PIN(0, 0, 0, 0, "temppw"); + REQUIRE(s != 0); + REQUIRE(strnlen(s, 100) > 0 ); + REQUIRE(NK_logout() == 0); +} |