diff options
author | Robin Krahl <me@robin-krahl.de> | 2019-01-13 12:29:58 +0100 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2019-01-13 13:27:59 +0100 |
commit | cd1cfdbfc4113186f80dbadf5eb76543b22e34bd (patch) | |
tree | c611d3e019624406949f8875af24eeec63502330 /unittest | |
parent | e9cfa720d39e0c540fe530f907a84e9a4b5d1240 (diff) | |
download | libnitrokey-wip/multiple-devices.tar.gz libnitrokey-wip/multiple-devices.tar.bz2 |
Add test for NK_list_devices to test_multiple_deviceswip/multiple-devices
As we cannot test this function properly in Python (due to missing
struct definitions), we test it in the C++ test suite.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/test_multiple_devices.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/unittest/test_multiple_devices.cc b/unittest/test_multiple_devices.cc index bc1b60b..4b1e2c1 100644 --- a/unittest/test_multiple_devices.cc +++ b/unittest/test_multiple_devices.cc @@ -29,6 +29,7 @@ const char * RFC_SECRET = "12345678901234567890"; #include <iostream> #include <NitrokeyManager.h> #include <stick20_commands.h> +#include "../NK_C_API.h" using namespace nitrokey; @@ -108,6 +109,24 @@ TEST_CASE("Regenerate AES keys", "[BASIC]") { } +TEST_CASE("Use C API", "[BASIC]") { + auto ptr = NK_list_devices(); + auto first_ptr = ptr; + REQUIRE(ptr != nullptr); + + while (ptr) { + std::cout << "Connect with: " << ptr->model << " " << ptr->path << " " + << ptr->serial_number << " | " << NK_connect_with_path(ptr->path) << " | "; + auto status = NK_status(); + std::cout << status << std::endl; + free(status); + ptr = ptr->next; + } + + NK_free_device_info(first_ptr); +} + + TEST_CASE("Use API", "[BASIC]") { auto nm = NitrokeyManager::instance(); nm->set_loglevel(2); |