aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NK_C_API.cc8
-rw-r--r--NK_C_API.h4
-rw-r--r--NitrokeyManager.cc7
-rw-r--r--include/NitrokeyManager.h4
-rw-r--r--unittest/test_storage.py7
5 files changed, 16 insertions, 14 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index aeb6920..d42840b 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -450,17 +450,17 @@ extern int NK_change_update_password(const char* current_update_password,
});
}
-extern const char* NK_get_status_storage() {
+extern const char* NK_get_status_storage_as_string() {
auto m = NitrokeyManager::instance();
return get_with_string_result([&](){
- return m->get_status_storage();
+ return m->get_status_storage_as_string();
});
}
-extern const char* NK_get_SD_usage_data() {
+extern const char* NK_get_SD_usage_data_as_string() {
auto m = NitrokeyManager::instance();
return get_with_string_result([&](){
- return m->get_SD_usage_data();
+ return m->get_SD_usage_data_as_string();
});
}
diff --git a/NK_C_API.h b/NK_C_API.h
index 2d958d6..a446a62 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -430,7 +430,7 @@ extern int NK_change_update_password(const char* current_update_password,
* Storage only
* @return string with devices attributes
*/
-extern const char* NK_get_status_storage();
+extern const char* NK_get_status_storage_as_string();
/**
* Get SD card usage attributes as string.
@@ -438,7 +438,7 @@ extern const char* NK_get_status_storage();
* Storage only
* @return string with SD card usage attributes
*/
-extern const char* NK_get_SD_usage_data();
+extern const char* NK_get_SD_usage_data_as_string();
/**
* Get progress value of current long operation.
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index bba06a3..20f4f14 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -491,9 +491,8 @@ namespace nitrokey{
void NitrokeyManager::send_startup(uint64_t seconds_from_epoch){
auto p = get_payload<stick20::SendStartup>();
-// p.set_defaults();
+// p.set_defaults(); //set current time
p.localtime = seconds_from_epoch;
- //auto device_status =
stick20::SendStartup::CommandTransaction::run(*device, p);
}
@@ -547,12 +546,12 @@ namespace nitrokey{
stick20::ChangeUpdatePassword::CommandTransaction::run(*device, p);
}
- const char * NitrokeyManager::get_status_storage(){
+ const char * NitrokeyManager::get_status_storage_as_string(){
auto p = stick20::GetDeviceStatus::CommandTransaction::run(*device);
return strdup(p.data().dissect().c_str());
}
- const char * NitrokeyManager::get_SD_usage_data(){
+ const char * NitrokeyManager::get_SD_usage_data_as_string(){
auto p = stick20::GetSDCardOccupancy::CommandTransaction::run(*device);
return strdup(p.data().dissect().c_str());
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 11c2be4..60fa753 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -103,9 +103,9 @@ namespace nitrokey {
void send_startup(uint64_t seconds_from_epoch);
- const char * get_status_storage();
+ const char * get_status_storage_as_string();
- const char *get_SD_usage_data();
+ const char *get_SD_usage_data_as_string();
int get_progress_bar_value();
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index e7e0bda..01276ce 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -22,15 +22,18 @@ def get_dict_from_dissect(status):
def test_get_status_storage(C):
- status_pointer = C.NK_get_status_storage()
+ status_pointer = C.NK_get_status_storage_as_string()
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
status_string = gs(status_pointer)
+ assert len(status_string) > 0
status_dict = get_dict_from_dissect(status_string)
default_admin_password_retry_count = 3
assert int(status_dict['AdminPwRetryCount']) == default_admin_password_retry_count
def test_sd_card_usage(C):
- data_pointer = C.NK_get_SD_usage_data()
+ data_pointer = C.NK_get_SD_usage_data_as_string()
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
data_string = gs(data_pointer)
assert len(data_string) > 0
data_dict = get_dict_from_dissect(data_string)