aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--unittest/test_multiple_devices.cc37
2 files changed, 34 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d788cf..6037393 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,7 +192,7 @@ IF (COMPILE_TESTS)
target_link_libraries (test_issues ${EXTRA_LIBS} nitrokey catch)
add_executable (test_multiple_devices unittest/test_multiple_devices.cc)
- target_link_libraries (test_multiple_devices ${EXTRA_LIBS} ${LIBNAME} catch)
+ target_link_libraries (test_multiple_devices ${EXTRA_LIBS} nitrokey catch)
ENDIF()
diff --git a/unittest/test_multiple_devices.cc b/unittest/test_multiple_devices.cc
index 235a24d..65ae9ab 100644
--- a/unittest/test_multiple_devices.cc
+++ b/unittest/test_multiple_devices.cc
@@ -8,7 +8,6 @@ const char * RFC_SECRET = "12345678901234567890";
#include <iostream>
#include <NitrokeyManager.h>
-#include <iostream>
#include <stick20_commands.h>
using namespace nitrokey;
@@ -99,13 +98,43 @@ TEST_CASE("Use API ID", "[BASIC]") {
auto v = nm->list_devices_by_cpuID();
REQUIRE(v.size() > 0);
- for(int i=0; i<1000; i++) {
+ //no refresh - should not reconnect to new devices
+ for (int j = 0; j < 100; j++) {
+ for (auto i : v) {
+ if (!nm->connect_with_ID(i)) continue;
+ int retry_count = 99;
+ try {
+ retry_count = nm->get_admin_retry_count();
+ std::cout << j << " " << i << " " << to_string(retry_count) << std::endl;
+ }
+ catch (...) {
+ retry_count = 99;
+ //pass
+ }
+ }
+ }
+ std::cout << "finished" << std::endl;
+}
+
+TEST_CASE("Use API ID refresh", "[BASIC]") {
+ auto nm = NitrokeyManager::instance();
+ nm->set_loglevel(2);
+
+ //refresh in each iteration - should reconnect to new devices
+ for(int j=0; j<100; j++) {
auto v = nm->list_devices_by_cpuID();
REQUIRE(v.size() > 0);
for (auto i : v) {
nm->connect_with_ID(i);
- auto retry_count = nm->get_admin_retry_count();
- std::cout << i << " " << to_string(retry_count) << std::endl;
+ int retry_count = 99;
+ try {
+ retry_count = nm->get_admin_retry_count();
+ std::cout << j <<" " << i << " " << to_string(retry_count) << std::endl;
+ }
+ catch (...){
+ retry_count = 99;
+ //pass
+ }
}
}
std::cout << "finished" << std::endl;