aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_C_API.cpp
diff options
context:
space:
mode:
authorszszszsz <szszszsz@users.noreply.github.com>2016-10-19 17:33:30 +0200
committerGitHub <noreply@github.com>2016-10-19 17:33:30 +0200
commit82a0fc21f039971acac18df0ee57e2bb010865e1 (patch)
treef4f487257c99826a6d208fa6ea6f48b4ab7392ed /unittest/test_C_API.cpp
parent10631378c61b7ce54ad6f31dc1d16c3ba4c49d32 (diff)
parente81a132c210e03b6b0a7404a8c96ebda889a5676 (diff)
downloadlibnitrokey-82a0fc21f039971acac18df0ee57e2bb010865e1.tar.gz
libnitrokey-82a0fc21f039971acac18df0ee57e2bb010865e1.tar.bz2
Merge pull request #42 from Nitrokey/13-storage_pro_cmds
Support Pro stick commands on Storage device
Diffstat (limited to 'unittest/test_C_API.cpp')
-rw-r--r--unittest/test_C_API.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/unittest/test_C_API.cpp b/unittest/test_C_API.cpp
new file mode 100644
index 0000000..37d3c7f
--- /dev/null
+++ b/unittest/test_C_API.cpp
@@ -0,0 +1,34 @@
+static const int TOO_LONG_STRING = 200;
+
+#include "catch.hpp"
+
+#include <iostream>
+#include <string>
+#include "log.h"
+#include "../NK_C_API.h"
+
+TEST_CASE("C API connect", "[BASIC]") {
+ auto login = NK_login_auto();
+ REQUIRE(login != 0);
+ NK_logout();
+ login = NK_login_auto();
+ REQUIRE(login != 0);
+ NK_logout();
+ login = NK_login_auto();
+ REQUIRE(login != 0);
+}
+
+TEST_CASE("Check retry count", "[BASIC]") {
+ REQUIRE(NK_get_admin_retry_count() == 3);
+ REQUIRE(NK_get_user_retry_count() == 3);
+}
+
+TEST_CASE("Check long strings", "[STANDARD]") {
+ char* longPin = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ char *pin = "123123123";
+ auto result = NK_change_user_PIN(longPin, pin);
+ REQUIRE(result == TOO_LONG_STRING);
+ result = NK_change_user_PIN(pin, longPin);
+ REQUIRE(result == TOO_LONG_STRING);
+ CAPTURE(result);
+} \ No newline at end of file