aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_C_API.cpp
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-03-02 11:41:13 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-03-02 11:41:13 +0100
commit379daf936caa7fc8d7311a5dda101edb40d35ca5 (patch)
tree2d186dec6976b12a9f7b37e589c02703275a30ef /unittest/test_C_API.cpp
parentd5486ba77235a874245fbee07a75cea89fa59ea2 (diff)
parentc3d615b659b608f3a1d624f6fc78c303efbe1f8e (diff)
downloadlibnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.gz
libnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.bz2
Merge branch 'wip-multiple_devices'
Allow to use multiple devices, iteratively. Storage only.
Diffstat (limited to 'unittest/test_C_API.cpp')
-rw-r--r--unittest/test_C_API.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/unittest/test_C_API.cpp b/unittest/test_C_API.cpp
index be47f08..2d83ef4 100644
--- a/unittest/test_C_API.cpp
+++ b/unittest/test_C_API.cpp
@@ -43,6 +43,7 @@ TEST_CASE("C API connect", "[BASIC]") {
TEST_CASE("Check retry count", "[BASIC]") {
REQUIRE(login != 0);
+ NK_set_debug_level(3);
REQUIRE(NK_get_admin_retry_count() == 3);
REQUIRE(NK_get_user_retry_count() == 3);
}
@@ -56,4 +57,31 @@ TEST_CASE("Check long strings", "[STANDARD]") {
result = NK_change_user_PIN(pin, longPin);
REQUIRE(result == TOO_LONG_STRING);
CAPTURE(result);
+}
+
+#include <string.h>
+
+TEST_CASE("multiple devices with ID", "[BASIC]") {
+ NK_logout();
+ NK_set_debug_level(3);
+ auto s = NK_list_devices_by_cpuID();
+ REQUIRE(s!=nullptr);
+ REQUIRE(strnlen(s, 4096) < 4096);
+ REQUIRE(strnlen(s, 4096) > 2*4);
+ std::cout << s << std::endl;
+
+ char *string, *token;
+ int t;
+
+ string = strndup(s, 4096);
+ free ( (void*) s);
+
+ while ((token = strsep(&string, ";")) != nullptr){
+ if (strnlen(token, 4096) < 3) continue;
+ std::cout << token << " connecting: ";
+ std::cout << (t=NK_connect_with_ID(token)) << std::endl;
+ REQUIRE(t == 1);
+ }
+
+ free (string);
} \ No newline at end of file