Skip to content

Commit

Permalink
Add test case mentioned in comment
Browse files Browse the repository at this point in the history
See #137 (comment) for details

Issue #137

Signed-off-by: Szczepan Zalega <[email protected]>
  • Loading branch information
szszszsz committed Jan 7, 2019
1 parent 1f3da5c commit c802af2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
Expand Down
10 changes: 10 additions & 0 deletions build/test_137-wrapper.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions unittest/test_137.cc
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit c802af2

Please sign in to comment.