From a5d11eab6003a6ed0f7c78ecb7136b28ee938a23 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 18 Jul 2016 18:04:34 +0200 Subject: Initial version of C/Python bindings Signed-off-by: Szczepan Zalega --- unittest/build/run.sh | 1 + unittest/test_HOTP.cc | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100755 unittest/build/run.sh (limited to 'unittest') diff --git a/unittest/build/run.sh b/unittest/build/run.sh new file mode 100755 index 0000000..2bcc580 --- /dev/null +++ b/unittest/build/run.sh @@ -0,0 +1 @@ +LD_LIBRARY_PATH=. ./test_HOTP diff --git a/unittest/test_HOTP.cc b/unittest/test_HOTP.cc index 1f54376..a961b24 100644 --- a/unittest/test_HOTP.cc +++ b/unittest/test_HOTP.cc @@ -1,8 +1,6 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() #include "catch.hpp" - #include -//#include #include "device_proto.h" #include "log.h" #include "stick10_commands.h" @@ -21,14 +19,14 @@ void hexStringToByte(uint8_t data[], const char* hexString){ if (i%2==1){ data[i/2] = strtoul(buf, NULL, 16) & 0xFF; } - } -}; + } +}; TEST_CASE("test secret", "[functions]") { uint8_t slot_secret[21]; slot_secret[20] = 0; const char* secretHex = "3132333435363738393031323334353637383930"; - hexStringToByte(slot_secret, secretHex); + hexStringToByte(slot_secret, secretHex); CAPTURE(slot_secret); REQUIRE(strcmp("12345678901234567890",reinterpret_cast(slot_secret) ) == 0 ); } @@ -60,7 +58,7 @@ TEST_CASE("Test HOTP codes according to RFC", "[HOTP]") { const char* secretHex = "3132333435363738393031323334353637383930"; hexStringToByte(hwrite.slot_secret, secretHex); // reset the HOTP counter - memset(hwrite.slot_counter, 0, 8); +// memset(hwrite.slot_counter, 0, 8); //hwrite.slot_config; //TODO check various configs in separate test cases //strcpy(reinterpret_cast(hwrite.slot_token_id), ""); //strcpy(reinterpret_cast(hwrite.slot_counter), ""); @@ -72,12 +70,12 @@ TEST_CASE("Test HOTP codes according to RFC", "[HOTP]") { auth.crc_to_authorize = WriteToHOTPSlot::CommandTransaction::getCRC(hwrite); Authorize::CommandTransaction::run(stick, auth); } - + //run hotp command WriteToHOTPSlot::CommandTransaction::run(stick, hwrite); uint32_t codes[] = { - 755224, 287082, 359152, 969429, 338314, + 755224, 287082, 359152, 969429, 338314, 254676, 287922, 162583, 399871, 520489 }; -- cgit v1.2.3