summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2019-01-13 12:05:09 +0100
committerRobin Krahl <me@robin-krahl.de>2019-01-13 13:27:18 +0100
commita63968570dc99ddf193589270218e6c6df34c460 (patch)
tree7d96d5aec8892ccff08fb727089a1f993eec07d3
parent8979b7301f79e167a8060772cf83913703f70f2c (diff)
downloadlibnitrokey-a63968570dc99ddf193589270218e6c6df34c460.tar.gz
libnitrokey-a63968570dc99ddf193589270218e6c6df34c460.tar.bz2
Add test case for NitrokeyManager::connect_with_path to test_multiple_devices
The current test case is renamed to “Use Storage API” as it queries the storage status. The new test case, “Use API”, lists all connected devices and prints their model, path and serial number.
-rw-r--r--unittest/test_multiple_devices.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/unittest/test_multiple_devices.cc b/unittest/test_multiple_devices.cc
index 2ea8a20..d644cfd 100644
--- a/unittest/test_multiple_devices.cc
+++ b/unittest/test_multiple_devices.cc
@@ -115,6 +115,29 @@ TEST_CASE("Use API", "[BASIC]") {
auto v = nm->list_devices();
REQUIRE(v.size() > 0);
+ for (auto i : v) {
+ std::cout << "Connect with: " << i.m_deviceModel << " " << i.m_path << " ";
+ std::wcout << i.m_serialNumber;
+ std::cout << " | " << std::boolalpha << nm->connect_with_path(i.m_path) << " |";
+ try {
+ auto status = nm->get_status();
+ std::cout << " " << status.card_serial_u32 << " "
+ << status.get_card_serial_hex()
+ << std::endl;
+ } catch (const LongOperationInProgressException &e) {
+ std::cout << "long operation in progress on " << i.m_path
+ << " " << std::to_string(e.progress_bar_value) << std::endl;
+ }
+ }
+}
+
+
+TEST_CASE("Use Storage API", "[BASIC]") {
+ auto nm = NitrokeyManager::instance();
+ nm->set_loglevel(2);
+ auto v = nm->list_devices();
+ REQUIRE(v.size() > 0);
+
for (int i=0; i<10; i++){
for (auto i : v) {
if (i.m_deviceModel != DeviceModel::STORAGE)